From 5ed15fa243cafcb969b7a486db87169ffc683921 Mon Sep 17 00:00:00 2001 From: Faiz Hashmi Date: Wed, 9 Oct 2024 14:39:23 +0300 Subject: [PATCH] Added Images support in ReqChat --- lib/main.dart | 11 ++- .../appoinment_detail_list_page.dart | 5 +- lib/views/appoinments/appointment_page.dart | 7 +- .../widget/general_appointment_widget.dart | 82 +++++++++---------- .../duplication/matched_services_page.dart | 52 ++++-------- .../settings/services/items_list_page.dart | 2 +- pubspec.yaml | 4 +- 7 files changed, 74 insertions(+), 89 deletions(-) diff --git a/lib/main.dart b/lib/main.dart index 86fb33d..6dc4fe6 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -71,7 +71,10 @@ Future main() async { ), ), ChangeNotifierProvider( - create: (_) => UserVM(userRepo: injector.get(), commanServices: injector.get()), + create: (_) => UserVM( + userRepo: injector.get(), + commanServices: injector.get(), + ), ), // ChangeNotifierProvider( @@ -128,10 +131,14 @@ Future main() async { create: (_) => ChatVM( chatRepo: injector.get(), requestRepo: injector.get(), + commonServices: injector.get(), ), ), ChangeNotifierProvider( - create: (_) => PaymentVM(paymentService: injector.get(), paymentRepo: injector.get()), + create: (_) => PaymentVM( + paymentService: injector.get(), + paymentRepo: injector.get(), + ), ), ], child: const MyApp(), diff --git a/lib/views/appoinments/appoinment_detail_list_page.dart b/lib/views/appoinments/appoinment_detail_list_page.dart index 90e831c..b1c1fa7 100644 --- a/lib/views/appoinments/appoinment_detail_list_page.dart +++ b/lib/views/appoinments/appoinment_detail_list_page.dart @@ -40,8 +40,7 @@ class AppointmentDetailListPage extends StatelessWidget { onTap: () { appointmentsVM.selectedAppointmentId = appointmentsVM.myFilteredAppointments2[appointmentsVM.selectedAppointmentIndex].customerAppointmentList![index].id ?? 0; appointmentsVM.selectedAppointmentSubIndex = index; - navigateWithName(context, ProviderAppRoutes.updateAppointmentPage, - arguments: appointmentsVM.myFilteredAppointments2[appointmentsVM.selectedAppointmentIndex].customerAppointmentList![index]); + navigateWithName(context, ProviderAppRoutes.updateAppointmentPage, arguments: appointmentsVM.myFilteredAppointments2[appointmentsVM.selectedAppointmentIndex].customerAppointmentList![index]); }, ); }, @@ -63,7 +62,7 @@ class AppointmentDetailListPage extends StatelessWidget { navigateWithName(context, ProviderAppRoutes.mergeAppointments); }, ) - : SizedBox(), + : const SizedBox(), ], )), ); diff --git a/lib/views/appoinments/appointment_page.dart b/lib/views/appoinments/appointment_page.dart index 5e66210..15335db 100644 --- a/lib/views/appoinments/appointment_page.dart +++ b/lib/views/appoinments/appointment_page.dart @@ -14,6 +14,7 @@ import 'package:mc_common_app/utils/navigator.dart'; import 'package:mc_common_app/utils/utils.dart'; import 'package:mc_common_app/view_models/appointments_view_model.dart'; import 'package:mc_common_app/widgets/common_widgets/categories_list.dart'; +import 'package:mc_common_app/widgets/empty_widget.dart'; import 'package:mc_common_app/widgets/extensions/extensions_widget.dart'; import 'package:flutter/material.dart'; import 'package:mc_common_app/classes/consts.dart'; @@ -99,9 +100,9 @@ class _AppointmentPageState extends State { }, ), if (appointmentsVM.myFilteredAppointments2.isEmpty) - Padding( - padding: const EdgeInsets.symmetric(vertical: 12), - child: LocaleKeys.noAppointmentFound.tr().toText(), + EmptyWidget( + spacerWidget: const SizedBox(height: 25), + text: LocaleKeys.noAppointmentFound.tr(), ), ListView.separated( itemBuilder: (context, index) { diff --git a/lib/views/dashboard/widget/general_appointment_widget.dart b/lib/views/dashboard/widget/general_appointment_widget.dart index dcfcff7..daee6a6 100644 --- a/lib/views/dashboard/widget/general_appointment_widget.dart +++ b/lib/views/dashboard/widget/general_appointment_widget.dart @@ -2,10 +2,12 @@ import 'package:flutter/material.dart'; import 'package:mc_common_app/classes/consts.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/appointments_models/appointment_list_model.dart'; import 'package:mc_common_app/theme/colors.dart'; import 'package:mc_common_app/widgets/extensions/extensions_widget.dart'; import 'package:flutter_svg/flutter_svg.dart'; +import 'package:easy_localization/easy_localization.dart'; class GeneralAppointmentWidget extends StatelessWidget { final AppointmentListModel appointmentListModel; @@ -127,7 +129,7 @@ class GeneralAppointmentWidget extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.start, children: [ if (isNeedToShowMergeStatus) - "Appointment Merged".toText(color: MyColors.white).toContainer( + "${LocaleKeys.merged.tr()}".toText(color: MyColors.white).toContainer( padding: const EdgeInsets.symmetric(horizontal: 6, vertical: 3), borderRadius: 12, backgroundColor: MyColors.greenColor, @@ -149,7 +151,7 @@ class GeneralAppointmentWidget extends StatelessWidget { (appointmentListModel.customerName ?? "").toText(color: MyColors.black, isBold: true, fontSize: 16), Row( children: [ - "Phone:".toText( + "${LocaleKeys.phone.tr()}:".toText( color: MyColors.lightTextColor, ), 2.width, @@ -162,38 +164,39 @@ class GeneralAppointmentWidget extends StatelessWidget { mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: [ - "Appt. On:".toText( + "${LocaleKeys.time.tr()}:".toText( color: MyColors.lightTextColor, ), + 4.width, + Flexible(child: (appointmentListModel.duration ?? "").toText(fontSize: 8)) + ], + ), + Row( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + "${LocaleKeys.date.tr()}:".toText( + color: MyColors.lightTextColor, + ), + 4.width, + Flexible(child: appointmentListModel.appointmentDate!.toFormattedDateWithoutTime().toText(fontSize: 8)) + ], + ), + Row( + children: [ + "${LocaleKeys.location.tr()}: ".toText(color: MyColors.lightTextColor), 2.width, - Expanded( - child: "${appointmentListModel.duration ?? ""} ${appointmentListModel.appointmentDate!.toFormattedDateWithoutTime()}".toText( - fontSize: 12, - ), + (appointmentListModel.appointmentType == 1 ? LocaleKeys.home.tr() : LocaleKeys.workshop.tr()).toText( + fontSize: 12, ), ], ), - // Row( - // children: [ - // "Location: ".toText( - // color: MyColors.lightTextColor, - // ), - // 2.width, - // appointmentListModel.appointmentType.toString().toText( - // fontSize: 12, - // ), - // ], - // ), ], ), ), if (!isNeedTotalPayment) if (appointmentListModel.customerAppointmentList!.length > 1) - "${appointmentListModel.customerAppointmentList!.length - 1}+ Appointments" - .toText( - fontSize: 8, - ) - .toContainer( + "${appointmentListModel.customerAppointmentList!.length - 1}+ Appointments".toText(fontSize: 8).toContainer( borderRadius: 15, backgroundColor: MyColors.lightGreyEAColor, padding: const EdgeInsets.symmetric( @@ -223,21 +226,18 @@ class GeneralAppointmentWidget extends StatelessWidget { Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - 24.height, - "Total Amount".toText( - fontSize: 12, - color: MyColors.lightTextColor, - isBold: true, - ), + 18.height, + LocaleKeys.totalAmount.tr().toText( + fontSize: 12, + color: MyColors.lightTextColor, + ), Row( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.end, children: [ appointmentListModel.totalAmount.toString().toText(fontSize: 16, isBold: true), 2.width, - "SAR:".toText( - color: MyColors.lightTextColor, - ), + LocaleKeys.sar.tr().toText(color: MyColors.lightTextColor), ], ), ], @@ -246,20 +246,17 @@ class GeneralAppointmentWidget extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.start, children: [ 2.height, - "Remaining Amount".toText( - fontSize: 12, - color: MyColors.lightTextColor, - isBold: true, - ), + LocaleKeys.remainingAmount.tr().toText( + fontSize: 12, + color: MyColors.lightTextColor, + ), Row( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.end, children: [ appointmentListModel.remainingAmount.toString().toText(fontSize: 16, isBold: true), 2.width, - "SAR:".toText( - color: MyColors.lightTextColor, - ), + LocaleKeys.sar.tr().toText(color: MyColors.lightTextColor), ], ), ], @@ -269,10 +266,7 @@ class GeneralAppointmentWidget extends StatelessWidget { ], ), ), - if (!isNeedToShowItems) - const Icon( - Icons.arrow_forward, - ), + if (!isNeedToShowItems) const Icon(Icons.arrow_forward), ], ), ], diff --git a/lib/views/settings/services/duplication/matched_services_page.dart b/lib/views/settings/services/duplication/matched_services_page.dart index 7f265a8..1058866 100644 --- a/lib/views/settings/services/duplication/matched_services_page.dart +++ b/lib/views/settings/services/duplication/matched_services_page.dart @@ -1,6 +1,4 @@ -import 'dart:convert'; - -import 'package:mc_common_app/models/general_models/generic_resp_model.dart'; +import 'package:mc_common_app/generated/locale_keys.g.dart'; import 'package:mc_common_app/view_models/service_view_model.dart'; import 'package:car_provider_app/views/settings/services/duplication/sheet/approved_branches_list_sheet.dart'; import 'package:car_provider_app/views/settings/services/duplication/sheet/items_selection_sheet.dart'; @@ -11,7 +9,6 @@ import 'package:mc_common_app/extensions/string_extensions.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:mc_common_app/models/services_models/item_model.dart'; import 'package:mc_common_app/theme/colors.dart'; -import 'package:mc_common_app/utils/navigator.dart'; import 'package:mc_common_app/utils/utils.dart'; import 'package:mc_common_app/widgets/bottom_sheet.dart'; import 'package:mc_common_app/widgets/button/show_fill_button.dart'; @@ -20,6 +17,7 @@ import 'package:mc_common_app/widgets/dropdown/dropdown_text.dart'; import 'package:mc_common_app/widgets/empty_widget.dart'; import 'package:mc_common_app/widgets/extensions/extensions_widget.dart'; import 'package:provider/provider.dart'; +import 'package:easy_localization/easy_localization.dart'; class MatchedServicesPage extends StatefulWidget { final MatchServicesArguments? matchServicesArguments; @@ -47,8 +45,8 @@ class _MatchedServicesPageState extends State { @override Widget build(BuildContext context) { return Scaffold( - appBar: const CustomAppBar( - title: "Select Services", + appBar: CustomAppBar( + title: LocaleKeys.selectServices.tr(), ), body: SizedBox( width: double.infinity, @@ -74,19 +72,17 @@ class _MatchedServicesPageState extends State { serviceVM.selectAllServices(v ?? false); }, ), - "Select All".toText( - isBold: true, - ) + LocaleKeys.selectAll.tr().toText(isBold: true) ], ), Container( alignment: Alignment.centerRight, - child: "Unselect All".toText( - color: MyColors.primaryColor, - isUnderLine: true, - isBold: true, - ), margin: const EdgeInsets.symmetric(horizontal: 14, vertical: 7), + child: LocaleKeys.unselectAll.tr().toText( + color: MyColors.primaryColor, + isUnderLine: true, + isBold: true, + ), ).onPress(() { serviceVM.selectAllServices(false); }), @@ -98,7 +94,7 @@ class _MatchedServicesPageState extends State { if (model.matchedServices == null) { return const Center(child: CircularProgressIndicator()); } else if (model.matchedServices!.isEmpty) { - return const EmptyWidget(text: "No Services found", isWrapedColumn: false); + return EmptyWidget(text: LocaleKeys.noServicesAvailable.tr(), isWrappedColumn: false); } return ListView.separated( itemBuilder: (context, index) { @@ -110,7 +106,7 @@ class _MatchedServicesPageState extends State { value: model.matchedServices![index].isExpandedOrSelected, onChanged: (v) { if (model.matchedServices![index].serviceItems!.isEmpty) { - Utils.showToast("No Items Available in this service"); + Utils.showToast(LocaleKeys.noItemstoShow.tr()); } else { model.matchedServices![index].isExpandedOrSelected = v ?? false; model.updateServiceItem(index, model.matchedServices![index].isExpandedOrSelected); @@ -123,8 +119,7 @@ class _MatchedServicesPageState extends State { crossAxisAlignment: CrossAxisAlignment.start, children: [ model.matchedServices![index].serviceDescription.toString().toText(fontSize: 16, isBold: true), - "${model.matchedServices![index].serviceItems!.where((c) => c.isUpdateOrSelected == true).length} items selected out of ${model.matchedServices![index].serviceItems!.length}" - .toText(color: MyColors.lightTextColor) + "${model.matchedServices![index].serviceItems!.where((c) => c.isUpdateOrSelected == true).length} items selected out of ${model.matchedServices![index].serviceItems!.length}".toText(color: MyColors.lightTextColor) ], ), ), @@ -158,25 +153,14 @@ class _MatchedServicesPageState extends State { ), 12.height, ShowFillButton( - title: "Copy Selected Services", + title: LocaleKeys.copySelectedServices.tr(), maxWidth: double.infinity, margin: const EdgeInsets.all(14), onPressed: () async { - Utils.showLoading(context); - List items = []; - for (var element in serviceVM.matchedServices!) { - items.addAll(element.serviceItems!.where((e) => e.isUpdateOrSelected == true).map((e) => e.id ?? 0).toList()); - } - Map map = { - "providerBranchID": widget.matchServicesArguments!.newBranch.toString(), - "serviceItems": items, - }; - print(jsonEncode(map)); - GenericRespModel mResponse = await serviceVM.duplicateItems(map); - Utils.hideLoading(context); - Utils.showToast(mResponse.message ?? ""); - pop(context); - pop(context); + await serviceVM.duplicateItems( + providerBranchID: widget.matchServicesArguments!.newBranch.toString(), + context: context, + ); }, ), ], diff --git a/lib/views/settings/services/items_list_page.dart b/lib/views/settings/services/items_list_page.dart index 8fc7592..0163e2a 100644 --- a/lib/views/settings/services/items_list_page.dart +++ b/lib/views/settings/services/items_list_page.dart @@ -41,7 +41,7 @@ class ItemsListPage extends StatelessWidget { return model.state == ViewState.busy ? const Center(child: CircularProgressIndicator()) : model.serviceItems!.data!.isEmpty - ? const EmptyWidget(text: "No Service Items found", isWrapedColumn: false) + ? const EmptyWidget(text: "No Service Items found", isWrappedColumn: false) : ListView.separated( itemBuilder: (BuildContext context, int index) { return SizedBox( diff --git a/pubspec.yaml b/pubspec.yaml index 724eed1..ee58bea 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -40,8 +40,8 @@ dependencies: # path: C:/Users/mirza.shafique/AndroidStudioProjects/mc_common_app mc_common_app: -# path: /Volumes/Data/Projects/Flutter/car_common_app - path: /Users/amir/StudioProjects/car_common_app + path: /Volumes/Data/Projects/Flutter/car_common_app +# path: /Users/amir/StudioProjects/car_common_app