diff --git a/lib/views/appoinments/appointment_page.dart b/lib/views/appoinments/appointment_page.dart index 8ce8dde..4a99e70 100644 --- a/lib/views/appoinments/appointment_page.dart +++ b/lib/views/appoinments/appointment_page.dart @@ -76,7 +76,7 @@ class _AppointmentPageState extends State { smallSize: 20, backgroundColor: MyColors.darkPrimaryColor, label: Text('${appointmentsVM.appointmentFiltersCounter}'), - child: MyAssets.searchIcon.buildSvg(), + child: MyAssets.searchIcon.buildSvg(height: 22, width: 22), ), ).onPress(() { navigateWithName(context, AppRoutes.appoinmentSearchFilterPage); diff --git a/lib/views/dashboard/widget/general_appointment_widget.dart b/lib/views/dashboard/widget/general_appointment_widget.dart index 35913c0..fc151e5 100644 --- a/lib/views/dashboard/widget/general_appointment_widget.dart +++ b/lib/views/dashboard/widget/general_appointment_widget.dart @@ -100,216 +100,213 @@ class GeneralAppointmentWidget extends StatelessWidget { @override Widget build(BuildContext context) { - return Row( - mainAxisAlignment: MainAxisAlignment.start, + return Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - if (isSelectable) - SizedBox( - child: const SizedBox( - width: 14, - height: 14, - ).toContainer( - borderRadius: 24, - marginAll: 4, - paddingAll: 0, - backgroundColor: (appointmentListModel.isSelected ?? false) ? MyColors.primaryColor : MyColors.greyButtonColor, - ), - ).toContainer( - borderRadius: 24, - isEnabledBorder: true, - paddingAll: 0, - borderWidget: 3, - borderColor: MyColors.primaryColor, - ), - if (isSelectable) 12.width, - Expanded( - child: Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - if (isNeedToShowMergeStatus) - LocaleKeys.merged.tr().toText(color: MyColors.white).toContainer( - padding: const EdgeInsets.symmetric(horizontal: 6, vertical: 3), - borderRadius: 12, - backgroundColor: MyColors.greenColor, - ), - Row( - mainAxisAlignment: MainAxisAlignment.start, + Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + if (isSelectable) + SizedBox( + child: const SizedBox( + width: 14, + height: 14, + ).toContainer( + borderRadius: 24, + marginAll: 4, + paddingAll: 0, + backgroundColor: (appointmentListModel.isSelected ?? false) ? MyColors.primaryColor : MyColors.greyButtonColor, + ), + ).toContainer( + borderRadius: 24, + isEnabledBorder: true, + paddingAll: 0, + borderWidget: 3, + borderColor: MyColors.primaryColor, + ), + if (isSelectable) 12.width, + Expanded( + child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Expanded( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisAlignment: MainAxisAlignment.start, - children: [ - (appointmentListModel.branchName ?? "").toText( - fontSize: 12, - color: MyColors.darkTextColor, - isBold: true, + if (isNeedToShowMergeStatus) + LocaleKeys.merged.tr().toText(color: MyColors.white).toContainer( + padding: const EdgeInsets.symmetric(horizontal: 6, vertical: 3), + borderRadius: 12, + backgroundColor: MyColors.greenColor, ), - (appointmentListModel.customerName ?? "").toText(color: MyColors.black, isBold: true, fontSize: 16), - Row( + Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, children: [ - "${LocaleKeys.phone.tr()}:".toText( - color: MyColors.lightTextColor, + (appointmentListModel.branchName ?? "").toText( + fontSize: 12, + color: MyColors.darkTextColor, + isBold: true, ), - 2.width, - appointmentListModel.customerMobileNum.toString().toText( - fontSize: 12, + (appointmentListModel.customerName ?? "").toText(color: MyColors.black, isBold: true, fontSize: 16), + Row( + children: [ + "${LocaleKeys.phone.tr()}:".toText( + color: MyColors.lightTextColor, + ), + 2.width, + Expanded( + child: appointmentListModel.customerMobileNum.toString().toText( + fontSize: 12, + ), ), + ], + ), + Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + "${LocaleKeys.time.tr()}:".toText( + color: MyColors.lightTextColor, + ), + 4.width, + Expanded(child: (appointmentListModel.duration ?? "").toText(fontSize: 8)) + ], + ), + + Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + "${LocaleKeys.date.tr()}:".toText( + color: MyColors.lightTextColor, + ), + 4.width, + Expanded(child: appointmentListModel.appointmentDate!.toFormattedDateWithoutTime().toText(fontSize: 8)) + ], + ), + Row( + children: [ + "${LocaleKeys.delivery.tr()}: ".toText(color: MyColors.lightTextColor), + 2.width, + Expanded( + child: (appointmentListModel.appointmentTypeEnum == AppointmentTypeEnum.home ? LocaleKeys.home.tr() : LocaleKeys.workshop.tr()).toText( + fontSize: 12, + ), + ), + ], + ), + Row( + children: [ + "${LocaleKeys.createdOn.tr()}: ".toText(color: MyColors.lightTextColor), + 2.width, + Expanded(child: appointmentListModel.appointmentCreatedOn!.toFormattedDateWithoutTime().toText(fontSize: 8)) + ], + ), + if (isFromUpdateAppointmentPage) ...[ + if (appointmentListModel.appointmentAddress != null && appointmentListModel.appointmentAddress!.isNotEmpty) ...[ + Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + "${LocaleKeys.address.tr()}: ".toText(color: MyColors.lightTextColor), + 2.width, + Expanded(child: (appointmentListModel.appointmentAddress ?? "").toText(fontSize: 8)) + ], + ), + ], + Row( + children: [ + "${LocaleKeys.paymentType.tr()}: ".toText(color: MyColors.lightTextColor), + 2.width, + Expanded(child: (appointmentListModel.paymentType ?? "").toText(fontSize: 8)), + ], + ), + LocaleKeys.openMapLocation + .tr() + .toText( + isUnderLine: true, + color: MyColors.darkPrimaryColor, + fontSize: 10, + ) + .onPress(() async { + double latitude, longitude = 0.0; + latitude = double.parse(appointmentListModel.appointmentLatitude!); + longitude = double.parse(appointmentListModel.appointmentLongitude!); + await Utils.openLocationInMaps(latitude: latitude, longitude: longitude); + }), + ] ], ), - Row( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - "${LocaleKeys.time.tr()}:".toText( + ), + if (!isNeedTotalPayment) + if (appointmentListModel.customerAppointmentList != null && appointmentListModel.customerAppointmentList!.length > 1) + "${appointmentListModel.customerAppointmentList!.length - 1}+ appts".toText(fontSize: 8).toContainer( + borderRadius: 15, + backgroundColor: MyColors.lightGreyEAColor, + padding: const EdgeInsets.symmetric( + vertical: 4, + horizontal: 8, + ), + ), + if (isNeedToShowAppointmentStatus) + (appointmentListModel.appointmentStatusEnum!.getAppointmentNameFromEnum()).toText(color: MyColors.white).toContainer( + padding: const EdgeInsets.symmetric(horizontal: 6, vertical: 3), + borderRadius: 12, + backgroundColor: MyColors.primaryColor, + ), + ], + ), + ], + ), + ), + ], + ), + 8.height, + Row( + crossAxisAlignment: CrossAxisAlignment.end, + children: [ + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + ...buildServicesFromAppointment(appointmentListModel: appointmentListModel), + if (isNeedTotalPayment) + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + 18.height, + LocaleKeys.totalAmount.tr().toText( + fontSize: 12, color: MyColors.lightTextColor, ), - 4.width, - Flexible(child: (appointmentListModel.duration ?? "").toText(fontSize: 8)) - ], - ), Row( mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.end, children: [ - "${LocaleKeys.date.tr()}:".toText( - color: MyColors.lightTextColor, - ), - 4.width, - Flexible(child: appointmentListModel.appointmentDate!.toFormattedDateWithoutTime().toText(fontSize: 8)) + appointmentListModel.totalAmount.toString().toText(fontSize: 16, isBold: true), + 2.width, + LocaleKeys.sar.tr().toText(color: MyColors.lightTextColor), ], ), - Row( - children: [ - "${LocaleKeys.serviceDeliveryType.tr()}: ".toText(color: MyColors.lightTextColor), - 2.width, - (appointmentListModel.appointmentTypeEnum == AppointmentTypeEnum.home ? LocaleKeys.home.tr() : LocaleKeys.workshop.tr()).toText( + 2.height, + LocaleKeys.remainingAmount.tr().toText( fontSize: 12, + color: MyColors.lightTextColor, ), - ], - ), Row( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.end, children: [ - "${LocaleKeys.createdOn.tr()}: ".toText(color: MyColors.lightTextColor), + appointmentListModel.remainingAmount.toString().toText(fontSize: 16, isBold: true), 2.width, - Flexible(child: appointmentListModel.appointmentCreatedOn!.toFormattedDateWithoutTime().toText(fontSize: 8)) - ], - ), - if (isFromUpdateAppointmentPage) ...[ - if (appointmentListModel.appointmentAddress != null && appointmentListModel.appointmentAddress!.isNotEmpty) ...[ - Row( - children: [ - "${LocaleKeys.address.tr()}: ".toText(color: MyColors.lightTextColor), - 2.width, - Flexible(child: (appointmentListModel.appointmentAddress ?? "").toText(fontSize: 8)) - ], - ), + LocaleKeys.sar.tr().toText(color: MyColors.lightTextColor), ], - Row( - children: [ - "${LocaleKeys.paymentType.tr()}: ".toText(color: MyColors.lightTextColor), - 2.width, - (appointmentListModel.paymentType ?? "").toText(fontSize: 8), - ], - ), - LocaleKeys.openMapLocation - .tr() - .toText( - isUnderLine: true, - color: MyColors.darkPrimaryColor, - fontSize: 10, - ) - .onPress(() async { - double latitude, longitude = 0.0; - latitude = double.parse(appointmentListModel.appointmentLatitude!); - longitude = double.parse(appointmentListModel.appointmentLongitude!); - await Utils.openLocationInMaps(latitude: latitude, longitude: longitude); - }), - ] - ], - ), - ), - if (!isNeedTotalPayment) - if (appointmentListModel.customerAppointmentList != null && appointmentListModel.customerAppointmentList!.length > 1) - "${appointmentListModel.customerAppointmentList!.length - 1}+ Appointments".toText(fontSize: 8).toContainer( - borderRadius: 15, - backgroundColor: MyColors.lightGreyEAColor, - padding: const EdgeInsets.symmetric( - vertical: 6, - horizontal: 12, - ), - ), - if (isNeedToShowAppointmentStatus) - (appointmentListModel.appointmentStatusEnum!.getAppointmentNameFromEnum()).toText(color: MyColors.white).toContainer( - padding: const EdgeInsets.symmetric(horizontal: 6, vertical: 3), - borderRadius: 12, - backgroundColor: MyColors.primaryColor, ), - ], - ), - 8.height, - Row( - crossAxisAlignment: CrossAxisAlignment.end, - children: [ - Expanded( - child: Column( - children: [ - ...buildServicesFromAppointment(appointmentListModel: appointmentListModel), - if (isNeedTotalPayment) - Column( - children: [ - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - 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, - LocaleKeys.sar.tr().toText(color: MyColors.lightTextColor), - ], - ), - ], - ), - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - 2.height, - 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, - LocaleKeys.sar.tr().toText(color: MyColors.lightTextColor), - ], - ), - ], - ), - ], - ) ], - ), - ), - if (!isNeedToShowItems) const Icon(Icons.arrow_forward), + ) ], ), - ], - ), - ) + ), + if (!isNeedToShowItems) const Icon(Icons.arrow_forward), + ], + ), ], ).toWhiteContainer(width: double.infinity, allPading: 12, onTap: onTap); } @@ -361,3 +358,94 @@ class GeneralAppointmentWidget extends StatelessWidget { ); } } + + + + +// https://ms.hmg.com/api/ServiceProviders/ServiceProviderBranchDetail_Get?ID=1061&ServiceCategoryIDs=4 + + // {ID: 1061, ServiceCategoryIDs: [4]} + // { +// "messageStatus": 1, +// "totalItemsCount": 1, +// "data": [ +// { +// "id": 1061, +// "serviceProviderID": 14, +// "serviceProviderName": "James Bond", +// "branchName": "Sawaidi Branch", +// "branchDescription": "This is Swaidi Branch", +// "cityID": 1, +// "cityName": "Riyadh", +// "address": "Riyadh, KSA", +// "latitude": "37.541014800226456", +// "longitude": "-122.36278831958771", +// "distanceKM": 12811.22, +// "openTime": "12:00", +// "closeTime": "22:45", +// "branchStatus": 3, +// "branchStatusText": "ApprovedOrActive", +// "branchRateAvg": 0.0, +// "serviceProviderServices": [ +// { +// "serviceProviderServiceID": 1212, +// "providerServiceDescription": null, +// "categoryID": 4, +// "categoryName": "Care and Protection", +// "serviceID": 16, +// "serviceDescription": "film body protection", +// "serviceDescriptionN": "فلم حماية الدهان", +// "serviceStatus": 1, +// "statusText": null, +// "isAllowAppointment": true, +// "isAllowAppointmentHome": true, +// "customerLocationRange": 10, +// "rangePricePerKm": 15.0, +// "itemsCount": 1 +// } +// ], +// "serviceProviderBranchImage": [ +// { +// "id": 136, +// "imageName": "image_picker_929CDE1A-800C-4EFE-AC48-7060BB338D77-69034-00003ADB833C597D.jpg", +// "imageUrl": "https://ms.hmg.com/api/serviceProviders/ServiceProviderBranchImage?imageName=61aa8beb-99b0-4876-b47a-08dce8674a2c_50243415.png&sp=Provider_14&serviceProviderBranch=ServiceProviderBranch_1061", +// "imageStr": null, +// "serviceProviderBranchID": 1061, +// "serviceProviderBranch": null, +// "isActive": true, +// "createdBy": 101, +// "createdOn": "2024-12-16T14:47:48.6633333", +// "modifiedBy": null, +// "modifiedOn": null +// }, +// { +// "id": 137, +// "imageName": "image_picker_EBF6BA32-3E4E-4AAE-BC2C-1B136A1C32B3-69034-00003ADB7C82E00F.jpg", +// "imageUrl": "https://ms.hmg.com/api/serviceProviders/ServiceProviderBranchImage?imageName=61aa8beb-99b0-4876-b47a-08dce8674a2c_51856527.png&sp=Provider_14&serviceProviderBranch=ServiceProviderBranch_1061", +// "imageStr": null, +// "serviceProviderBranchID": 1061, +// "serviceProviderBranch": null, +// "isActive": true, +// "createdBy": 101, +// "createdOn": "2024-12-16T14:47:48.6866667", +// "modifiedBy": null, +// "modifiedOn": null +// }, +// { +// "id": 138, +// "imageName": "image_picker_168879D6-4707-4D0E-ACDA-0C956BD2AC4A-69034-00003AE6922D39CF.jpg", +// "imageUrl": "https://ms.hmg.com/api/serviceProviders/ServiceProviderBranchImage?imageName=61aa8beb-99b0-4876-b47a-08dce8674a2c_61115226.png&sp=Provider_14&serviceProviderBranch=ServiceProviderBranch_1061", +// "imageStr": null, +// "serviceProviderBranchID": 1061, +// "serviceProviderBranch": null, +// "isActive": true, +// "createdBy": 101, +// "createdOn": "2024-12-16T14:47:48.7066667", +// "modifiedBy": null, +// "modifiedOn": null +// } +// ] +// } +// ], +// "message": "Success" +// } diff --git a/lib/views/subscriptions/all_subscriptions_page.dart b/lib/views/subscriptions/all_subscriptions_page.dart index 38cef93..359bdb9 100644 --- a/lib/views/subscriptions/all_subscriptions_page.dart +++ b/lib/views/subscriptions/all_subscriptions_page.dart @@ -74,7 +74,7 @@ class _SubscriptionsPageState extends State { subcriptionsVM.tempSubscriptions[index], isSubscribed: subcriptionsVM.tempSubscriptions[index].isSubscribed ?? false, onRenewSubscriptionClick: () async { - GenericRespModel response = await subcriptionsVM.createSubscriptionOrder(subcriptionsVM.tempSubscriptions[index].id ?? 0, true, true); + GenericRespModel response = await subcriptionsVM.createSubscriptionOrder(subscriptionId: subcriptionsVM.tempSubscriptions[index].id ?? 0, isStartNow: true, isRenew: true); if (response.data != null) { context.read().updateOrderProviderSubscriptionId(id: response.data ?? 0); navigateWithName(context, AppRoutes.paymentMethodsView, arguments: PaymentTypes.subscription); diff --git a/lib/views/subscriptions/sheet/downgrade_data_sheet.dart b/lib/views/subscriptions/sheet/downgrade_data_sheet.dart index 59751d9..565986b 100644 --- a/lib/views/subscriptions/sheet/downgrade_data_sheet.dart +++ b/lib/views/subscriptions/sheet/downgrade_data_sheet.dart @@ -1,4 +1,3 @@ - import 'package:flutter/material.dart'; import 'package:mc_common_app/classes/app_state.dart'; import 'package:mc_common_app/extensions/int_extensions.dart'; @@ -50,7 +49,8 @@ class _DowngradeDataSheetState extends State { isBold: true, ), 8.height, - "To select this subscription you need to deactivate your branches and users as this package only supports 1 branch and 2 users per branch. You can reactivate these branches later after upgrading the package".toText( + "To select this subscription you need to deactivate your branches and users as this package only supports 1 branch and 2 users per branch. You can reactivate these branches later after upgrading the package" + .toText( fontSize: 14, color: MyColors.textColor, ), @@ -102,10 +102,10 @@ class _DowngradeDataSheetState extends State { onTempContinue: () async { Utils.showLoading(context); GenericRespModel response = await model.payForSubscription( - widget.subscription.id!, - true, - false, - widget.subscription.price.toString(), + subscriptionId: widget.subscription.id!, + isStartNow: true, + isRenew: false, + amount: widget.subscription.price.toString(), isDegrade: true, listOfBranches: listOfBranches, listOfUsers: listOfUsers, diff --git a/lib/views/subscriptions/sheet/upgrade_package_sheet.dart b/lib/views/subscriptions/sheet/upgrade_package_sheet.dart index 0d49976..5a1602f 100644 --- a/lib/views/subscriptions/sheet/upgrade_package_sheet.dart +++ b/lib/views/subscriptions/sheet/upgrade_package_sheet.dart @@ -81,7 +81,7 @@ class _UpgradePackageSheetState extends State { packageItem( LocaleKeys.nowVar.tr(), ("${LocaleKeys.yourSubscriptionUpgradeAffectingFrom.tr()} ${widget.subscription.dateEnd == null ? DateFormat('d MMMM yyyy', context.locale.toString()).format(DateTime.now()) : DateFormat('d MMMM yyyy', context.locale.toString()).format(DateHelper.parseStringToDate(DateHelper.formatDateT(widget.subscription.dateEnd!)))}"), - // ("${LocaleKeys.yourSubscriptionUpgradeAffectingFrom.tr()} ${widget.subscription.dateEnd == null ? DateHelper.formatAsDayMonthYear(DateTime.now()) : DateHelper.formatAsDayMonthYear(DateHelper.parseStringToDate(DateHelper.formatDateT(widget.subscription.dateEnd!)))}"), + // ("${LocaleKeys.yourSubscriptionUpgradeAffectingFrom.tr()} ${widget.subscription.dateEnd == null ? DateHelper.formatAsDayMonthYear(DateTime.now()) : DateHelper.formatAsDayMonthYear(DateHelper.parseStringToDate(DateHelper.formatDateT(widget.subscription.dateEnd!)))}"), double.parse(model.newPrice).toStringAsFixed(2), isNowSelected, ).onPress(() { @@ -95,7 +95,7 @@ class _UpgradePackageSheetState extends State { packageItem( LocaleKeys.upgradeAfterCurrentExpiry.tr(), ("${LocaleKeys.yourSubscriptionUpgradeCurrentSubscriptionAffectingFrom.tr()} ${AppState().getproviderSubscription.first.dateEnd == null ? "" : AppState().getproviderSubscription.first.dateEnd == null ? DateFormat('d MMMM yyyy', context.locale.toString()).format(DateTime.now()) : DateFormat('d MMMM yyyy', context.locale.toString()).format(DateHelper.parseStringToDate(DateHelper.formatDateT(AppState().getproviderSubscription.first.dateEnd!)))}"), - // ("${LocaleKeys.yourSubscriptionUpgradeCurrentSubscriptionAffectingFrom.tr()} ${AppState().getproviderSubscription.first.dateEnd == null ? "" : AppState().getproviderSubscription.first.dateEnd == null ? DateHelper.formatAsDayMonthYear(DateTime.now()) : DateHelper.formatAsDayMonthYear(DateHelper.parseStringToDate(DateHelper.formatDateT(AppState().getproviderSubscription.first.dateEnd!)))}"), + // ("${LocaleKeys.yourSubscriptionUpgradeCurrentSubscriptionAffectingFrom.tr()} ${AppState().getproviderSubscription.first.dateEnd == null ? "" : AppState().getproviderSubscription.first.dateEnd == null ? DateHelper.formatAsDayMonthYear(DateTime.now()) : DateHelper.formatAsDayMonthYear(DateHelper.parseStringToDate(DateHelper.formatDateT(AppState().getproviderSubscription.first.dateEnd!)))}"), widget.subscription.price.toString(), isNowSelected ? false : true, ).onPress(() { @@ -112,7 +112,7 @@ class _UpgradePackageSheetState extends State { onPressed: () async { if (widget.isRenew) { Utils.showLoading(context); - GenericRespModel response = await model.createSubscriptionOrder(widget.subscription.id ?? 0, true, true); + GenericRespModel response = await model.createSubscriptionOrder(subscriptionId: widget.subscription.id ?? 0, isStartNow: true, isRenew: true); Utils.hideLoading(context); if (response.data != null) { context.read().updateOrderProviderSubscriptionId(id: response.data ?? 0); @@ -125,7 +125,7 @@ class _UpgradePackageSheetState extends State { paymentType: PaymentTypes.subscription, onTempContinue: () async { Utils.showLoading(context); - GenericRespModel mResponse = await model.payForSubscription(widget.subscription.id!, isNowSelected, false, price); + GenericRespModel mResponse = await model.payForSubscription(subscriptionId: widget.subscription.id!, isStartNow: isNowSelected, isRenew: false, amount: price); Utils.hideLoading(context); if (mResponse.messageStatus == 1) { context.read().updateOrderProviderSubscriptionId(id: mResponse.data); @@ -209,3 +209,5 @@ class _UpgradePackageSheetState extends State { ); } } + +