diff --git a/assets/langs/ar-SA.json b/assets/langs/ar-SA.json index 58e689f..26b3b82 100644 --- a/assets/langs/ar-SA.json +++ b/assets/langs/ar-SA.json @@ -645,5 +645,7 @@ "searchByVehicleModel": "البحث حسب طراز المركبة", "customerCarePrompt": "هل لديك أي استفسار؟ نحن هنا لخدمتك. انقر هنا للتحدث مع خدمة العملاء لدينا الآن.", "callNow": "اتصل الآن", - "condition": "الحالة" + "condition": "الحالة", + "servicesNotAvailableHomeLocation": "بعض الخدمات غير متوفرة في الموقع المنزلي.", + "additionalChargesNotice": "هذه الرسوم إضافية على رسوم الخدمة الفعلية. قد تختلف الرسوم للعناصر الثقيلة." } \ No newline at end of file diff --git a/assets/langs/en-US.json b/assets/langs/en-US.json index cdec152..178eeea 100644 --- a/assets/langs/en-US.json +++ b/assets/langs/en-US.json @@ -646,5 +646,7 @@ "searchByVehicleModel": "Search By Vehicle Model", "customerCarePrompt": "Got any question? We are here to service. Click here to talk to our customer care right now.", "callNow": "Call Now", - "condition": "Condition" + "condition": "Condition", + "servicesNotAvailableHomeLocation": "Some services are not available on home location.", + "additionalChargesNotice": "These charges are additional to the actual service charges. For heavy items the charges may vary." } \ No newline at end of file diff --git a/lib/generated/codegen_loader.g.dart b/lib/generated/codegen_loader.g.dart index 92f745e..8529b51 100644 --- a/lib/generated/codegen_loader.g.dart +++ b/lib/generated/codegen_loader.g.dart @@ -661,7 +661,9 @@ class CodegenLoader extends AssetLoader{ "searchByVehicleModel": "البحث حسب طراز المركبة", "customerCarePrompt": "هل لديك أي استفسار؟ نحن هنا لخدمتك. انقر هنا للتحدث مع خدمة العملاء لدينا الآن.", "callNow": "اتصل الآن", - "condition": "الحالة" + "condition": "الحالة", + "servicesNotAvailableHomeLocation": "بعض الخدمات غير متوفرة في الموقع المنزلي.", + "additionalChargesNotice": "هذه الرسوم إضافية على رسوم الخدمة الفعلية. قد تختلف الرسوم للعناصر الثقيلة." }; static const Map en_US = { "firstTimeLogIn": "First Time Log In", @@ -1311,7 +1313,9 @@ static const Map en_US = { "searchByVehicleModel": "Search By Vehicle Model", "customerCarePrompt": "Got any question? We are here to service. Click here to talk to our customer care right now.", "callNow": "Call Now", - "condition": "Condition" + "condition": "Condition", + "servicesNotAvailableHomeLocation": "Some services are not available on home location.", + "additionalChargesNotice": "These charges are additional to the actual service charges. For heavy items the charges may vary." }; static const Map> mapLocales = {"ar_SA": ar_SA, "en_US": en_US}; } diff --git a/lib/generated/locale_keys.g.dart b/lib/generated/locale_keys.g.dart index 9693a8e..0e29163 100644 --- a/lib/generated/locale_keys.g.dart +++ b/lib/generated/locale_keys.g.dart @@ -625,5 +625,7 @@ abstract class LocaleKeys { static const customerCarePrompt = 'customerCarePrompt'; static const callNow = 'callNow'; static const condition = 'condition'; + static const servicesNotAvailableHomeLocation = 'servicesNotAvailableHomeLocation'; + static const additionalChargesNotice = 'additionalChargesNotice'; } diff --git a/lib/view_models/appointments_view_model.dart b/lib/view_models/appointments_view_model.dart index b1d8d7e..0164622 100644 --- a/lib/view_models/appointments_view_model.dart +++ b/lib/view_models/appointments_view_model.dart @@ -474,10 +474,9 @@ class AppointmentsVM extends BaseVM { int selectedSubServicesCounter = 0; void onItemUpdateOrSelected(int index, bool selected, int itemId) { - int serviceIndex = servicesInCurrentAppointment.indexWhere((element) => element.serviceId == currentServiceSelection!.serviceId!); - // print("servicesInCurrentAppointment: ${servicesInCurrentAppointment.length}"); - if (serviceIndex == -1) { - return; + int serviceIndex = 0; + if (servicesInCurrentAppointment.isNotEmpty) { + serviceIndex = servicesInCurrentAppointment.indexWhere((element) => element.serviceId == currentServiceSelection!.serviceId!); } log("index: $index"); @@ -500,7 +499,6 @@ class AppointmentsVM extends BaseVM { } } else { log("currentServiceSelection!.serviceItems: ${currentServiceSelection!.serviceItems!.length}"); - selectedSubServicesCounter = selectedSubServicesCounter - 1; currentServiceSelection!.serviceItems!.removeWhere((element) => element.id == itemId); log("currentServiceSelection!.serviceItems: ${currentServiceSelection!.serviceItems!.length}"); diff --git a/lib/views/advertisement/components/damage_pictures_bottom_sheet.dart b/lib/views/advertisement/components/damage_pictures_bottom_sheet.dart index 1eb22c2..95f46e1 100644 --- a/lib/views/advertisement/components/damage_pictures_bottom_sheet.dart +++ b/lib/views/advertisement/components/damage_pictures_bottom_sheet.dart @@ -34,7 +34,7 @@ class _DamagePicturesListState extends State { child: Consumer( builder: (context, appointmentsVM, _) { if (appointmentsVM.state == ViewState.busy) { - return Center(child: CircularProgressIndicator()); + return const Center(child: CircularProgressIndicator()); } return appointmentsVM.serviceItemsFromApi.isEmpty ? const EmptyWidget() @@ -55,9 +55,9 @@ class _DamagePicturesListState extends State { children: [ serviceItemModel.name.toString().toText(fontSize: 16, isBold: true), 4.height, - showItem(LocaleKeys.availableforAppointment.tr() + ":", (serviceItemModel.isAllowAppointment ?? false) ? "Yes" : "No", valueColor: Colors.green), - showItem(LocaleKeys.allowingWorkshopService.tr() + ":", (serviceItemModel.isAppointmentCompanyLoc ?? false) ? "Yes" : "No", valueColor: Colors.green), - showItem(LocaleKeys.allowingHomeService.tr() + ":", (serviceItemModel.isAppointmentCustomerLoc ?? false) ? "Yes" : "No", valueColor: Colors.green), + showItem("${LocaleKeys.availableforAppointment.tr()}:", (serviceItemModel.isAllowAppointment ?? false) ? "Yes" : "No", valueColor: Colors.green), + showItem("${LocaleKeys.allowingWorkshopService.tr()}:", (serviceItemModel.isAppointmentCompanyLoc ?? false) ? "Yes" : "No", valueColor: Colors.green), + showItem("${LocaleKeys.allowingHomeService.tr()}:", (serviceItemModel.isAppointmentCustomerLoc ?? false) ? "Yes" : "No", valueColor: Colors.green), 12.height, LocaleKeys.serviceAmount.tr().toText(fontSize: 12, color: MyColors.lightTextColor, isBold: true), Row( diff --git a/lib/views/appointments/widgets/appointment_service_pick_bottom_sheet.dart b/lib/views/appointments/widgets/appointment_service_pick_bottom_sheet.dart index e1c5e43..7aabee9 100644 --- a/lib/views/appointments/widgets/appointment_service_pick_bottom_sheet.dart +++ b/lib/views/appointments/widgets/appointment_service_pick_bottom_sheet.dart @@ -1,18 +1,21 @@ +import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; import 'package:mc_common_app/config/routes.dart'; import 'package:mc_common_app/extensions/int_extensions.dart'; import 'package:mc_common_app/extensions/string_extensions.dart'; +import 'package:mc_common_app/generated/locale_keys.g.dart'; import 'package:mc_common_app/models/general_models/widgets_models.dart'; import 'package:mc_common_app/theme/colors.dart'; +import 'package:mc_common_app/utils/enums.dart'; import 'package:mc_common_app/utils/navigator.dart'; import 'package:mc_common_app/view_models/appointments_view_model.dart'; +import 'package:mc_common_app/views/location_views/pick_location_page.dart'; import 'package:mc_common_app/widgets/button/show_fill_button.dart'; import 'package:mc_common_app/widgets/dropdown/dropdow_field.dart'; import 'package:mc_common_app/widgets/extensions/extensions_widget.dart'; import 'package:mc_common_app/widgets/txt_field.dart'; import 'package:provider/provider.dart'; - class AppointmentServicePickBottomSheet extends StatelessWidget { const AppointmentServicePickBottomSheet({Key? key}) : super(key: key); @@ -33,7 +36,7 @@ class AppointmentServicePickBottomSheet extends StatelessWidget { Row( mainAxisAlignment: MainAxisAlignment.start, children: [ - "Select Category".toText(fontSize: 24, isBold: true), + LocaleKeys.selectCategory.tr().toText(fontSize: 24, isBold: true), ], ), 30.height, @@ -45,10 +48,8 @@ class AppointmentServicePickBottomSheet extends StatelessWidget { return DropdownField( (DropValue value) => appointmentsVM.updateProviderCategoryId(SelectionModel(selectedId: value.id, selectedOption: value.value, itemPrice: value.subValue)), list: appointmentsVM.branchCategories, - hint: "Select Category", - dropdownValue: appointmentsVM.branchSelectedCategoryId.selectedId != -1 - ? DropValue(appointmentsVM.branchSelectedCategoryId.selectedId, appointmentsVM.branchSelectedCategoryId.selectedOption, "") - : null, + hint: LocaleKeys.selectCategory.tr(), + dropdownValue: appointmentsVM.branchSelectedCategoryId.selectedId != -1 ? DropValue(appointmentsVM.branchSelectedCategoryId.selectedId, appointmentsVM.branchSelectedCategoryId.selectedOption, "") : null, ); }, ), @@ -75,10 +76,8 @@ class AppointmentServicePickBottomSheet extends StatelessWidget { return DropdownField( (DropValue value) => appointmentsVM.updateBranchServiceId(SelectionModel(selectedId: value.id, selectedOption: value.value, itemPrice: value.subValue)), list: serviceCategories, - hint: "Select Service", - dropdownValue: appointmentsVM.branchSelectedServiceId.selectedId != -1 - ? DropValue(appointmentsVM.branchSelectedServiceId.selectedId, appointmentsVM.branchSelectedServiceId.selectedOption, "") - : null, + hint: LocaleKeys.selectService.tr(), + dropdownValue: appointmentsVM.branchSelectedServiceId.selectedId != -1 ? DropValue(appointmentsVM.branchSelectedServiceId.selectedId, appointmentsVM.branchSelectedServiceId.selectedOption, "") : null, ); }, ), @@ -101,7 +100,7 @@ class AppointmentServicePickBottomSheet extends StatelessWidget { child: ShowFillButton( isFilled: appointmentsVM.isHomeTapped, maxHeight: 48, - title: "Home", + title: LocaleKeys.home.tr(), txtColor: appointmentsVM.isHomeTapped ? MyColors.white : MyColors.darkTextColor, onPressed: () => appointmentsVM.updateIsHomeTapped(true), ), @@ -112,7 +111,7 @@ class AppointmentServicePickBottomSheet extends StatelessWidget { isFilled: !appointmentsVM.isHomeTapped, txtColor: !appointmentsVM.isHomeTapped ? MyColors.white : MyColors.darkTextColor, maxHeight: 48, - title: "Workshop", + title: LocaleKeys.workshop.tr(), onPressed: () => appointmentsVM.updateIsHomeTapped(false), ), ), @@ -121,32 +120,31 @@ class AppointmentServicePickBottomSheet extends StatelessWidget { if (appointmentsVM.isHomeTapped) ...[ 8.height, TxtField( - hint: 'Pick Home Location', + hint: LocaleKeys.pickLocation.tr(), errorValue: appointmentsVM.pickHomeLocationError, value: appointmentsVM.pickedHomeLocation, isNeedClickAll: true, postfixData: Icons.location_on, postFixDataColor: MyColors.darkTextColor, onTap: () { - //TODO: open the place picked to pick the location and save it in provider. - appointmentsVM.updatePickedHomeLocation("PM58+F97, Al Olaya, Riyadh 12333"); + navigateTo( + context, + PickLocationPage( + onPickAddress: (double latitude, double longitude, String address) { + appointmentsVM.updatePickedHomeLocation(address); + appointmentsVM.setState(ViewState.idle); + }, + ), + ); }, ), 14.height, Row( crossAxisAlignment: CrossAxisAlignment.end, children: [ - const Icon( - Icons.warning, - color: MyColors.adPendingStatusColor, - size: 19, - ).paddingOnly(bottom: 2), + const Icon(Icons.warning, color: MyColors.adPendingStatusColor, size: 19).paddingOnly(bottom: 2), 3.width, - "Some services are not available on home location.".toText( - color: MyColors.adPendingStatusColor, - fontSize: 12, - isItalic: true, - ), + LocaleKeys.servicesNotAvailableHomeLocation.tr().toText(color: MyColors.adPendingStatusColor, fontSize: 12, isItalic: true), ], ), ] @@ -165,10 +163,10 @@ class AppointmentServicePickBottomSheet extends StatelessWidget { children: [ // TODO: This Price will be decided according to the service selected, We will calculate the KMs and multiple it with price per KMs 150.toString().toText(fontSize: 30, isBold: true), - "SAR".toText(fontSize: 15, isBold: true, color: MyColors.lightTextColor).paddingOnly(bottom: 5), + LocaleKeys.sar.tr().toText(fontSize: 15, isBold: true, color: MyColors.lightTextColor).paddingOnly(bottom: 5), ], ), - "These charges are additional to the actual service charges. For heavy items the charges may vary.".toText(fontSize: 12, color: MyColors.lightTextColor), + LocaleKeys.additionalChargesNotice.tr().toText(fontSize: 12, color: MyColors.lightTextColor), 22.height, ], SizedBox( @@ -176,7 +174,7 @@ class AppointmentServicePickBottomSheet extends StatelessWidget { child: ShowFillButton( maxHeight: 55, backgroundColor: !appointmentsVM.isServiceSelectionValidated() ? MyColors.lightTextColor.withOpacity(0.6) : MyColors.darkPrimaryColor, - title: "Next", + title: LocaleKeys.next.tr(), onPressed: () { bool isValidated = appointmentsVM.isServiceSelectionValidated(); if (isValidated) {