From cbffe18384e74f0d70e9ce3f22de88b3d73da6a1 Mon Sep 17 00:00:00 2001 From: Faiz Hashmi Date: Thu, 23 Jan 2025 15:45:36 +0300 Subject: [PATCH] Check appointmnet filter for provider --- lib/views/branches/provider_profile_view.dart | 2 +- lib/views/dashboard/dashboard_view.dart | 2 +- .../fragments/appointments_fragment.dart | 112 +++++++++--------- .../dashboard/fragments/home_fragment.dart | 4 +- 4 files changed, 60 insertions(+), 60 deletions(-) diff --git a/lib/views/branches/provider_profile_view.dart b/lib/views/branches/provider_profile_view.dart index 36a5e48..95bb437 100644 --- a/lib/views/branches/provider_profile_view.dart +++ b/lib/views/branches/provider_profile_view.dart @@ -90,7 +90,7 @@ class _ProviderProfileViewState extends State { Row( children: [ ("${LocaleKeys.companyName.tr()}:").toText(color: MyColors.lightTextColor, fontSize: 12), - 4.width, + 4.width, (appointmentsVM.providerProfileModel!.companyName ?? appointmentsVM.providerProfileModel!.name).toString().toText( fontSize: 16, isBold: true, diff --git a/lib/views/dashboard/dashboard_view.dart b/lib/views/dashboard/dashboard_view.dart index ea3c695..14ef873 100644 --- a/lib/views/dashboard/dashboard_view.dart +++ b/lib/views/dashboard/dashboard_view.dart @@ -34,7 +34,7 @@ class _DashboardViewState extends State { void initState() { super.initState(); dashboardVM = context.read(); - scheduleMicrotask(() => dashboardVM.onRefresh(context, dashboardRouteEnum: widget.dashboardRouteEnum)); + scheduleMicrotask(() async => await dashboardVM.onRefresh(context, dashboardRouteEnum: widget.dashboardRouteEnum)); } @override diff --git a/lib/views/dashboard/fragments/appointments_fragment.dart b/lib/views/dashboard/fragments/appointments_fragment.dart index ae94cb6..4a38717 100644 --- a/lib/views/dashboard/fragments/appointments_fragment.dart +++ b/lib/views/dashboard/fragments/appointments_fragment.dart @@ -60,63 +60,65 @@ class AppointmentsFragment extends StatelessWidget { }, ), 16.height, - RefreshIndicator( - onRefresh: () async { - int index = appointmentsVM.appointmentsFilterOptions.indexWhere((element) => element.isSelected); - if (index != -1) { - AppointmentStatusEnum appointmentStatusEnum = appointmentsVM.appointmentsFilterOptions[index].id.toAppointmentStatusEnum(); - appointmentsVM.applyFilterOnAppointmentsVMForCustomers(appointmentStatusEnum: appointmentStatusEnum); - } - }, - child: appointmentsVM.state == ViewState.busy - ? const Center(child: CircularProgressIndicator()) - : appointmentsVM.myFilteredAppointmentsForCustomers.isEmpty - ? AppState().getIsViewOnly - ? LocaleKeys.loginToViewAppointments.tr().toText(fontSize: 16, color: MyColors.lightTextColor) - : Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - LocaleKeys.noAppointmentstoShow.tr().toText(fontSize: 16, color: MyColors.lightTextColor), - if (appointmentsVM.appointmentFiltersCounter > 0) ...[ - 8.height, - InkWell( - onTap: () async { - appointmentsVM.clearAppointmentFilters(); - await appointmentsVM.applyFilterOnAppointmentsVMForCustomers(appointmentStatusEnum: AppointmentStatusEnum.allAppointments); - }, - child: LocaleKeys.clearFilters.tr().toText( - fontSize: 14, - isBold: true, - color: MyColors.darkPrimaryColor, - ), - ), + Expanded( + child: RefreshIndicator( + onRefresh: () async { + int index = appointmentsVM.appointmentsFilterOptions.indexWhere((element) => element.isSelected); + if (index != -1) { + AppointmentStatusEnum appointmentStatusEnum = appointmentsVM.appointmentsFilterOptions[index].id.toAppointmentStatusEnum(); + appointmentsVM.applyFilterOnAppointmentsVMForCustomers(appointmentStatusEnum: appointmentStatusEnum); + } + }, + child: appointmentsVM.state == ViewState.busy + ? const Center(child: CircularProgressIndicator()) + : appointmentsVM.myFilteredAppointmentsForCustomers.isEmpty + ? AppState().getIsViewOnly + ? LocaleKeys.loginToViewAppointments.tr().toText(fontSize: 16, color: MyColors.lightTextColor) + : Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + LocaleKeys.noAppointmentstoShow.tr().toText(fontSize: 16, color: MyColors.lightTextColor), + if (appointmentsVM.appointmentFiltersCounter > 0) ...[ + 8.height, + InkWell( + onTap: () async { + appointmentsVM.clearAppointmentFilters(); + await appointmentsVM.applyFilterOnAppointmentsVMForCustomers(appointmentStatusEnum: AppointmentStatusEnum.allAppointments); + }, + child: LocaleKeys.clearFilters.tr().toText( + fontSize: 14, + isBold: true, + color: MyColors.darkPrimaryColor, + ), + ), + ], ], - ], - ) - : ListView.separated( - separatorBuilder: (context, index) => 12.height, - shrinkWrap: true, - itemCount: appointmentsVM.myFilteredAppointmentsForCustomers.length, - itemBuilder: (BuildContext context, int index) { - return AppointmentFragmentTileWidget( - onTapped: () { - AppointmentListModel appointmentModel = appointmentsVM.myFilteredAppointmentsForCustomers[index]; - appointmentModel.appointmentServicesList!.forEach((service) { - double totalServicePrice = 0.0; - service.serviceItems!.forEach((item) { - totalServicePrice = totalServicePrice + (double.parse("${item.price ?? 0.0}")); + ) + : ListView.separated( + separatorBuilder: (context, index) => 12.height, + shrinkWrap: true, + itemCount: appointmentsVM.myFilteredAppointmentsForCustomers.length, + itemBuilder: (BuildContext context, int index) { + return AppointmentFragmentTileWidget( + onTapped: () { + AppointmentListModel appointmentModel = appointmentsVM.myFilteredAppointmentsForCustomers[index]; + appointmentModel.appointmentServicesList!.forEach((service) { + double totalServicePrice = 0.0; + service.serviceItems!.forEach((item) { + totalServicePrice = totalServicePrice + (double.parse("${item.price ?? 0.0}")); + }); + service.currentTotalServicePrice = totalServicePrice; }); - service.currentTotalServicePrice = totalServicePrice; - }); - navigateWithName(context, AppRoutes.appointmentDetailView, arguments: appointmentModel); - }, - appointmentListModel: appointmentsVM.myFilteredAppointmentsForCustomers[index], - ).margin(left: 21, right: 21); - }, - ), - ).toViewOnly(context, onTap: () { - navigateWithName(context, AppRoutes.loginWithPassword, arguments: false); - }), + navigateWithName(context, AppRoutes.appointmentDetailView, arguments: appointmentModel); + }, + appointmentListModel: appointmentsVM.myFilteredAppointmentsForCustomers[index], + ).margin(left: 21, right: 21).toViewOnly(context, onTap: () { + navigateWithName(context, AppRoutes.loginWithPassword, arguments: false); + }); + }, + ), + ), + ) ], ), ), diff --git a/lib/views/dashboard/fragments/home_fragment.dart b/lib/views/dashboard/fragments/home_fragment.dart index a88cfef..98dd995 100644 --- a/lib/views/dashboard/fragments/home_fragment.dart +++ b/lib/views/dashboard/fragments/home_fragment.dart @@ -58,9 +58,7 @@ class HomeFragment extends StatelessWidget { width: double.infinity, height: double.infinity, child: RefreshIndicator( - onRefresh: () async { - await context.read().onRefresh(context); - }, + onRefresh: () async => await context.read().onRefresh(context), child: ListView( children: [ 16.height,