|
|
|
|
@ -1,3 +1,4 @@
|
|
|
|
|
import 'package:mc_common_app/classes/app_state.dart';
|
|
|
|
|
import 'package:mc_common_app/classes/consts.dart';
|
|
|
|
|
import 'package:mc_common_app/generated/locale_keys.g.dart';
|
|
|
|
|
import 'package:mc_common_app/view_models/appointments_view_model.dart';
|
|
|
|
|
@ -44,7 +45,7 @@ class AppointmentsFragment extends StatelessWidget {
|
|
|
|
|
})
|
|
|
|
|
],
|
|
|
|
|
).toViewOnly(context, onTap: () {
|
|
|
|
|
navigateWithName(context, AppRoutes.loginWithPassword);
|
|
|
|
|
navigateWithName(context, AppRoutes.loginWithPassword, arguments: false);
|
|
|
|
|
}),
|
|
|
|
|
body: SizedBox(
|
|
|
|
|
width: double.infinity,
|
|
|
|
|
@ -53,67 +54,68 @@ class AppointmentsFragment extends StatelessWidget {
|
|
|
|
|
children: [
|
|
|
|
|
16.height,
|
|
|
|
|
FiltersList(
|
|
|
|
|
filterList: appointmentsVM.appointmentsFilterOptions,
|
|
|
|
|
onFilterTapped: (index, selectedFilterId) {
|
|
|
|
|
appointmentsVM.applyFilterOnAppointmentsVMForCustomers(appointmentStatusEnum: selectedFilterId.toAppointmentStatusEnum());
|
|
|
|
|
}),
|
|
|
|
|
filterList: appointmentsVM.appointmentsFilterOptions,
|
|
|
|
|
onFilterTapped: (index, selectedFilterId) {
|
|
|
|
|
appointmentsVM.applyFilterOnAppointmentsVMForCustomers(appointmentStatusEnum: selectedFilterId.toAppointmentStatusEnum());
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
16.height,
|
|
|
|
|
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
|
|
|
|
|
? 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,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
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}"));
|
|
|
|
|
});
|
|
|
|
|
service.currentTotalServicePrice = totalServicePrice;
|
|
|
|
|
)
|
|
|
|
|
: 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}"));
|
|
|
|
|
});
|
|
|
|
|
navigateWithName(context, AppRoutes.appointmentDetailView, arguments: appointmentModel);
|
|
|
|
|
},
|
|
|
|
|
appointmentListModel: appointmentsVM.myFilteredAppointmentsForCustomers[index],
|
|
|
|
|
).margin(left: 21, right: 21);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
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);
|
|
|
|
|
navigateWithName(context, AppRoutes.loginWithPassword, arguments: false);
|
|
|
|
|
}),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
@ -128,7 +130,7 @@ class AppointmentsFragment extends StatelessWidget {
|
|
|
|
|
color: MyColors.white,
|
|
|
|
|
),
|
|
|
|
|
).toViewOnly(context, onTap: () {
|
|
|
|
|
navigateWithName(context, AppRoutes.loginWithPassword);
|
|
|
|
|
navigateWithName(context, AppRoutes.loginWithPassword, arguments: false);
|
|
|
|
|
}),
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
|