diff --git a/lib/view_models/schedule_view_model.dart b/lib/view_models/schedule_view_model.dart index 3bb42d9..d91b445 100644 --- a/lib/view_models/schedule_view_model.dart +++ b/lib/view_models/schedule_view_model.dart @@ -115,10 +115,15 @@ class ScheduleVM extends BaseVM { return response; } - getSchedules(String branchId) async { - schedule = null; - schedule = await scheduleRepo.getSchedules(branchId); - setState(ViewState.idle); + Future getSchedules(String branchId) async { + try { + setState(ViewState.busy); + schedule = null; + schedule = await scheduleRepo.getSchedules(branchId); + setState(ViewState.idle); + } catch (e) { + setState(ViewState.idle); + } } Future updateSchedule(Map map) async { diff --git a/lib/views/appoinments/add_new_service_appointment_page.dart b/lib/views/appoinments/add_new_service_appointment_page.dart index f2a68ba..e6bb02a 100644 --- a/lib/views/appoinments/add_new_service_appointment_page.dart +++ b/lib/views/appoinments/add_new_service_appointment_page.dart @@ -217,6 +217,7 @@ class _AddNewServiceAppointmentPageState extends State { ), 8.height, ChipsPickerItem( + isNeedLabelOnTop: true, hint: LocaleKeys.select_Services.tr(), itemsList: [...scheduleVM.selectedServicesItems], onClick: () { @@ -248,6 +249,7 @@ class _AddSchedulesPageState extends State { ), 8.height, ChipsPickerItem( + isNeedLabelOnTop: true, hint: LocaleKeys.offDays.tr(), itemsList: [...scheduleVM.selectedDaysItems], onClick: () { diff --git a/lib/views/branch_management/schedule/schedules_list_page.dart b/lib/views/branch_management/schedule/schedules_list_page.dart index c5d96a3..2cabe22 100644 --- a/lib/views/branch_management/schedule/schedules_list_page.dart +++ b/lib/views/branch_management/schedule/schedules_list_page.dart @@ -10,6 +10,7 @@ import 'package:mc_common_app/models/general_models/generic_resp_model.dart'; import 'package:mc_common_app/theme/colors.dart'; import 'package:mc_common_app/utils/date_helper.dart'; import 'package:mc_common_app/utils/dialogs_and_bottomsheets.dart'; +import 'package:mc_common_app/utils/enums.dart'; import 'package:mc_common_app/utils/navigator.dart'; import 'package:mc_common_app/utils/utils.dart'; import 'package:mc_common_app/widgets/button/show_fill_button.dart'; @@ -52,7 +53,7 @@ class _SchedulesListPageState extends State { GenericRespModel res = await serviceVM.setScheduleInactive(serviceVM.schedule!.data![index].id!, serviceVM.schedule!.data![index].serviceProviderBranchId!); Utils.hideLoading(context); if (res.messageStatus == 1) { - Utils.showToast(LocaleKeys.branch_deleted.tr()); + Utils.showToast(LocaleKeys.scheduleDeletedSuccessfully.tr()); } else { Utils.showToast(res.message ?? ""); } @@ -94,62 +95,67 @@ class _SchedulesListPageState extends State { ? EmptyWidget( text: LocaleKeys.noSchedulesFound.tr(), ).paddingAll(21) - : ListView.separated( - itemBuilder: (BuildContext context, int index) { - return Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Expanded(child: scheduleVM.schedule!.data![index].scheduleName.toString().toText(fontSize: 16)), - Padding( - padding: const EdgeInsets.all(4.0), - child: SvgPicture.asset( - MyAssets.icEdit, - width: 18, - height: 18, - ), - ).onPress(() { - scheduleVM.schedule!.data![index].branchId = widget.branchId ?? ""; - navigateWithName(context, AppRoutes.addSchedule, arguments: scheduleVM.schedule!.data![index]); - }), - MyAssets.closeWithOrangeBg - .buildSvg(height: 28, width: 28) - .onPress(() => deleteScheduleConfirmationSheet(index, scheduleVM, context)) - .paddingOnly(top: 3, left: 4), - ], - ), - 8.height, - showItem("${LocaleKeys.startDate.tr()}:", DateHelper.formatAsDayMonthYear(scheduleVM.schedule!.data![index].fromDate)), - showItem("${LocaleKeys.endDate.tr()}:", DateHelper.formatAsDayMonthYear(scheduleVM.schedule!.data![index].toDate)), - showItem("${LocaleKeys.shiftStartTime.tr()}:", scheduleVM.schedule!.data![index].startTime ?? ""), - showItem("${LocaleKeys.shiftEndTime.tr()}:", scheduleVM.schedule!.data![index].endTime ?? ""), - showItem("${LocaleKeys.slotsTime.tr()}:", "${scheduleVM.schedule!.data![index].slotDurationMinute} Mins"), - showItem("${LocaleKeys.appointmentPerSlot.tr()}:", scheduleVM.schedule!.data![index].perSlotAppointment.toString()), - showItem( - LocaleKeys.serviceLocation.tr(), scheduleVM.schedule!.data![index].appointmentType == 1 ? LocaleKeys.companyLocation.tr() : LocaleKeys.customerLocation.tr()), - showItem("${LocaleKeys.offDays.tr()}:", offDays(scheduleVM.schedule!.data![index])), - 12.height, - "${LocaleKeys.services.tr()}:".toText(fontSize: 12, color: MyColors.lightTextColor), - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: scheduleVM.schedule!.data![index].scheduleServices! - .map( - (element) => Container( - child: element.serviceDescription.toString().toText(fontSize: 12), - ), - ) - .toList(), - ) - ], - ).toWhiteContainer(width: double.infinity, allPading: 12); - }, - separatorBuilder: (BuildContext context, int index) { - return 12.height; + : RefreshIndicator( + onRefresh: () async { + await scheduleVM.getSchedules(widget.branchId ?? ""); }, - padding: const EdgeInsets.all(20), - itemCount: scheduleVM.schedule!.data!.length, + child: ListView.separated( + itemBuilder: (BuildContext context, int index) { + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Expanded(child: scheduleVM.schedule!.data![index].scheduleName.toString().toText(fontSize: 16)), + Padding( + padding: const EdgeInsets.all(4.0), + child: SvgPicture.asset( + MyAssets.icEdit, + width: 18, + height: 18, + ), + ).onPress(() { + scheduleVM.schedule!.data![index].branchId = widget.branchId ?? ""; + navigateWithName(context, AppRoutes.addSchedule, arguments: scheduleVM.schedule!.data![index]); + }), + MyAssets.closeWithOrangeBg + .buildSvg(height: 28, width: 28) + .onPress(() => deleteScheduleConfirmationSheet(index, scheduleVM, context)) + .paddingOnly(top: 3, left: 4), + ], + ), + 8.height, + showItem("${LocaleKeys.startDate.tr()}:", DateHelper.formatAsDayMonthYear(scheduleVM.schedule!.data![index].fromDate)), + showItem("${LocaleKeys.endDate.tr()}:", DateHelper.formatAsDayMonthYear(scheduleVM.schedule!.data![index].toDate)), + showItem("${LocaleKeys.shiftStartTime.tr()}:", scheduleVM.schedule!.data![index].startTime ?? ""), + showItem("${LocaleKeys.shiftEndTime.tr()}:", scheduleVM.schedule!.data![index].endTime ?? ""), + showItem("${LocaleKeys.slotsTime.tr()}:", "${scheduleVM.schedule!.data![index].slotDurationMinute} Mins"), + showItem("${LocaleKeys.appointmentPerSlot.tr()}:", scheduleVM.schedule!.data![index].perSlotAppointment.toString()), + showItem( + LocaleKeys.serviceLocation.tr(), scheduleVM.schedule!.data![index].appointmentType == 1 ? LocaleKeys.companyLocation.tr() : LocaleKeys.customerLocation.tr()), + showItem("${LocaleKeys.offDays.tr()}:", offDays(scheduleVM.schedule!.data![index])), + 12.height, + "${LocaleKeys.services.tr()}:".toText(fontSize: 12, color: MyColors.lightTextColor), + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: scheduleVM.schedule!.data![index].scheduleServices! + .map( + (element) => Container( + child: element.serviceDescription.toString().toText(fontSize: 12), + ), + ) + .toList(), + ) + ], + ).toWhiteContainer(width: double.infinity, allPading: 12); + }, + separatorBuilder: (BuildContext context, int index) { + return 12.height; + }, + padding: const EdgeInsets.all(20), + itemCount: scheduleVM.schedule!.data!.length, + ), ); }, ), @@ -161,7 +167,7 @@ class _SchedulesListPageState extends State { onPressed: () { navigateWithName(context, AppRoutes.addSchedule, arguments: ScheduleData(branchId: widget.branchId ?? "")); }, - ), + ), ], ), ), diff --git a/lib/views/branch_management/schedule/widgets/chips_picker_item.dart b/lib/views/branch_management/schedule/widgets/chips_picker_item.dart index 216584c..517bdff 100644 --- a/lib/views/branch_management/schedule/widgets/chips_picker_item.dart +++ b/lib/views/branch_management/schedule/widgets/chips_picker_item.dart @@ -15,54 +15,74 @@ class PickerItem { } class ChipsPickerItem extends StatelessWidget { + final bool isNeedLabelOnTop; final String hint; final List itemsList; final Function onClick; - const ChipsPickerItem({super.key, required this.hint, required this.itemsList, required this.onClick}); + const ChipsPickerItem({super.key, required this.isNeedLabelOnTop, required this.hint, required this.itemsList, required this.onClick}); @override Widget build(BuildContext context) { - return Row( + return Column( children: [ - if (itemsList.isEmpty) - Expanded( - child: Text( - hint, - style: const TextStyle(color: borderColor, fontSize: 15, fontWeight: MyFonts.Medium), - )), - if (itemsList.isNotEmpty) - Expanded( - child: ListView( - scrollDirection: Axis.horizontal, - children: [ - showItem(itemsList[0].title), - 6.width, - if (itemsList.length > 1) showItem(itemsList[1].title), - 6.width, - if (itemsList.length > 2) showItem("${itemsList.length - 2}+ more", isNeedToShowIcon: false), - 6.width, - ], - ), + if (isNeedLabelOnTop && hint.isNotEmpty) ...[ + Row( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + (hint).toText( + color: borderColor, + fontSize: 13, + fontWeight: MyFonts.Medium, + ), + ], ), - const Icon( - Icons.arrow_forward_ios_rounded, - size: 16, - color: MyColors.lightIconColor, - ), + 4.height, + ], + Row( + mainAxisAlignment: MainAxisAlignment.end, + children: [ + if (itemsList.isEmpty && !isNeedLabelOnTop) + Expanded( + child: Text( + hint, + style: const TextStyle(color: borderColor, fontSize: 15, fontWeight: MyFonts.Medium), + ), + ), + if (itemsList.isNotEmpty) + Expanded( + child: ListView( + scrollDirection: Axis.horizontal, + children: [ + showItem(itemsList[0].title), + 6.width, + if (itemsList.length > 1) showItem(itemsList[1].title), + 6.width, + if (itemsList.length > 2) showItem("${itemsList.length - 2}+ more", isNeedToShowIcon: false), + 6.width, + ], + ), + ), + const Icon( + Icons.arrow_forward_ios_rounded, + size: 16, + color: MyColors.lightIconColor, + ), + ], + ) + .toContainer( + width: double.infinity, + height: 45, + isEnabledBorder: true, + borderWidget: 2, + borderRadius: 0, + borderColor: MyColors.darkPrimaryColor, + ) + .onPress(() { + onClick(); + }), ], - ) - .toContainer( - width: double.infinity, - height: 45, - isEnabledBorder: true, - borderWidget: 2, - borderRadius: 0, - borderColor: MyColors.darkPrimaryColor, - ) - .onPress(() { - onClick(); - }); + ); } Widget showItem(String title, {bool isNeedToShowIcon = true}) { diff --git a/lib/views/branch_management/services/create_item_page.dart b/lib/views/branch_management/services/create_item_page.dart index 00f3c54..ac6297d 100644 --- a/lib/views/branch_management/services/create_item_page.dart +++ b/lib/views/branch_management/services/create_item_page.dart @@ -86,14 +86,6 @@ class _CreateItemPageState extends State { }, ), 12.height, - TxtField( - hint: LocaleKeys.itemDescription.tr(), - value: description, - onChanged: (v) { - description = v; - }, - ), - 12.height, TxtField( hint: LocaleKeys.itemPrice.tr(), value: price, @@ -121,6 +113,15 @@ class _CreateItemPageState extends State { }, ), 12.height, + TxtField( + hint: LocaleKeys.itemDescription.tr(), + value: description, + maxLines: 3, + onChanged: (v) { + description = v; + }, + ), + 12.height, if (pickedImage.isNotEmpty) ...[ PickedFilesContainer( pickedFiles: pickedImage, diff --git a/lib/views/dashboard/fragments/home_fragment.dart b/lib/views/dashboard/fragments/home_fragment.dart index 4a935ff..7a9b35d 100644 --- a/lib/views/dashboard/fragments/home_fragment.dart +++ b/lib/views/dashboard/fragments/home_fragment.dart @@ -105,6 +105,7 @@ class HomeFragment extends StatelessWidget { }, ).horPaddingMain(), AdsListWidget( + isDraftAds: false, shouldShowAdStatus: true, isAdsFragment: false, adsList: adVM.myActiveAdsForHome, @@ -128,6 +129,7 @@ class HomeFragment extends StatelessWidget { }, ).horPaddingMain(), AdsListWidget( + isDraftAds: false, shouldShowAdStatus: false, adsList: adVM.exploreAds.length >= 3 ? adVM.exploreAds.take(3).toList() : adVM.exploreAds, isAdsFragment: false,