From c1b01c156561a2ef606c6bbd1aa2148b8e90d38e Mon Sep 17 00:00:00 2001 From: Aamir Date: Thu, 24 Oct 2024 14:39:09 +0300 Subject: [PATCH 1/3] changes --- lib/classes/app_state.dart | 2 +- .../subscription_model.dart | 4 + lib/services/common_auth_service.dart | 15 +- lib/services/payments_service.dart | 50 ++-- lib/utils/enums.dart | 6 +- lib/view_models/payment_view_model.dart | 3 +- lib/view_models/service_view_model.dart | 3 +- .../setting_options_language.dart | 252 +++++++++--------- lib/views/user/login_with_password_page.dart | 37 +-- pubspec.yaml | 30 +-- 10 files changed, 213 insertions(+), 189 deletions(-) diff --git a/lib/classes/app_state.dart b/lib/classes/app_state.dart index d8e4dce..ee491de 100644 --- a/lib/classes/app_state.dart +++ b/lib/classes/app_state.dart @@ -65,7 +65,7 @@ class AppState { List? _providerSubscription; - List get getproviderSubscription => _providerSubscription!; + List get getproviderSubscription => _providerSubscription ?? [new Subscription(name: "")]; set setproviderSubscription(List value) { _providerSubscription = value; diff --git a/lib/models/subscriptions_models/subscription_model.dart b/lib/models/subscriptions_models/subscription_model.dart index fc77955..9697266 100644 --- a/lib/models/subscriptions_models/subscription_model.dart +++ b/lib/models/subscriptions_models/subscription_model.dart @@ -69,6 +69,7 @@ class Subscription { this.totalAds, this.branchesRemaining, this.subUsersRemaining, + this.subscriptionType, this.adsRemaining}); int? id; @@ -90,6 +91,7 @@ class Subscription { SubscriptionTypeEnum? subscriptionTypeEnum; bool? isMyCurrentPackage; bool? isRenewable; + int? subscriptionType; int? subscriptionBranches; int? subscriptionSubUsers; @@ -130,6 +132,7 @@ class Subscription { branchesRemaining: json["branchesRemaining"], subUsersRemaining: json["subUsersRemaining"], adsRemaining: json["adsRemaining"], + subscriptionType: json["subscriptionType"], ); Map toJson() => { @@ -159,5 +162,6 @@ class Subscription { "branchesRemaining": branchesRemaining, "subUsersRemaining": subUsersRemaining, "adsRemaining": adsRemaining, + "subscriptionType": subscriptionType, }; } diff --git a/lib/services/common_auth_service.dart b/lib/services/common_auth_service.dart index 1f52e02..c1b5969 100644 --- a/lib/services/common_auth_service.dart +++ b/lib/services/common_auth_service.dart @@ -2,7 +2,6 @@ import 'dart:io'; import 'package:device_info_plus/device_info_plus.dart'; import 'package:flutter/services.dart'; -import 'package:huawei_fido/huawei_fido.dart'; import 'package:local_auth/local_auth.dart'; import 'package:local_auth_android/local_auth_android.dart'; import 'package:local_auth_darwin/types/auth_messages_ios.dart'; @@ -61,11 +60,11 @@ class CommonAuthImp implements CommonAuthServices { return await localAuth.getAvailableBiometrics(); } - Future getHuaweiAuth() async { - DeviceInfoPlugin deviceInfo = DeviceInfoPlugin(); - AndroidDeviceInfo androidInfo = await deviceInfo.androidInfo; - // if (androidInfo.brand == "HUAWEI") { - // huawei.canAuth(); - // } - } +// Future getHuaweiAuth() async { +// DeviceInfoPlugin deviceInfo = DeviceInfoPlugin(); +// AndroidDeviceInfo androidInfo = await deviceInfo.androidInfo; +// // if (androidInfo.brand == "HUAWEI") { +// // huawei.canAuth(); +// // } +// } } diff --git a/lib/services/payments_service.dart b/lib/services/payments_service.dart index aed50b8..51df85a 100644 --- a/lib/services/payments_service.dart +++ b/lib/services/payments_service.dart @@ -26,13 +26,25 @@ abstract class PaymentService { class PaymentServiceImp implements PaymentService { MyInAppBrowser? myInAppBrowser; - var inAppBrowserOptions = InAppBrowserClassOptions( - inAppWebViewGroupOptions: - InAppWebViewGroupOptions(crossPlatform: InAppWebViewOptions(useShouldOverrideUrlLoading: true, transparentBackground: false), ios: IOSInAppWebViewOptions(applePayAPIEnabled: true)), - crossPlatform: InAppBrowserOptions(hideUrlBar: true, toolbarTopBackgroundColor: Colors.black), - android: AndroidInAppBrowserOptions(), - ios: - IOSInAppBrowserOptions(hideToolbarBottom: true, toolbarBottomBackgroundColor: Colors.white, closeButtonColor: Colors.white, presentationStyle: IOSUIModalPresentationStyle.OVER_FULL_SCREEN)); + + var inAppBrowserOptions = InAppBrowserClassSettings( + webViewSettings: InAppWebViewSettings( + useShouldOverrideUrlLoading: false, + transparentBackground: false, + isInspectable: false, + applePayAPIEnabled: true, + cacheEnabled: false, + ), + browserSettings: InAppBrowserSettings( + hideUrlBar: true, + hideTitleBar: true, + hideDefaultMenuItems: false, + toolbarBottomBackgroundColor: Colors.black, + closeButtonColor: Colors.white, + presentationStyle: ModalPresentationStyle.OVER_FULL_SCREEN, + // toolbarTopBackgroundColor: Colors.black + ), + ); @override Future placePayment({ @@ -75,15 +87,23 @@ class PaymentServiceImp implements PaymentService { break; } log("PaymentUrl: $urlRequest"); - myInAppBrowser = MyInAppBrowser(onExitCallback: () { - log("Browser Exited"); - }, onLoadStartCallback: (String url) { - log("Browser LoadStart for : $url"); - onBrowserLoadStart(onFailure: onFailure, onSuccess: onSuccess, url: url); - }); + myInAppBrowser = MyInAppBrowser( + onExitCallback: () { + log("Browser Exited"); + }, + onLoadStartCallback: (String url) { + log("Browser LoadStart for : $url"); + onBrowserLoadStart(onFailure: onFailure, onSuccess: onSuccess, url: url); + }, + ); await myInAppBrowser!.openUrlRequest( - urlRequest: URLRequest(url: Uri.parse(urlRequest)), - options: inAppBrowserOptions, + urlRequest: URLRequest( + url: WebUri('${Uri.parse(urlRequest)}', forceToStringRawValue: true), + allowsCellularAccess: true, + allowsConstrainedNetworkAccess: true, + allowsExpensiveNetworkAccess: true, + ), + settings: inAppBrowserOptions, ); } diff --git a/lib/utils/enums.dart b/lib/utils/enums.dart index b214b10..980ae1b 100644 --- a/lib/utils/enums.dart +++ b/lib/utils/enums.dart @@ -187,9 +187,9 @@ enum ChatTypeEnum { } enum SubscriptionTypeEnum { - current, - upgrade, - downgrade, + current, //1 + upgrade, //2 + downgrade, //3 } enum SubscriptionActionTypeEnum { diff --git a/lib/view_models/payment_view_model.dart b/lib/view_models/payment_view_model.dart index 89fba48..af993fd 100644 --- a/lib/view_models/payment_view_model.dart +++ b/lib/view_models/payment_view_model.dart @@ -213,9 +213,8 @@ class PaymentVM extends ChangeNotifier { onSubscriptionPaymentSuccess(BuildContext context) { pop(context); - // context.read().getMySubscriptions(AppState().getUser.data?.userInfo?.providerId.toString() ?? ""); - context.read().getSubscriptionBySP(AppState().getUser.data?.userInfo?.providerId.toString() ?? "", true); + // context.read().getSubscriptionBySP(AppState().getUser.data?.userInfo?.providerId.toString() ?? "", true); // context.read().mySubscriptionsBySp = []; // context.read().getMySubscriptionsBySP(); navigateReplaceWithNameUntilRoute(context, AppRoutes.dashboard); diff --git a/lib/view_models/service_view_model.dart b/lib/view_models/service_view_model.dart index a7e9715..11ba597 100644 --- a/lib/view_models/service_view_model.dart +++ b/lib/view_models/service_view_model.dart @@ -272,7 +272,8 @@ class ServiceVM extends BaseVM { Future getBranchAndServices() async { setState(ViewState.busy); branches = await branchRepo.getBranchAndServices(); - homePageBranches = branches!.data!.serviceProviderBranch!.where((element) => element.branchStatus == BranchStatusEnum.approvedOrActive).toList(); + if (branches!.data != null) + homePageBranches = branches!.data!.serviceProviderBranch!.where((element) => element.branchStatus == BranchStatusEnum.approvedOrActive).toList(); setState(ViewState.idle); } diff --git a/lib/views/setting_options/setting_options_language.dart b/lib/views/setting_options/setting_options_language.dart index d58628a..34f9053 100644 --- a/lib/views/setting_options/setting_options_language.dart +++ b/lib/views/setting_options/setting_options_language.dart @@ -40,141 +40,141 @@ class _SettingOptionsLanguageState extends State { // ? Expanded( child: ListView( - shrinkWrap: true, - padding: EdgeInsets.zero, - children: [ - Column( + shrinkWrap: true, + padding: EdgeInsets.zero, children: [ - CustomSettingOptionsTile( - leadingWidget: const Icon(Icons.quickreply_outlined, size: 20), - titleText: LocaleKeys.requests.tr(), - needBorderBelow: true, - onTap: () { - context.read().onNavbarTapped(4); - Navigator.pop(context); - }), - if (AppState().currentAppType == AppType.customer) ...[ - CustomSettingOptionsTile( - leadingWidget: const Icon(Icons.favorite, size: 20), - titleText: LocaleKeys.favoriteList.tr(), - needBorderBelow: true, - onTap: () => navigateWithName(context, AppRoutes.favoriteListView), - ), - ], - CustomSettingOptionsTile( - leadingWidget: const Icon(Icons.settings, size: 20), - titleText: LocaleKeys.settings.tr(), - needBorderBelow: true, - onTap: () {}, - //navigateWithName(context, AppRoutes.settingOptionsInviteFriends), - ), - CustomSettingOptionsTile( - leadingWidget: const Icon(Icons.question_mark_outlined, size: 20), - titleText: LocaleKeys.help.tr(), - needBorderBelow: true, - onTap: () => navigateWithName(context, AppRoutes.settingOptionsHelp), - ), - CustomSettingOptionsTile( - leadingWidget: const Icon(Icons.person, size: 20), - titleText: LocaleKeys.account.tr(), - needBorderBelow: false, - onTap: () { - navigateWithName(context, AppRoutes.profileView); - // context.read().onNavbarTapped(4); - // Navigator.pop(context); - }), - ], - ).toWhiteContainer(width: double.infinity, pading: const EdgeInsets.all(12), borderRadius: 0), - 10.height, - CustomSettingOptionsTile( - leadingWidget: const Icon(Icons.translate, size: 20), - titleText: LocaleKeys.language.tr(), - isForLanguage: true, - onTap: () { - context.read().changeLanguage(context); - Future.delayed(Duration(seconds: 1), () { - setState(() {}); - }); - }, - ).toWhiteContainer(width: double.infinity, pading: const EdgeInsets.all(12), borderRadius: 0), - 10.height, - (AppState().currentAppType == AppType.provider) - ? Column( - children: [ - CustomSettingOptionsTile( - leadingWidget: SizedBox( - width: 16, - height: 16, - child: SvgPicture.asset( - MyAssets.icStar, - color: MyColors.primaryColor, - ), - ), - titleText: LocaleKeys.mySubscription.tr(), - subTitle: AppState().getproviderSubscription.first.name ?? "Silver", - isForLanguage: false, + Column( + children: [ + CustomSettingOptionsTile( + leadingWidget: const Icon(Icons.quickreply_outlined, size: 20), + titleText: LocaleKeys.requests.tr(), needBorderBelow: true, onTap: () { - navigateWithName(context, AppRoutes.mySubscriptionsPage); - }, - ), + context.read().onNavbarTapped(4); + Navigator.pop(context); + }), + if (AppState().currentAppType == AppType.customer) ...[ CustomSettingOptionsTile( - leadingWidget: SizedBox( - width: 16, - height: 16, - child: SvgPicture.asset( - MyAssets.icGroupStar, - // color: MyColors.primaryColor, - ), - ), - titleText: LocaleKeys.subscriptions.tr(), - subTitle: null, - isForLanguage: false, + leadingWidget: const Icon(Icons.favorite, size: 20), + titleText: LocaleKeys.favoriteList.tr(), needBorderBelow: true, - onTap: () { - navigateWithName(context, AppRoutes.subscriptionsPage); - }, + onTap: () => navigateWithName(context, AppRoutes.favoriteListView), ), - CustomSettingOptionsTile( - leadingWidget: SizedBox( - width: 16, - height: 16, - child: SvgPicture.asset( - MyAssets.icGroupStar, - // color: MyColors.primaryColor, - ), - ), - titleText: LocaleKeys.defineLicenses.tr(), - subTitle: null, - isForLanguage: false, + ], + CustomSettingOptionsTile( + leadingWidget: const Icon(Icons.settings, size: 20), + titleText: LocaleKeys.settings.tr(), + needBorderBelow: true, + onTap: () {}, + //navigateWithName(context, AppRoutes.settingOptionsInviteFriends), + ), + CustomSettingOptionsTile( + leadingWidget: const Icon(Icons.question_mark_outlined, size: 20), + titleText: LocaleKeys.help.tr(), + needBorderBelow: true, + onTap: () => navigateWithName(context, AppRoutes.settingOptionsHelp), + ), + CustomSettingOptionsTile( + leadingWidget: const Icon(Icons.person, size: 20), + titleText: LocaleKeys.account.tr(), needBorderBelow: false, onTap: () { - navigateWithName(context, AppRoutes.providerLicensePage); - }, + navigateWithName(context, AppRoutes.profileView); + // context.read().onNavbarTapped(4); + // Navigator.pop(context); + }), + ], + ).toWhiteContainer(width: double.infinity, pading: const EdgeInsets.all(12), borderRadius: 0), + 10.height, + CustomSettingOptionsTile( + leadingWidget: const Icon(Icons.translate, size: 20), + titleText: LocaleKeys.language.tr(), + isForLanguage: true, + onTap: () { + context.read().changeLanguage(context); + Future.delayed(Duration(seconds: 1), () { + setState(() {}); + }); + }, + ).toWhiteContainer(width: double.infinity, pading: const EdgeInsets.all(12), borderRadius: 0), + 10.height, + (AppState().currentAppType == AppType.provider) + ? Column( + children: [ + CustomSettingOptionsTile( + leadingWidget: SizedBox( + width: 16, + height: 16, + child: SvgPicture.asset( + MyAssets.icStar, + color: MyColors.primaryColor, + ), ), - // CustomSettingOptionsTile( - // leadingWidget: SizedBox( - // width: 16, - // height: 16, - // child: SvgPicture.asset( - // MyAssets.providersIcon, - // // color: MyColors.primaryColor, - // ), - // ), - // titleText: "Users", - // subTitle: null, - // isForLanguage: false, - // needBorderBelow: false, - // onTap: () { - // navigateWithName(context, AppRoutes.dealerUser, arguments: AppState().getUser.data!.userInfo!.id.toString()); - // }, - // ) - ], - ).toWhiteContainer(width: double.infinity, pading: const EdgeInsets.all(12), borderRadius: 0) - : const SizedBox(), - (AppState().currentAppType == AppType.provider) ? 10.height : const SizedBox(), - ], - )), + titleText: LocaleKeys.mySubscription.tr(), + subTitle: AppState().getproviderSubscription.first.name, + isForLanguage: false, + needBorderBelow: true, + onTap: () { + navigateWithName(context, AppRoutes.mySubscriptionsPage); + }, + ), + CustomSettingOptionsTile( + leadingWidget: SizedBox( + width: 16, + height: 16, + child: SvgPicture.asset( + MyAssets.icGroupStar, + // color: MyColors.primaryColor, + ), + ), + titleText: LocaleKeys.subscriptions.tr(), + subTitle: null, + isForLanguage: false, + needBorderBelow: true, + onTap: () { + navigateWithName(context, AppRoutes.subscriptionsPage); + }, + ), + CustomSettingOptionsTile( + leadingWidget: SizedBox( + width: 16, + height: 16, + child: SvgPicture.asset( + MyAssets.icGroupStar, + // color: MyColors.primaryColor, + ), + ), + titleText: LocaleKeys.defineLicenses.tr(), + subTitle: null, + isForLanguage: false, + needBorderBelow: false, + onTap: () { + navigateWithName(context, AppRoutes.providerLicensePage); + }, + ), + // CustomSettingOptionsTile( + // leadingWidget: SizedBox( + // width: 16, + // height: 16, + // child: SvgPicture.asset( + // MyAssets.providersIcon, + // // color: MyColors.primaryColor, + // ), + // ), + // titleText: "Users", + // subTitle: null, + // isForLanguage: false, + // needBorderBelow: false, + // onTap: () { + // navigateWithName(context, AppRoutes.dealerUser, arguments: AppState().getUser.data!.userInfo!.id.toString()); + // }, + // ) + ], + ).toWhiteContainer(width: double.infinity, pading: const EdgeInsets.all(12), borderRadius: 0) + : const SizedBox(), + (AppState().currentAppType == AppType.provider) ? 10.height : const SizedBox(), + ], + )), // : Expanded( // child: ListView( // children: [ diff --git a/lib/views/user/login_with_password_page.dart b/lib/views/user/login_with_password_page.dart index 4f25a70..094ba2d 100644 --- a/lib/views/user/login_with_password_page.dart +++ b/lib/views/user/login_with_password_page.dart @@ -34,7 +34,8 @@ class _LoginWithPasswordState extends State { //TODO: ONLY FOR DEVELOPMENT PURPOSE // String phoneNum = "966504278212", password = "Fa@1234"; - String phoneNum = "966504278213", password = "Fa@1234"; + // String phoneNum = "966504278213", password = "Fa@1234"; + String phoneNum = "", password = ""; // String phoneNum = "", password = ""; String email = ""; @@ -51,23 +52,23 @@ class _LoginWithPasswordState extends State { scheduleMicrotask(() { userVM = Provider.of(context, listen: false); context.read().getAvailBio(); - if (AppState().currentAppType == AppType.provider) { - phoneNum = "966530896018"; - password = "Amir@1234"; - // - // // phoneNum = "966569755630"; - // // password = "Amir12345@"; //AAmir Sal - // - // // phoneNum = "966598646795"; - // // password = "Zahoor@123"; - // - // // User Details - // // phoneNum = "966554870506"; - // // password = "Sikander123@"; // "lastName": "sik", - // // "email": "sikander@gmail.com", - // // phoneNum = "966569755630"; - // // password = "Amir12345@"; - } + // if (AppState().currentAppType == AppType.provider) { + // phoneNum = "966530896018"; + // password = "Amir@1234"; + // // + // // // phoneNum = "966569755630"; + // // // password = "Amir12345@"; //AAmir Sal + // // + // // // phoneNum = "966598646795"; + // // // password = "Zahoor@123"; + // // + // // // User Details + // // // phoneNum = "966554870506"; + // // // password = "Sikander123@"; // "lastName": "sik", + // // // "email": "sikander@gmail.com", + // // // phoneNum = "966569755630"; + // // // password = "Amir12345@"; + // } getCountryList(); }); diff --git a/pubspec.yaml b/pubspec.yaml index b85f5e6..77d9a49 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -13,28 +13,28 @@ dependencies: cupertino_icons: ^1.0.2 path_provider: ^2.0.4 - injector: ^2.0.0 + injector: ^4.0.0 provider: ^6.0.0 easy_localization: ^3.0.3 http: ^0.13.3 permission_handler: ^11.3.1 - flutter_svg: ^1.0.3 - sizer: ^2.0.15 + flutter_svg: ^2.0.9 + sizer: any fluttertoast: ^8.0.8 shared_preferences: ^2.0.6 - file_picker: ^6.1.1 - image_picker: ^0.8.4+4 + file_picker: ^8.1.2 + image_picker: ^1.1.2 equatable: ^2.0.3 - logger: 2.3.0 + logger: ^2.4.0 auto_size_text: any - shimmer: ^2.0.0 + shimmer: ^3.0.0 hexcolor: ^3.0.1 cached_network_image: any url_launcher: ^6.1.14 badges: ^3.0.2 carousel_slider: 5.0.0 dropdown_button2: ^2.0.0 - flutter_inappwebview: ^5.7.2+3 + flutter_inappwebview: ^6.1.5 country_code_picker: ^3.0.0 table_calendar: ^3.0.9 intl: any @@ -46,9 +46,9 @@ dependencies: # Firebase Packages - firebase_messaging: ^15.0.4 - firebase_core: ^3.3.0 - flutter_local_notifications: ^17.2.1+2 + firebase_messaging: ^15.1.3 + firebase_core: ^3.6.0 + flutter_local_notifications: ^17.2.3 # google @@ -60,15 +60,15 @@ dependencies: # Auth local_auth: ^2.2.0 - huawei_fido: ^6.3.0+305 - device_info_plus: ^10.1.0 - + #huawei_fido: ^6.3.0+305 + device_info_plus: ^11.0.0 + flutter_lints: any dev_dependencies: flutter_test: sdk: flutter - flutter_lints: ^2.0.0 + flutter: From 327f9d41b7c5fd760518c1ec2fbd50d1d291edfc Mon Sep 17 00:00:00 2001 From: Aamir Date: Thu, 24 Oct 2024 16:11:04 +0300 Subject: [PATCH 2/3] changes --- .../profile/document.dart | 39 ++--- lib/services/payments_service.dart | 8 +- .../provider_license_page.dart | 135 +++++++++--------- 3 files changed, 98 insertions(+), 84 deletions(-) diff --git a/lib/models/provider_branches_models/profile/document.dart b/lib/models/provider_branches_models/profile/document.dart index eb6d2f8..d82aa02 100644 --- a/lib/models/provider_branches_models/profile/document.dart +++ b/lib/models/provider_branches_models/profile/document.dart @@ -21,14 +21,16 @@ class Document { int? messageStatus; String? message; - factory Document.fromJson(Map json) => Document( + factory Document.fromJson(Map json) => + Document( totalItemsCount: json["totalItemsCount"], data: json["data"] == null ? null : List.from(json["data"].map((x) => DocumentData.fromJson(x))), messageStatus: json["messageStatus"], message: json["message"], ); - Map toJson() => { + Map toJson() => + { "totalItemsCount": totalItemsCount, "data": data == null ? null : List.from(data!.map((x) => x.toJson())), "messageStatus": messageStatus, @@ -50,6 +52,7 @@ class DocumentData { this.fileExt, this.documentName, this.isLocalFile, + this.description, }); int? id; @@ -64,22 +67,26 @@ class DocumentData { String? statusText; String? documentName; bool? isLocalFile; + String? description; - factory DocumentData.fromJson(Map json) => DocumentData( - id: json["id"], - serviceProviderId: json["serviceProviderID"], - documentId: json["documentID"], - documentUrl: json["documentURL"], - status: json["status"], - statusText: json["statusText"], - comment: json["comment"], - isActive: json["isActive"], - document: null, - fileExt: null, - documentName: json["documentName"], - isLocalFile: false); + factory DocumentData.fromJson(Map json) => + DocumentData( + id: json["id"], + serviceProviderId: json["serviceProviderID"], + documentId: json["documentID"], + documentUrl: json["documentURL"], + status: json["status"], + statusText: json["statusText"], + comment: json["comment"], + isActive: json["isActive"], + document: null, + fileExt: null, + documentName: json["documentName"], + isLocalFile: false, + description: null); - Map toJson() => { + Map toJson() => + { "id": id, "serviceProviderID": serviceProviderId, "documentID": documentId, diff --git a/lib/services/payments_service.dart b/lib/services/payments_service.dart index 36f5c91..4f8901d 100644 --- a/lib/services/payments_service.dart +++ b/lib/services/payments_service.dart @@ -27,10 +27,12 @@ abstract class PaymentService { class PaymentServiceImp implements PaymentService { MyInAppBrowser? myInAppBrowser; var inAppBrowserOptions = InAppBrowserClassOptions( - inAppWebViewGroupOptions: InAppWebViewGroupOptions(crossPlatform: InAppWebViewOptions(useShouldOverrideUrlLoading: true, transparentBackground: false), ios: IOSInAppWebViewOptions(applePayAPIEnabled: true)), + inAppWebViewGroupOptions: + InAppWebViewGroupOptions(crossPlatform: InAppWebViewOptions(useShouldOverrideUrlLoading: true, transparentBackground: false), ios: IOSInAppWebViewOptions(applePayAPIEnabled: true)), crossPlatform: InAppBrowserOptions(hideUrlBar: true, toolbarTopBackgroundColor: Colors.black), android: AndroidInAppBrowserOptions(), - ios: IOSInAppBrowserOptions(hideToolbarBottom: true, toolbarBottomBackgroundColor: Colors.white, closeButtonColor: Colors.white, presentationStyle: IOSUIModalPresentationStyle.OVER_FULL_SCREEN)); + ios: + IOSInAppBrowserOptions(hideToolbarBottom: true, toolbarBottomBackgroundColor: Colors.white, closeButtonColor: Colors.white, presentationStyle: IOSUIModalPresentationStyle.OVER_FULL_SCREEN)); String getUrlRequestByPaymentId({required int id, List? appointmentIds, required PaymentTypes paymentType}) { String urlRequest = ""; @@ -87,7 +89,7 @@ class PaymentServiceImp implements PaymentService { onBrowserLoadStart(onFailure: onFailure, onSuccess: onSuccess, url: url); }); await myInAppBrowser!.openUrlRequest( - urlRequest: URLRequest(url: Uri.parse(urlRequest)), + urlRequest: URLRequest(url: WebUri(urlRequest, forceToStringRawValue: true)), options: inAppBrowserOptions, ); } diff --git a/lib/views/setting_options/provider_license_page.dart b/lib/views/setting_options/provider_license_page.dart index 9d17e99..6ae4eea 100644 --- a/lib/views/setting_options/provider_license_page.dart +++ b/lib/views/setting_options/provider_license_page.dart @@ -130,72 +130,77 @@ class _ProviderLicensePageState extends State { return serviceVM.document!.data!.isEmpty ? Text(LocaleKeys.somethingWrong.tr()) : ListView.separated( - separatorBuilder: (context, index) { - return 20.height; - }, - itemCount: serviceVM.document!.data!.length, - physics: const NeverScrollableScrollPhysics(), - shrinkWrap: true, - padding: const EdgeInsets.symmetric(horizontal: 20), - itemBuilder: (context, index) { - DocumentData? document = serviceVM.document?.data![index]; - return Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - 10.height, - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - (document!.documentName!).toText(fontSize: 16, letterSpacing: -0.56, fontWeight: MyFonts.SemiBold), - if (document.statusText != null && document.statusText!.isNotEmpty) ...[ - 10.width, - Utils.statusContainerChip(text: document.statusText!.replaceFirst('OrActive', ''), chipColor: getColorByStatus(document.status ?? 1)), - ], - ], - ), - if (document.status != 1 && document.status != 3) ...[ - Padding( - padding: const EdgeInsets.only(top: 4, bottom: 8), - child: LocaleKeys.enter_licence_detail.tr().toText(fontSize: 14, color: MyColors.lightTextColor), - ), - TxtField( - hint: LocaleKeys.description.tr(), - maxLines: 3, - isBackgroundEnabled: true, - ), - ], - 10.height, - if (isNeedToShow(model: serviceVM, document: document)) ...[ - PickedFilesContainer( - isReview: document.status == 4, - allowAdButton: false, - pickedFiles: isLocalOrNetworkFiles(model: serviceVM, document: document), - onCrossPressedPrimary: isNetworkImage(document: document) - ? serviceVM.removeNetworkImage - : document.documentId == 1 - ? serviceVM.commerceRemove - : document.documentId == 2 - ? serviceVM.commercialRemove - : serviceVM.vatRemove, - isPdf: serviceVM.document!.data![index].fileExt == "pdf", - isFromNetwork: !(document.isLocalFile ?? false), - onAddFilePressed: () { - serviceVM.pickPdfReceiptFile(context, document.documentId!, index); - }, - ), - buildCommentContainer(document: document), - ] else ...[ - 10.height, - DottedRectContainer( - onTap: () => serviceVM.pickPdfReceiptFile(context, document.documentId!, index) ?? "", - text: LocaleKeys.attachImage.tr(), - icon: MyAssets.attachmentIcon.buildSvg(), - ), - ], + separatorBuilder: (context, index) { + return 20.height; + }, + itemCount: serviceVM.document!.data!.length, + physics: const NeverScrollableScrollPhysics(), + shrinkWrap: true, + padding: const EdgeInsets.symmetric(horizontal: 20), + itemBuilder: (context, index) { + DocumentData? document = serviceVM.document?.data![index]; + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + 10.height, + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + (document!.documentName!).toText(fontSize: 16, letterSpacing: -0.56, fontWeight: MyFonts.SemiBold), + if (document.statusText != null && document.statusText!.isNotEmpty) ...[ + 10.width, + Utils.statusContainerChip(text: document.statusText!.replaceFirst('OrActive', ''), chipColor: getColorByStatus(document.status ?? 1)), ], - ); - }, - ); + ], + ), + if (document.status != 1 && document.status != 3) ...[ + Padding( + padding: const EdgeInsets.only(top: 4, bottom: 8), + child: LocaleKeys.enter_licence_detail.tr().toText(fontSize: 14, color: MyColors.lightTextColor), + ), + TxtField( + hint: LocaleKeys.description.tr(), + maxLines: 3, + isBackgroundEnabled: true, + value: document.description != null ? document.description : "", + onChanged: (val) { + document.description = val; + }, + ), + ], + 10.height, + if (isNeedToShow(model: serviceVM, document: document)) ...[ + PickedFilesContainer( + isReview: document.status == 4, + allowAdButton: false, + pickedFiles: isLocalOrNetworkFiles(model: serviceVM, document: document), + onCrossPressedPrimary: isNetworkImage(document: document) + ? serviceVM.removeNetworkImage + : document.documentId == 1 + ? serviceVM.commerceRemove + : document.documentId == 2 + ? serviceVM.commercialRemove + : serviceVM.vatRemove, + isPdf: serviceVM.document!.data![index].fileExt == "pdf", + isFromNetwork: !(document.isLocalFile ?? false), + onAddFilePressed: () { + serviceVM.pickPdfReceiptFile(context, document.documentId!, index); + }, + ), + buildCommentContainer(document: document), + ] else + ...[ + 10.height, + DottedRectContainer( + onTap: () => serviceVM.pickPdfReceiptFile(context, document.documentId!, index) ?? "", + text: LocaleKeys.attachImage.tr(), + icon: MyAssets.attachmentIcon.buildSvg(), + ), + ], + ], + ); + }, + ); } List isLocalOrNetworkFiles({required ServiceVM model, required DocumentData document}) { From 73080483fcd09d15621632e131d539056443063d Mon Sep 17 00:00:00 2001 From: Aamir Date: Sun, 3 Nov 2024 10:18:24 +0300 Subject: [PATCH 3/3] changes --- assets/langs/ar-SA.json | 3 +- assets/langs/en-US.json | 3 +- lib/config/dependency_injection.dart | 2 + lib/generated/codegen_loader.g.dart | 6 +- lib/generated/locale_keys.g.dart | 1 + lib/services/common_services.dart | 1 + lib/services/payments_service.dart | 39 +++- lib/utils/location/Location.dart | 44 +++- lib/view_models/payment_view_model.dart | 2 +- lib/view_models/service_view_model.dart | 46 +++- lib/view_models/subscriptions_view_model.dart | 18 +- .../location_views/map_selection_widget.dart | 4 +- .../location_views/pick_location_page.dart | 39 ++-- .../provider_license_page.dart | 218 ++++++++++-------- 14 files changed, 268 insertions(+), 158 deletions(-) diff --git a/assets/langs/ar-SA.json b/assets/langs/ar-SA.json index 0e1df59..9556085 100644 --- a/assets/langs/ar-SA.json +++ b/assets/langs/ar-SA.json @@ -679,5 +679,6 @@ "inviteFriendsByWhatsApp": "دعوة الأصدقاء عبر واتساب", "inviteFriendsByEmail": "دعوة الأصدقاء عبر البريد الإلكتروني", "noFAQsToShow": "لا توجد أسئلة شائعة في الوقت الحالي. يرجى الاتصال بنا إذا كان لديك أي استفسار.", - "appInfo": "معلومات التطبيق" + "appInfo": "معلومات التطبيق", + "attachPDF": "إرفاق قوات الدفاع الشعبي" } \ No newline at end of file diff --git a/assets/langs/en-US.json b/assets/langs/en-US.json index a4cf2bd..f2508db 100644 --- a/assets/langs/en-US.json +++ b/assets/langs/en-US.json @@ -677,5 +677,6 @@ "inviteFriendsByWhatsApp": "Invite Friends By WhatsApp", "inviteFriendsByEmail": "Invite Friends By Email", "noFAQsToShow": "There are no Frequently asked Questions Right now. Please contact us if you have any query.", - "appInfo": "App Info" + "appInfo": "App Info", + "attachPDF": "Attach PDF" } \ No newline at end of file diff --git a/lib/config/dependency_injection.dart b/lib/config/dependency_injection.dart index 8a42acd..f79770c 100644 --- a/lib/config/dependency_injection.dart +++ b/lib/config/dependency_injection.dart @@ -18,6 +18,7 @@ import 'package:mc_common_app/repositories/user_repo.dart'; import 'package:mc_common_app/services/common_services.dart'; import 'package:mc_common_app/services/firebase_service.dart'; import 'package:mc_common_app/services/payments_service.dart'; +import 'package:mc_common_app/utils/location/Location.dart'; import '../repositories/request_repo.dart'; @@ -46,6 +47,7 @@ class AppDependencies { injector.registerSingleton(() => BranchRepoImp()); injector.registerSingleton(() => ShippingRepoImp()); injector.registerSingleton(() => SettingOptionsRepoImp()); + injector.registerSingleton(() => LocationService()); // } diff --git a/lib/generated/codegen_loader.g.dart b/lib/generated/codegen_loader.g.dart index 5e42c42..5317da0 100644 --- a/lib/generated/codegen_loader.g.dart +++ b/lib/generated/codegen_loader.g.dart @@ -695,7 +695,8 @@ class CodegenLoader extends AssetLoader{ "inviteFriendsByWhatsApp": "دعوة الأصدقاء عبر واتساب", "inviteFriendsByEmail": "دعوة الأصدقاء عبر البريد الإلكتروني", "noFAQsToShow": "لا توجد أسئلة شائعة في الوقت الحالي. يرجى الاتصال بنا إذا كان لديك أي استفسار.", - "appInfo": "معلومات التطبيق" + "appInfo": "معلومات التطبيق", + "attachPDF": "إرفاق قوات الدفاع الشعبي" }; static const Map en_US = { "firstTimeLogIn": "First Time Log In", @@ -1376,7 +1377,8 @@ static const Map en_US = { "inviteFriendsByWhatsApp": "Invite Friends By WhatsApp", "inviteFriendsByEmail": "Invite Friends By Email", "noFAQsToShow": "There are no Frequently asked Questions Right now. Please contact us if you have any query.", - "appInfo": "App Info" + "appInfo": "App Info", + "attachPDF": "Attach PDF" }; 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 9734eae..92b01c9 100644 --- a/lib/generated/locale_keys.g.dart +++ b/lib/generated/locale_keys.g.dart @@ -659,5 +659,6 @@ abstract class LocaleKeys { static const inviteFriendsByEmail = 'inviteFriendsByEmail'; static const noFAQsToShow = 'noFAQsToShow'; static const appInfo = 'appInfo'; + static const attachPDF = 'attachPDF'; } diff --git a/lib/services/common_services.dart b/lib/services/common_services.dart index 53ffe31..b1788e5 100644 --- a/lib/services/common_services.dart +++ b/lib/services/common_services.dart @@ -6,6 +6,7 @@ import 'package:geolocator/geolocator.dart'; import 'package:image_picker/image_picker.dart'; import 'package:mc_common_app/main.dart'; import 'package:mc_common_app/utils/app_permission_handler.dart'; +import 'package:mc_common_app/utils/utils.dart'; abstract class CommonAppServices { Future> pickMultipleImages(); diff --git a/lib/services/payments_service.dart b/lib/services/payments_service.dart index 4f8901d..1a495f8 100644 --- a/lib/services/payments_service.dart +++ b/lib/services/payments_service.dart @@ -26,13 +26,29 @@ abstract class PaymentService { class PaymentServiceImp implements PaymentService { MyInAppBrowser? myInAppBrowser; - var inAppBrowserOptions = InAppBrowserClassOptions( - inAppWebViewGroupOptions: - InAppWebViewGroupOptions(crossPlatform: InAppWebViewOptions(useShouldOverrideUrlLoading: true, transparentBackground: false), ios: IOSInAppWebViewOptions(applePayAPIEnabled: true)), - crossPlatform: InAppBrowserOptions(hideUrlBar: true, toolbarTopBackgroundColor: Colors.black), - android: AndroidInAppBrowserOptions(), - ios: - IOSInAppBrowserOptions(hideToolbarBottom: true, toolbarBottomBackgroundColor: Colors.white, closeButtonColor: Colors.white, presentationStyle: IOSUIModalPresentationStyle.OVER_FULL_SCREEN)); + var inAppBrowserOptions = InAppBrowserClassSettings( + + webViewSettings: InAppWebViewSettings( + useShouldOverrideUrlLoading: false, + transparentBackground: false, + isInspectable: false, + applePayAPIEnabled: true, + cacheEnabled: false, + ), + browserSettings: InAppBrowserSettings( + hideUrlBar: true, + hideTitleBar: true, + hideDefaultMenuItems: true, + hideToolbarBottom: true, + hideToolbarTop: false, + hideCloseButton: false, + allowGoBackWithBackButton: true, + toolbarBottomBackgroundColor: Colors.black, + closeButtonColor: Colors.white, + presentationStyle: ModalPresentationStyle.FULL_SCREEN, + // toolbarTopBackgroundColor: Colors.black + ), + ); String getUrlRequestByPaymentId({required int id, List? appointmentIds, required PaymentTypes paymentType}) { String urlRequest = ""; @@ -89,8 +105,13 @@ class PaymentServiceImp implements PaymentService { onBrowserLoadStart(onFailure: onFailure, onSuccess: onSuccess, url: url); }); await myInAppBrowser!.openUrlRequest( - urlRequest: URLRequest(url: WebUri(urlRequest, forceToStringRawValue: true)), - options: inAppBrowserOptions, + urlRequest: URLRequest( + url: WebUri(urlRequest, forceToStringRawValue: true), + allowsCellularAccess: true, + allowsConstrainedNetworkAccess: true, + allowsExpensiveNetworkAccess: true, + ), + settings: inAppBrowserOptions, ); } diff --git a/lib/utils/location/Location.dart b/lib/utils/location/Location.dart index bdb67b4..0c6b6a7 100644 --- a/lib/utils/location/Location.dart +++ b/lib/utils/location/Location.dart @@ -7,17 +7,29 @@ import 'package:flutter/rendering.dart'; import 'package:geolocator/geolocator.dart'; import 'package:google_maps_flutter/google_maps_flutter.dart'; +import 'package:mc_common_app/classes/app_state.dart'; import 'package:mc_common_app/utils/app_permission_handler.dart'; import 'package:mc_common_app/utils/utils.dart'; // import 'package:geodesy/geodesy.dart' as geodesy; -//Created By Mr.Zohaib -class Location { +abstract class Location { + void handleLocationPermission(); + + void havePermission(Function(bool) callback); + + void isEnabled(Function(bool) callback); + + void listenGPS({bool change = true, Function(bool)? onChange}); + + void getCurrentLocation(Function(LatLng?) callback); +} + +class LocationService implements Location { static _Map map = _Map(); - static void havePermission(Function(bool) callback) { + void havePermission(Function(bool) callback) { Geolocator.checkPermission().then((value) async { if (value == LocationPermission.denied) { value = await Geolocator.requestPermission(); @@ -28,13 +40,26 @@ class Location { }); } - static void isEnabled(Function(bool) callback) { + void isEnabled(Function(bool) callback) { Geolocator.isLocationServiceEnabled().then((value) => callback(value)); } + void handleLocationPermission() { + havePermission((val) { + if (val) { + print(val); + getCurrentLocation((LatLng? latlng) { + print(latlng); + AppState().currentLocation = latlng ?? const LatLng(0, 0); + print("App State Location" + AppState().currentLocation.toJson().toString()); + }); + } + }); + } + static bool _listeningSettingChange = true; - static void listenGPS({bool change = true, Function(bool)? onChange}) async { + void listenGPS({bool change = true, Function(bool)? onChange}) async { _listeningSettingChange = change; if (change == false) return; @@ -46,10 +71,8 @@ class Location { }); } - static void getCurrentLocation(Function(LatLng?) callback) { + void getCurrentLocation(Function(LatLng?) callback) { void done(Position position) { - //AppStorage.sp.saveLocation(position); - LatLng? myCurrentLocation = LatLng(position.latitude, position.longitude); callback(myCurrentLocation); } @@ -88,8 +111,7 @@ class Location { } class _Map { - Marker createMarker( - String id, { + Marker createMarker(String id, { required LatLng coordinates, BitmapDescriptor? icon, VoidCallback? onTap, @@ -139,7 +161,7 @@ class _Map { } void goToCurrentLocation({Completer? mapController, double? direction = 0.0, bool? animation}) { - Location.getCurrentLocation((location) { + LocationService().getCurrentLocation((location) { moveTo(location!, zoom: 17, mapController: mapController!, animation: animation, direction: direction!); }); } diff --git a/lib/view_models/payment_view_model.dart b/lib/view_models/payment_view_model.dart index 96a9af7..db53fb0 100644 --- a/lib/view_models/payment_view_model.dart +++ b/lib/view_models/payment_view_model.dart @@ -199,7 +199,7 @@ class PaymentVM extends ChangeNotifier { void onAppointmentSuccess(BuildContext context) { context.read().onNavbarTapped(1); navigateReplaceWithNameUntilRoute(context, AppRoutes.dashboard); - } + } Future onVisaCardSelected(BuildContext context, PaymentTypes paymentType) async { currentPaymentType = paymentType; diff --git a/lib/view_models/service_view_model.dart b/lib/view_models/service_view_model.dart index 90ad442..7644d40 100644 --- a/lib/view_models/service_view_model.dart +++ b/lib/view_models/service_view_model.dart @@ -93,15 +93,34 @@ class ServiceVM extends BaseVM { Future getServiceProviderDocument(int providerId) async { setState(ViewState.busy); + commerceCertificates.clear(); + commercialCertificates.clear(); + vatCertificates.clear(); + // 0 Need To Upload + //1 Pending + //2 + //3 Approved + //4 Rejected + // document = await branchRepo.getServiceProviderDocument(providerId); + // if (document != null && document!.data != null && document!.data!.isNotEmpty) { + // print(document!.data!.length); + // for (var doc in document!.data!) { + // print("doc: ${doc.status}"); + // if (doc.status != 3 || doc.status == 1) { + // updateIsAllDocsApproved(false); + // } + // } + // } + + // + document = await branchRepo.getServiceProviderDocument(providerId); - if (document != null && document!.data != null && document!.data!.isNotEmpty) { - for (var doc in document!.data!) { - log("doc: ${doc.status}"); - if (doc.status != 3) { - updateIsAllDocsApproved(false); - } - } - } + + // 0 Need To Upload + //1 Pending + //2 + //3 Approved + //4 Rejected setState(ViewState.idle); } @@ -210,10 +229,10 @@ class ServiceVM extends BaseVM { // return null; // } - bool isAllDocsApproved = false; + bool isShowContinue = true; - updateIsAllDocsApproved(var value) { - isAllDocsApproved = value; + updateIsShowContinue(var value) { + isShowContinue = value; notifyListeners(); } @@ -223,7 +242,12 @@ class ServiceVM extends BaseVM { context, allowMultiple: false, ); + if (files != null && files.any((file) => file.path.split('.').last.toLowerCase() != 'pdf')) { + Utils.showToast("Only PDF files are allowed"); + return; + } if (files == null) return; + for (var element in files) { imageModels.add(ImageModel( filePath: element.path, diff --git a/lib/view_models/subscriptions_view_model.dart b/lib/view_models/subscriptions_view_model.dart index deefeef..ddc0f84 100644 --- a/lib/view_models/subscriptions_view_model.dart +++ b/lib/view_models/subscriptions_view_model.dart @@ -3,6 +3,7 @@ import 'package:mc_common_app/models/general_models/generic_resp_model.dart'; import 'package:mc_common_app/models/subscriptions_models/branch_user_selection_model.dart'; import 'package:mc_common_app/models/subscriptions_models/subscription_model.dart'; import 'package:mc_common_app/utils/enums.dart'; +import 'package:mc_common_app/utils/utils.dart'; import 'package:mc_common_app/view_models/base_view_model.dart'; import 'package:mc_common_app/widgets/dropdown/dropdow_field.dart'; import '../repositories/subscription_repo.dart'; @@ -61,21 +62,22 @@ class SubscriptionsVM extends BaseVM { monthlyTabs.first.isEnabled = true; selectedMonthlyTab = monthlyTabs.first; - filterSubscriptions(); - getMySubscriptionsBySP(); + await filterSubscriptions(); + await getMySubscriptionsBySP(); setState(ViewState.idle); } else { setState(ViewState.error); } } - String newPrice = ""; + String newPrice = "0.0"; calculationUpgradePrice(String? serviceProviderID, String? newSubscription) async { setState(ViewState.busy); GenericRespModel genericRespModel = await subscriptionRepo.calculationUpgradePrice(serviceProviderID, newSubscription); if (genericRespModel.messageStatus == 1) { setState(ViewState.idle); + print("=========== ${genericRespModel.data.toString()}================="); newPrice = genericRespModel.data.toString(); } else { setState(ViewState.error); @@ -114,7 +116,12 @@ class SubscriptionsVM extends BaseVM { } Future createSubscriptionOrder(int subscriptionId, bool isStartNow, bool isRenew, {bool isDegrade = false, List? listOfBranches, List? listOfUsers}) async { - Map map = {"providerID": AppState().getUser.data?.userInfo?.providerId.toString() ?? "", "subscriptionID": subscriptionId.toString(), "isStartNow": isStartNow.toString(), "isRenew": isRenew.toString()}; + Map map = { + "providerID": AppState().getUser.data?.userInfo?.providerId.toString() ?? "", + "subscriptionID": subscriptionId.toString(), + "isStartNow": isStartNow.toString(), + "isRenew": isRenew.toString() + }; GenericRespModel genericRespModel = await subscriptionRepo.payForProviderSubscription(map); return genericRespModel; } @@ -185,6 +192,7 @@ class SubscriptionsVM extends BaseVM { // My Provider Subscription getMySubscriptionsBySP() async { setState(ViewState.busy); + mySubscriptionsBySp.clear(); if (mySubscriptionsBySp.isEmpty) { // allSubscriptions.data for (var element in allSubscriptions.data!) { @@ -192,9 +200,9 @@ class SubscriptionsVM extends BaseVM { mySubscriptionsBySp.add(element); } } - // mySubscriptionsBySp = await subscriptionRepo.getProviderSubscription(serviceProviderID: serviceProviderID); AppState().setproviderSubscription = mySubscriptionsBySp; } setState(ViewState.idle); } + } diff --git a/lib/views/location_views/map_selection_widget.dart b/lib/views/location_views/map_selection_widget.dart index dc28656..2275466 100644 --- a/lib/views/location_views/map_selection_widget.dart +++ b/lib/views/location_views/map_selection_widget.dart @@ -7,13 +7,14 @@ import 'package:google_maps_flutter/google_maps_flutter.dart'; class AppMap extends StatefulWidget { final CameraPositionCallback onCameraMove; + final VoidCallback onCameraIdle; Map initialCamera; late AppMapState _state; final Function onMapCreated; AppMap(this.initialCamera, - {required this.onCameraMove, required this.onMapCreated}); + {required this.onCameraMove, required this.onCameraIdle, required this.onMapCreated}); @override State createState() => _state = AppMapState(); @@ -59,6 +60,7 @@ class AppMapState extends State { const CameraPosition( target: LatLng(-26.1711459, 27.9002758), zoom: 2.0), onCameraMove: widget.onCameraMove, + onCameraIdle: widget.onCameraIdle, onMapCreated: (GoogleMapController controller) { googleMapController = controller; _googleMapControllerComp.complete(controller); diff --git a/lib/views/location_views/pick_location_page.dart b/lib/views/location_views/pick_location_page.dart index a4d4176..516b6a0 100644 --- a/lib/views/location_views/pick_location_page.dart +++ b/lib/views/location_views/pick_location_page.dart @@ -6,6 +6,7 @@ import 'package:flutter/material.dart'; import 'package:geolocator/geolocator.dart'; import 'package:google_maps_flutter/google_maps_flutter.dart'; +import 'package:mc_common_app/classes/app_state.dart'; import 'package:mc_common_app/generated/locale_keys.g.dart'; import 'package:mc_common_app/utils/navigator.dart'; import 'package:mc_common_app/widgets/button/show_fill_button.dart'; @@ -32,12 +33,11 @@ class _PickLocationPageState extends State { final Set markers = {}; late AppMap appMap; - static CameraPosition _kGooglePlex = const CameraPosition( - target: LatLng(37.42796133580664, -122.085749655962), + static CameraPosition _kGooglePlex = CameraPosition( + target: AppState().currentLocation, zoom: 14.4746, ); late LatLng currentPosition; - Completer mapController = Completer(); final ValueNotifier _counter = ValueNotifier(""); @override @@ -47,11 +47,15 @@ class _PickLocationPageState extends State { onCameraMove: (camera) { _updatePosition(camera); }, + onCameraIdle: (){ + print("===== Idle Triggered ====="); + updateAddress(latitude, longitude); + }, onMapCreated: () { - // goToCurrentLocation(); _getUserLocation(); setState(() {}); }, + ); super.initState(); } @@ -125,9 +129,7 @@ class _PickLocationPageState extends State { Future _updatePosition(CameraPosition position) async { latitude = position.target.latitude; longitude = position.target.longitude; - log(latitude.toString()); - log(latitude.toString()); - updateAddress(latitude, longitude); + // updateAddress(latitude, longitude); } void _getUserLocation() async { @@ -152,21 +154,28 @@ class _PickLocationPageState extends State { }, ); } + setState(() {}); } updateAddress(double latitude, double longitude) async { - List placemarks = await placemarkFromCoordinates(latitude, longitude); + print("========="); + List placemarks = await placemarkFromCoordinates(latitude, longitude).catchError((e) { + print(e); + }); + print(placemarks.length); + print("====end====="); _counter.value = '${placemarks.first.street}, ${placemarks.first.subLocality}, ${placemarks.first.locality}, ${placemarks.first.postalCode}, ${placemarks.first.country}'; + } setMap() { - setState(() { - _kGooglePlex = CameraPosition( - target: currentPosition, - zoom: 14.4746, - ); - appMap.moveTo(cameraPostion: _kGooglePlex); - }); + // setState(() { + _kGooglePlex = CameraPosition( + target: currentPosition, + zoom: 14.4746, + ); + appMap.moveTo(cameraPostion: _kGooglePlex); + // }); } Future getCurrentAddress() async { diff --git a/lib/views/setting_options/provider_license_page.dart b/lib/views/setting_options/provider_license_page.dart index 6ae4eea..ab535bd 100644 --- a/lib/views/setting_options/provider_license_page.dart +++ b/lib/views/setting_options/provider_license_page.dart @@ -58,40 +58,43 @@ class _ProviderLicensePageState extends State { child: CircularProgressIndicator(), ); } - return Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Expanded( - child: SingleChildScrollView(child: buildContent(serviceVM)), - ), - if (!serviceVM.isAllDocsApproved) ...[ - Padding( - padding: const EdgeInsets.all(12.0), - child: ShowFillButton( - title: LocaleKeys.continu.tr(), - maxWidth: double.infinity, - onPressed: () async { - bool status = false; - if (AppState().getUser.data!.userInfo!.roleId == 5) { - if (validateDocuments(serviceVM)) { - status = await updateDocument(serviceVM); + return GestureDetector( + onTap: () => FocusScope.of(context).focusedChild?.unfocus(), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + child: SingleChildScrollView(child: buildContent(serviceVM)), + ), + if (isAllowContinue(serviceVM)) ...[ + Padding( + padding: const EdgeInsets.all(12.0), + child: ShowFillButton( + title: LocaleKeys.continu.tr(), + maxWidth: double.infinity, + onPressed: () async { + bool status = false; + if (AppState().getUser.data!.userInfo!.roleId == 5) { + if (validateDocuments(serviceVM)) { + status = await updateDocument(serviceVM); + } else { + Utils.showToast(LocaleKeys.allDocumentMandatoryDealershipProvider.tr()); + return; + } } else { - Utils.showToast(LocaleKeys.allDocumentMandatoryDealershipProvider.tr()); - return; - } - } else { - status = await updateDocument(serviceVM); - } - Future.delayed(const Duration(seconds: 1), () { - if (status) { - pop(context); + status = await updateDocument(serviceVM); } - }); - }, + Future.delayed(const Duration(seconds: 1), () { + if (status != null && status) { + pop(context); + } + }); + }, + ), ), - ), + ], ], - ], + ), ); }), ); @@ -108,6 +111,19 @@ class _ProviderLicensePageState extends State { return valid; } + bool isAllowContinue(ServiceVM model) { + bool isShow = false; + if (model.document != null && model.document!.data != null && model.document!.data!.isNotEmpty) { + for (var doc in model.document!.data!) { + print("doc: ${doc.status}"); + if (doc.status == 4 || doc.status == 0) { + isShow = true; + } + } + } + return isShow; + } + Future updateDocument(ServiceVM model) async { try { Utils.showLoading(context); @@ -115,7 +131,7 @@ class _ProviderLicensePageState extends State { Utils.hideLoading(context); if (res.messageStatus == 1) { Utils.showToast(LocaleKeys.documentsUploadedSuccessfully.tr()); - Navigator.of(context).pop(); + // Navigator.of(context).pop(); return true; } else { Utils.showToast(res.message ?? ""); @@ -130,77 +146,77 @@ class _ProviderLicensePageState extends State { return serviceVM.document!.data!.isEmpty ? Text(LocaleKeys.somethingWrong.tr()) : ListView.separated( - separatorBuilder: (context, index) { - return 20.height; - }, - itemCount: serviceVM.document!.data!.length, - physics: const NeverScrollableScrollPhysics(), - shrinkWrap: true, - padding: const EdgeInsets.symmetric(horizontal: 20), - itemBuilder: (context, index) { - DocumentData? document = serviceVM.document?.data![index]; - return Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - 10.height, - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - (document!.documentName!).toText(fontSize: 16, letterSpacing: -0.56, fontWeight: MyFonts.SemiBold), - if (document.statusText != null && document.statusText!.isNotEmpty) ...[ - 10.width, - Utils.statusContainerChip(text: document.statusText!.replaceFirst('OrActive', ''), chipColor: getColorByStatus(document.status ?? 1)), + separatorBuilder: (context, index) { + return 20.height; + }, + itemCount: serviceVM.document!.data!.length, + physics: const NeverScrollableScrollPhysics(), + shrinkWrap: true, + padding: const EdgeInsets.symmetric(horizontal: 20), + itemBuilder: (context, index) { + DocumentData? document = serviceVM.document?.data![index]; + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + 10.height, + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + (document!.documentName!).toText(fontSize: 16, letterSpacing: -0.56, fontWeight: MyFonts.SemiBold), + if (document.statusText != null && document.statusText!.isNotEmpty) ...[ + 10.width, + Utils.statusContainerChip(text: document.statusText!.replaceFirst('OrActive', ''), chipColor: getColorByStatus(document.status ?? 1)), + ], + ], + ), + if (document.status != 1 && document.status != 3) ...[ + Padding( + padding: const EdgeInsets.only(top: 4, bottom: 8), + child: LocaleKeys.enter_licence_detail.tr().toText(fontSize: 14, color: MyColors.lightTextColor), + ), + // TxtField( + // hint: LocaleKeys.description.tr(), + // maxLines: 3, + // isBackgroundEnabled: true, + // value: document.description != null ? document.description : "", + // onChanged: (val) { + // document.description = val; + // }, + // ), + ], + 10.height, + if (isNeedToShow(model: serviceVM, document: document)) ...[ + PickedFilesContainer( + //|| document.status == 3 || document.status != 4 + isReview: document.status != 0 && document.status == 1 || document.status == 3, + allowAdButton: false, + pickedFiles: isLocalOrNetworkFiles(model: serviceVM, document: document), + onCrossPressedPrimary: isNetworkImage(document: document) + ? serviceVM.removeNetworkImage + : document.documentId == 1 + ? serviceVM.commerceRemove + : document.documentId == 2 + ? serviceVM.commercialRemove + : serviceVM.vatRemove, + isPdf: true, + isFromNetwork: !(document.isLocalFile ?? false), + onAddFilePressed: () { + serviceVM.pickPdfReceiptFile(context, document.documentId!, index); + }, + ), + buildCommentContainer(document: document), + ] else ...[ + 10.height, + DottedRectContainer( + onTap: () => serviceVM.pickPdfReceiptFile(context, document.documentId!, index) ?? "", + text: LocaleKeys.attachPDF.tr(), + icon: MyAssets.attachmentIcon.buildSvg(), + ), + ], ], - ], - ), - if (document.status != 1 && document.status != 3) ...[ - Padding( - padding: const EdgeInsets.only(top: 4, bottom: 8), - child: LocaleKeys.enter_licence_detail.tr().toText(fontSize: 14, color: MyColors.lightTextColor), - ), - TxtField( - hint: LocaleKeys.description.tr(), - maxLines: 3, - isBackgroundEnabled: true, - value: document.description != null ? document.description : "", - onChanged: (val) { - document.description = val; - }, - ), - ], - 10.height, - if (isNeedToShow(model: serviceVM, document: document)) ...[ - PickedFilesContainer( - isReview: document.status == 4, - allowAdButton: false, - pickedFiles: isLocalOrNetworkFiles(model: serviceVM, document: document), - onCrossPressedPrimary: isNetworkImage(document: document) - ? serviceVM.removeNetworkImage - : document.documentId == 1 - ? serviceVM.commerceRemove - : document.documentId == 2 - ? serviceVM.commercialRemove - : serviceVM.vatRemove, - isPdf: serviceVM.document!.data![index].fileExt == "pdf", - isFromNetwork: !(document.isLocalFile ?? false), - onAddFilePressed: () { - serviceVM.pickPdfReceiptFile(context, document.documentId!, index); - }, - ), - buildCommentContainer(document: document), - ] else - ...[ - 10.height, - DottedRectContainer( - onTap: () => serviceVM.pickPdfReceiptFile(context, document.documentId!, index) ?? "", - text: LocaleKeys.attachImage.tr(), - icon: MyAssets.attachmentIcon.buildSvg(), - ), - ], - ], - ); - }, - ); + ); + }, + ); } List isLocalOrNetworkFiles({required ServiceVM model, required DocumentData document}) {