diff --git a/lib/classes/app_state.dart b/lib/classes/app_state.dart index 2b1d974..d8e4dce 100644 --- a/lib/classes/app_state.dart +++ b/lib/classes/app_state.dart @@ -1,6 +1,7 @@ import 'package:google_maps_flutter/google_maps_flutter.dart'; import 'package:mc_common_app/models/general_models/post_params_model.dart'; import 'package:mc_common_app/models/subscriptions_models/provider_subscription_model.dart'; +import 'package:mc_common_app/models/subscriptions_models/subscription_model.dart'; import 'package:mc_common_app/models/user_models/user.dart'; import 'package:mc_common_app/utils/enums.dart'; @@ -62,11 +63,11 @@ class AppState { LatLng get getCurrentLocation => currentLocation; - List? _providerSubscription; + List? _providerSubscription; - List get getproviderSubscription => _providerSubscription!; + List get getproviderSubscription => _providerSubscription!; - set setproviderSubscription(List value) { + set setproviderSubscription(List value) { _providerSubscription = value; } } diff --git a/lib/models/provider_branches_models/profile/document.dart b/lib/models/provider_branches_models/profile/document.dart index 0876cb0..7be8a60 100644 --- a/lib/models/provider_branches_models/profile/document.dart +++ b/lib/models/provider_branches_models/profile/document.dart @@ -21,34 +21,25 @@ class Document { int? messageStatus; String? message; - factory Document.fromJson(Map json) => Document( - totalItemsCount: json["totalItemsCount"] == null ? null : json["totalItemsCount"], - data: json["data"] == null ? null : List.from(json["data"].map((x) => DocumentData.fromJson(x))), - messageStatus: json["messageStatus"] == null ? null : json["messageStatus"], - message: json["message"] == null ? null : json["message"], - ); + factory Document.fromJson(Map json) => + Document( + totalItemsCount: json["totalItemsCount"] == null ? null : json["totalItemsCount"], + data: json["data"] == null ? null : List.from(json["data"].map((x) => DocumentData.fromJson(x))), + messageStatus: json["messageStatus"] == null ? null : json["messageStatus"], + message: json["message"] == null ? null : json["message"], + ); - Map toJson() => { - "totalItemsCount": totalItemsCount == null ? null : totalItemsCount, - "data": data == null ? null : List.from(data!.map((x) => x.toJson())), - "messageStatus": messageStatus == null ? null : messageStatus, - "message": message == null ? null : message, - }; + Map toJson() => + { + "totalItemsCount": totalItemsCount == null ? null : totalItemsCount, + "data": data == null ? null : List.from(data!.map((x) => x.toJson())), + "messageStatus": messageStatus == null ? null : messageStatus, + "message": message == null ? null : message, + }; } class DocumentData { - DocumentData({ - this.id, - this.serviceProviderId, - this.documentId, - this.documentUrl, - this.status, - this.comment, - this.isActive, - this.document, - this.fileExt, - this.documentName, - }); + DocumentData({this.id, this.serviceProviderId, this.documentId, this.documentUrl, this.status, this.comment, this.isActive, this.document, this.fileExt, this.documentName}); int? id; int? serviceProviderId; @@ -61,26 +52,28 @@ class DocumentData { String? fileExt; String? documentName; - factory DocumentData.fromJson(Map json) => DocumentData( - id: json["id"] == null ? null : json["id"], - serviceProviderId: json["serviceProviderID"] == null ? null : json["serviceProviderID"], - documentId: json["documentID"] == null ? null : json["documentID"], - documentUrl: json["documentURL"], - status: json["status"] == null ? null : json["status"], - comment: json["comment"], - isActive: json["isActive"] == null ? null : json["isActive"], - document: null, - fileExt: null, - documentName: json["documentName"] == null ? null : json["documentName"], - ); + factory DocumentData.fromJson(Map json) => + DocumentData( + id: json["id"] == null ? null : json["id"], + serviceProviderId: json["serviceProviderID"] == null ? null : json["serviceProviderID"], + documentId: json["documentID"] == null ? null : json["documentID"], + documentUrl: json["documentURL"], + status: json["status"] == null ? null : json["status"], + comment: json["comment"], + isActive: json["isActive"] == null ? null : json["isActive"], + document: null, + fileExt: null, + documentName: json["documentName"] == null ? null : json["documentName"], + ); - Map toJson() => { - "id": id == null ? null : id, - "serviceProviderID": serviceProviderId == null ? null : serviceProviderId, - "documentID": documentId == null ? null : documentId, - "documentURL": documentUrl, - "status": status == null ? null : status, - "comment": comment, - "isActive": isActive == null ? null : isActive, - }; + Map toJson() => + { + "id": id == null ? null : id, + "serviceProviderID": serviceProviderId == null ? null : serviceProviderId, + "documentID": documentId == null ? null : documentId, + "documentURL": documentUrl, + "status": status == null ? null : status, + "comment": comment, + "isActive": isActive == null ? null : isActive, + }; } diff --git a/lib/models/subscriptions_models/provider_subscription_model.dart b/lib/models/subscriptions_models/provider_subscription_model.dart index 9cb2ae7..966c90a 100644 --- a/lib/models/subscriptions_models/provider_subscription_model.dart +++ b/lib/models/subscriptions_models/provider_subscription_model.dart @@ -22,6 +22,7 @@ class ProviderSubscriptionModel { int? totalSubUsers; int? totalAds; + ProviderSubscriptionModel({ this.id, this.subscriptionAppliedId, diff --git a/lib/models/subscriptions_models/subscription_model.dart b/lib/models/subscriptions_models/subscription_model.dart index a7e979d..fc77955 100644 --- a/lib/models/subscriptions_models/subscription_model.dart +++ b/lib/models/subscriptions_models/subscription_model.dart @@ -41,29 +41,35 @@ class SubscriptionModel { } class Subscription { - Subscription({ - this.id, - this.name, - this.description, - this.durationName, - this.durationDays, - this.price, - this.currency, - this.numberOfBranches, - this.numberOfSubUsers, - this.numberOfAds, - this.countryId, - this.countryName, - this.isSubscribed, - this.subscriptionAppliedId, - this.serviceProviderId, - this.dateStart, - this.dateEnd, - this.isExpired, - this.isActive, - this.subscriptionTypeEnum, - this.isMyCurrentPackage, - }); + Subscription( + {this.id, + this.name, + this.description, + this.durationName, + this.durationDays, + this.price, + this.currency, + this.countryId, + this.countryName, + this.isSubscribed, + this.subscriptionAppliedId, + this.serviceProviderId, + this.dateStart, + this.dateEnd, + this.isExpired, + this.isActive, + this.subscriptionTypeEnum, + this.isMyCurrentPackage, + this.isRenewable, + this.subscriptionBranches, + this.subscriptionSubUsers, + this.subscriptionAds, + this.totalBranches, + this.totalSubUsers, + this.totalAds, + this.branchesRemaining, + this.subUsersRemaining, + this.adsRemaining}); int? id; String? name; @@ -72,9 +78,6 @@ class Subscription { int? durationDays; double? price; String? currency; - int? numberOfBranches; - int? numberOfSubUsers; - int? numberOfAds; int? countryId; String? countryName; bool? isSubscribed; @@ -86,29 +89,48 @@ class Subscription { bool? isActive; SubscriptionTypeEnum? subscriptionTypeEnum; bool? isMyCurrentPackage; + bool? isRenewable; + + int? subscriptionBranches; + int? subscriptionSubUsers; + int? subscriptionAds; + int? totalBranches; + int? totalSubUsers; + int? totalAds; + int? branchesRemaining; + int? subUsersRemaining; + int? adsRemaining; factory Subscription.fromJson(Map json) => Subscription( - id: json["id"], - name: json["name"], - description: json["description"], - durationName: json["durationName"], - durationDays: json["durationDays"], - price: json["price"]?.toDouble(), - currency: json["currency"], - numberOfBranches: json["numberOfBranches"], - numberOfSubUsers: json["numberOfSubUsers"], - numberOfAds: json["numberOfAds"], - countryId: json["countryID"], - countryName: json["countryName"], - isSubscribed: json["isSubscribed"], - subscriptionAppliedId: json["subscriptionAppliedID"], - serviceProviderId: json["serviceProviderID"], - dateStart: json["dateStart"] == null ? null : DateTime.parse(json["dateStart"]), - dateEnd: json["dateEnd"] == null ? null : DateTime.parse(json["dateEnd"]), - isExpired: json["isExpired"], - isActive: json["isActive"], - isMyCurrentPackage: false, - subscriptionTypeEnum: json["subscriptionType"] == null ? null : ((json['subscriptionType']) as int).toSubscriptionTypeEnum()); + id: json["id"], + name: json["name"], + description: json["description"], + durationName: json["durationName"], + durationDays: json["durationDays"], + price: json["price"]?.toDouble(), + currency: json["currency"], + countryId: json["countryID"], + countryName: json["countryName"], + isSubscribed: json["isSubscribed"], + subscriptionAppliedId: json["subscriptionAppliedID"], + serviceProviderId: json["serviceProviderID"], + dateStart: json["dateStart"] == null ? null : DateTime.parse(json["dateStart"]), + dateEnd: json["dateEnd"] == null ? null : DateTime.parse(json["dateEnd"]), + isExpired: json["isExpired"], + isActive: json["isActive"], + isMyCurrentPackage: false, + isRenewable: json["isRenewable"], + subscriptionTypeEnum: json["subscriptionType"] == null ? null : ((json['subscriptionType']) as int).toSubscriptionTypeEnum(), + subscriptionBranches: json["subscriptionBranches"], + subscriptionSubUsers: json["subscriptionSubUsers"], + subscriptionAds: json["subscriptionAds"], + totalBranches: json["totalBranches"], + totalSubUsers: json["totalBranches"], + totalAds: json["totalAds"], + branchesRemaining: json["branchesRemaining"], + subUsersRemaining: json["subUsersRemaining"], + adsRemaining: json["adsRemaining"], + ); Map toJson() => { "id": id, @@ -118,9 +140,6 @@ class Subscription { "durationDays": durationDays, "price": price, "currency": currency, - "numberOfBranches": numberOfBranches, - "numberOfSubUsers": numberOfSubUsers, - "numberOfAds": numberOfAds, "countryID": countryId, "countryName": countryName, "isSubscribed": isSubscribed, @@ -130,5 +149,15 @@ class Subscription { "dateEnd": dateEnd?.toIso8601String(), "isExpired": isExpired, "isActive": isActive, + "isRenewable": isRenewable, + "subscriptionBranches": subscriptionBranches, + "subscriptionSubUsers": subscriptionSubUsers, + "subscriptionAds": subscriptionAds, + "totalBranches": totalBranches, + "totalSubUsers": totalSubUsers, + "totalAds": totalAds, + "branchesRemaining": branchesRemaining, + "subUsersRemaining": subUsersRemaining, + "adsRemaining": adsRemaining, }; } diff --git a/lib/services/common_services.dart b/lib/services/common_services.dart index 56daf74..3f0a050 100644 --- a/lib/services/common_services.dart +++ b/lib/services/common_services.dart @@ -12,7 +12,7 @@ abstract class CommonAppServices { Future pickImageFromPhone(int sourceFlag); - Future?> pickMultipleFiles(BuildContext context); + Future?> pickMultipleFiles(BuildContext context, {bool allowMultiple = true}); Future pickFile(BuildContext context, {required FileType fileType, List? allowedExtensions}); @@ -36,12 +36,12 @@ class CommonServicesImp implements CommonAppServices { } @override - Future?> pickMultipleFiles(BuildContext context) async { + Future?> pickMultipleFiles(BuildContext context, {bool allowMultiple = true}) async { FilePickerResult? result; final status = await AppPermissions.checkStoragePermissions(context); if (status) { - result = await FilePicker.platform.pickFiles(allowMultiple: true, type: FileType.custom, allowedExtensions: ['pdf']); + result = await FilePicker.platform.pickFiles(allowMultiple: allowMultiple, type: FileType.custom, allowedExtensions: ['pdf']); } List pickedFiles = []; diff --git a/lib/view_models/payment_view_model.dart b/lib/view_models/payment_view_model.dart index 4dc7d98..79ad783 100644 --- a/lib/view_models/payment_view_model.dart +++ b/lib/view_models/payment_view_model.dart @@ -211,10 +211,16 @@ class PaymentVM extends ChangeNotifier { navigateReplaceWithName(context, AppRoutes.dashboard); } - void onSubscriptionPaymentSuccess(BuildContext context) { - context.read().mySubscriptionsBySp = []; - context.read().getMySubscriptionsBySP(AppState().getUser.data?.userInfo?.providerId.toString() ?? ""); - navigateReplaceWithNameUntilRoute(context, AppRoutes.mySubscriptionsPage); + + + 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().mySubscriptionsBySp = []; + // context.read().getMySubscriptionsBySP(); + navigateReplaceWithNameUntilRoute(context, AppRoutes.dashboard); } Future onVisaCardSelected(BuildContext context, PaymentTypes paymentType) async { diff --git a/lib/view_models/service_view_model.dart b/lib/view_models/service_view_model.dart index 7215d81..6e154f6 100644 --- a/lib/view_models/service_view_model.dart +++ b/lib/view_models/service_view_model.dart @@ -62,6 +62,9 @@ class ServiceVM extends BaseVM { String branchName = ""; String branchDescription = ""; String branchErrorScreen = ""; + List commerceCertificates = []; + List commercialCertificates = []; + List vatCertificates = []; void updateSelectionOpenTime(String date) { openTime = date; @@ -116,29 +119,96 @@ class ServiceVM extends BaseVM { notifyListeners(); } - Future selectFile(BuildContext context, int index) async { - final status = await AppPermissions.checkStoragePermissions(context); - if (status) { - final File? file = await commonServices.pickFile( - context, - fileType: FileType.custom, - allowedExtensions: ['png', 'pdf', 'jpeg'], - ); - if (file != null) { - int sizeInBytes = file.lengthSync(); - // double sizeInMb = sizeInBytes / (1024 * 1024); - if (sizeInBytes > 1000000) { - Utils.showToast(LocaleKeys.fileLarger.tr()); - } else { - document!.data![index].document = Utils.convertFileToBase64(file); - document!.data![index].fileExt = Utils.checkFileExt(file.path); - document!.data![index].documentUrl = file.path; - setState(ViewState.idle); - } - } else { - // User canceled the picker - } + // Future selectFile(BuildContext context, int index) async { + // final status = await AppPermissions.checkStoragePermissions(context); + // if (status) { + // final File? file = await commonServices.pickFile( + // context, + // fileType: FileType.custom, + // allowedExtensions: ['png', 'pdf', 'jpeg'], + // ); + // if (file != null) { + // int sizeInBytes = file.lengthSync(); + // // double sizeInMb = sizeInBytes / (1024 * 1024); + // if (sizeInBytes > 1000000) { + // Utils.showToast(LocaleKeys.fileLarger.tr()); + // } else { + // document!.data![index].document = Utils.convertFileToBase64(file); + // document!.data![index].fileExt = Utils.checkFileExt(file.path); + // document!.data![index].documentUrl = file.path; + // setState(ViewState.idle); + // // return document!.data![index].document; + // } + // } else { + // // User canceled the picker + // } + // } + // } + + // Future selectFile(BuildContext context, int index) async { + // File? file = await commonServices.pickFile(context, fileType: FileType.custom, allowedExtensions: ['png', 'pdf', 'jpeg']); + // + // if (file != null) { + // int sizeInBytes = file.lengthSync(); + // // double sizeInMb = sizeInBytes / (1024 * 1024); + // if (sizeInBytes > 1000000) { + // Utils.showToast(LocaleKeys.fileLarger.tr()); + // } else { + // document!.data![index].document = Utils.convertFileToBase64(file); + // document!.data![index].fileExt = Utils.checkFileExt(file.path); + // document!.data![index].documentUrl = file.path; + // document!.data![index].isFileAttached = true; + // return Utils.convertFileToBase64(file); + // } + // } else { + // // User canceled the picker + // } + // return null; + // } + + Future pickPdfReceiptFile(BuildContext context, int documentID, int index) async { + List imageModels = []; + List? files = await commonServices.pickMultipleFiles(context, allowMultiple: false); + if (files == null) return null; + for (var element in files) { + imageModels.add(ImageModel(filePath: element.path, isFromNetwork: false)); } + documentID == 1 + ? commerceCertificates.addAll(imageModels) + : documentID == 2 + ? commercialCertificates.addAll(imageModels) + : vatCertificates.addAll(imageModels); + document!.data![index].document = Utils.convertFileToBase64(files.first); + document!.data![index].fileExt = Utils.checkFileExt(files.first.path); + document!.data![index].documentUrl = files.first.path; + notifyListeners(); + } + + Future commerceRemove(String filePath) async { + int index = commerceCertificates.indexWhere((element) => element.filePath == filePath); + if (index == -1) { + return; + } + commerceCertificates.removeAt(index); + notifyListeners(); + } + + Future commercialRemove(String filePath) async { + int index = commercialCertificates.indexWhere((element) => element.filePath == filePath); + if (index == -1) { + return; + } + commercialCertificates.removeAt(index); + notifyListeners(); + } + + Future vatRemove(String filePath) async { + int index = vatCertificates.indexWhere((element) => element.filePath == filePath); + if (index == -1) { + return; + } + vatCertificates.removeAt(index); + notifyListeners(); } Future updateDocument(List? data) async { @@ -265,10 +335,10 @@ class ServiceVM extends BaseVM { DropValue( element.id ?? 0, ((element.categoryName!.isEmpty - ? "N/A" - : countryCode == "SA" - ? element.categoryNameN - : element.categoryName) ?? + ? "N/A" + : countryCode == "SA" + ? element.categoryNameN + : element.categoryName) ?? "N/A"), "", ), @@ -412,9 +482,7 @@ class ServiceVM extends BaseVM { File file = File(imageModel.filePath!); List imageBytes = await file.readAsBytes(); String image = base64Encode(imageBytes); - String fileName = file.path - .split('/') - .last; + String fileName = file.path.split('/').last; branchPostingImages = BranchPostingImages( imageName: fileName, imageStr: image, diff --git a/lib/view_models/subscriptions_view_model.dart b/lib/view_models/subscriptions_view_model.dart index 7046d5d..2bae993 100644 --- a/lib/view_models/subscriptions_view_model.dart +++ b/lib/view_models/subscriptions_view_model.dart @@ -1,6 +1,7 @@ import 'dart:convert'; import 'package:mc_common_app/classes/app_state.dart'; +import 'package:mc_common_app/main.dart'; 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/provider_subscription_model.dart'; @@ -20,7 +21,7 @@ class SubscriptionsVM extends BaseVM { late DropValue selectedMonthlyTab; List monthlyTabs = []; late SubscriptionModel allSubscriptions; - List mySubscriptionsBySp = []; + List mySubscriptionsBySp = []; List tempSubscriptions = []; //My Subscriptions @@ -65,6 +66,7 @@ class SubscriptionsVM extends BaseVM { selectedMonthlyTab = monthlyTabs.first; filterSubscriptions(); + getMySubscriptionsBySP(); setState(ViewState.idle); } else { setState(ViewState.error); @@ -116,7 +118,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; } @@ -154,8 +161,9 @@ class SubscriptionsVM extends BaseVM { if (selectedMonthlyTab.id == element.durationDays) { tempSubscriptions.add(element); } - if (element.id == AppState().getproviderSubscription.first.subscriptionID) { + if (element.subscriptionTypeEnum == SubscriptionTypeEnum.current) { element.isMyCurrentPackage = true; + // mySubscriptionsBySp.add(element); } } } @@ -184,10 +192,16 @@ class SubscriptionsVM extends BaseVM { // General Chat // My Provider Subscription - getMySubscriptionsBySP(String? serviceProviderID) async { + getMySubscriptionsBySP() async { setState(ViewState.busy); if (mySubscriptionsBySp.isEmpty) { - mySubscriptionsBySp = await subscriptionRepo.getProviderSubscription(serviceProviderID: serviceProviderID); + // allSubscriptions.data + for (var element in allSubscriptions.data!) { + if (element.subscriptionTypeEnum == SubscriptionTypeEnum.current) { + mySubscriptionsBySp.add(element); + } + } + // mySubscriptionsBySp = await subscriptionRepo.getProviderSubscription(serviceProviderID: serviceProviderID); AppState().setproviderSubscription = mySubscriptionsBySp; } setState(ViewState.idle); diff --git a/lib/views/setting_options/provider_license_page.dart b/lib/views/setting_options/provider_license_page.dart index 742b68d..211ada4 100644 --- a/lib/views/setting_options/provider_license_page.dart +++ b/lib/views/setting_options/provider_license_page.dart @@ -1,18 +1,25 @@ +import 'dart:async'; +import 'dart:convert'; import 'dart:io'; import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; import 'package:mc_common_app/classes/app_state.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/main.dart'; import 'package:mc_common_app/models/general_models/generic_resp_model.dart'; +import 'package:mc_common_app/models/provider_branches_models/profile/document.dart'; import 'package:mc_common_app/theme/colors.dart'; import 'package:mc_common_app/utils/enums.dart'; import 'package:mc_common_app/utils/utils.dart'; import 'package:mc_common_app/view_models/service_view_model.dart'; +import 'package:mc_common_app/views/advertisement/components/picked_images_container_widget.dart'; import 'package:mc_common_app/widgets/button/show_fill_button.dart'; import 'package:mc_common_app/widgets/common_widgets/app_bar.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'; @@ -26,12 +33,16 @@ class ProviderLicensePage extends StatefulWidget { class _ProviderLicensePageState extends State { late ServiceVM branchVM; + bool showAttachment = false; + String? attachedFile; @override void initState() { super.initState(); - branchVM = Provider.of(context, listen: false); - branchVM.getServiceProviderDocument(AppState().getUser.data!.userInfo!.providerId ?? 0); + scheduleMicrotask(() { + branchVM = Provider.of(context, listen: false); + branchVM.getServiceProviderDocument(AppState().getUser.data!.userInfo!.providerId ?? 0); + }); } @override @@ -47,13 +58,9 @@ class _ProviderLicensePageState extends State { Expanded( child: SingleChildScrollView( child: Padding( - padding: const EdgeInsets.all(20.0), + padding: const EdgeInsets.all(0.0), child: Column( children: [ - // LocaleKeys.defineLicences.tr().toText20(isBold: true), - // 12.height, - // LocaleKeys.defineLicenese.tr().toText14(color: MyColors.lightTextColor), - 20.height, showWidget(model), ], ), @@ -99,6 +106,7 @@ class _ProviderLicensePageState extends State { updateDocument(ServiceVM model) async { Utils.showLoading(context); + GenericRespModel res = await model.updateDocument(model.document!.data); Utils.hideLoading(context); if (res.messageStatus == 1) { @@ -113,108 +121,105 @@ class _ProviderLicensePageState extends State { return model.document!.data!.isEmpty ? Text(LocaleKeys.somethingWrong.tr()) : ListView.separated( - itemBuilder: (context, index) { - return Column( - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Text( - model.document?.data![index].documentName ?? "", - style: const TextStyle( - fontSize: 16, + itemBuilder: (context, index) { + DocumentData? document = model.document?.data![index]; + return Column( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + 10.height, + (document!.documentName! ?? "").toText(fontSize: 16, letterSpacing: -0.56, fontWeight: MyFonts.SemiBold), + Padding( + padding: const EdgeInsets.only(left: 20, right: 20, top: 4, bottom: 8), + child: LocaleKeys.enter_licence_detail.tr().toText(fontSize: 14, color: MyColors.lightTextColor, textAlign: TextAlign.center), + ), + TxtField( + hint: LocaleKeys.description.tr(), + maxLines: 3, + isBackgroundEnabled: true, + ), + 10.height, + if (document.documentId == 1 + ? model.commerceCertificates.isNotEmpty + : document.documentId == 2 + ? model.commercialCertificates.isNotEmpty + : model.vatCertificates.isNotEmpty) ...[ + PickedFilesContainer( + pickedFiles: document.documentId == 1 + ? model.commerceCertificates + : document.documentId == 2 + ? model.commercialCertificates + : model.vatCertificates, + onCrossPressedPrimary: document.documentId == 1 + ? model.commerceRemove + : document.documentId == 2 + ? model.commercialRemove + : model.vatRemove, + isPdf: model.document!.data![index].fileExt == "pdf", + onAddFilePressed: () { + model.pickPdfReceiptFile(context, document.documentId!, index); + }, + ), + ] else + ...[ + 10.height, + InkWell( + onTap: () async { + model.pickPdfReceiptFile(context, document.documentId!, index) ?? ""; + }, + child: Container( + width: double.infinity, + height: 45, + decoration: BoxDecoration( + color: Colors.transparent, + border: Border.all(color: MyColors.greyACColor, width: 2), + borderRadius: const BorderRadius.all(Radius.circular(0)), ), - ), - Padding( - padding: const EdgeInsets.only(left: 20, right: 20, top: 4, bottom: 8), - child: LocaleKeys.enter_licence_detail.tr().toText(fontSize: 14, color: MyColors.lightTextColor, textAlign: TextAlign.center), - ), - TxtField( - hint: LocaleKeys.description.tr(), - maxLines: 3, - isBackgroundEnabled: true, - ), - if ((model.document?.data![index].documentUrl ?? "").toString().isNotEmpty) - Column( + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, children: [ - 8.height, - (model.document?.data![index].documentUrl ?? "").toString().toText( - fontSize: 14, - color: MyColors.lightTextColor, - ), - ], - ), - 8.height, - InkWell( - onTap: () async { - model.selectFile(context, index); - }, - child: Container( - width: double.infinity, - height: 45, - decoration: BoxDecoration( - color: Colors.transparent, - border: Border.all(color: MyColors.greyACColor, width: 2), - borderRadius: const BorderRadius.all(Radius.circular(0)), - ), - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - const Icon( - Icons.attach_file, - size: 18, + const Icon( + Icons.attach_file, + size: 18, + color: MyColors.darkPrimaryColor, + ), + 8.width, + Text( + LocaleKeys.attachFile.tr(), + style: const TextStyle( color: MyColors.darkPrimaryColor, ), - 8.width, - Text( - LocaleKeys.attachFile.tr(), - style: const TextStyle( - color: MyColors.darkPrimaryColor, - ), - ), - const Icon( - Icons.attach_file, - size: 18, - color: Colors.transparent, - ), - ], - ), + ), + const Icon( + Icons.attach_file, + size: 18, + color: Colors.transparent, + ), + ], ), ), - ], - ); - }, - separatorBuilder: (context, index) { - return 20.height; - }, - itemCount: model.document!.data!.length, - physics: const NeverScrollableScrollPhysics(), - shrinkWrap: true, - ); + ), + ], + ], + ); + }, + separatorBuilder: (context, index) { + return 20.height; + }, + itemCount: model.document!.data!.length, + physics: const NeverScrollableScrollPhysics(), + shrinkWrap: true, + padding: EdgeInsets.symmetric(horizontal: 20), + ); } else { - return const Center( - child: CircularProgressIndicator(), + return Column( + children: [ + 20.height, + const Center( + child: CircularProgressIndicator(), + ), + ], ); } } - -// selectFile(int index) async { -// FilePickerResult? result = await FilePicker.platform.pickFiles(type: FileType.custom, allowedExtensions: ['png', 'pdf', 'jpeg']); -// -// if (result != null) { -// File file = File(result.files.single.path ?? ""); -// int sizeInBytes = file.lengthSync(); -// // double sizeInMb = sizeInBytes / (1024 * 1024); -// if (sizeInBytes > 1000) { -// Utils.showToast("File is larger then 1KB"); -// } else { -// document!.data![index].document = Utils.convertFileToBase64(file); -// document!.data![index].fileExt = Utils.checkFileExt(file.path); -// setState(() { -// document!.data![index].documentUrl = result.files.single.path ?? ""; -// }); -// } -// } else { -// // User canceled the picker -// } -// } } diff --git a/lib/views/setting_options/setting_options_language.dart b/lib/views/setting_options/setting_options_language.dart index b897b9e..d58628a 100644 --- a/lib/views/setting_options/setting_options_language.dart +++ b/lib/views/setting_options/setting_options_language.dart @@ -111,7 +111,7 @@ class _SettingOptionsLanguageState extends State { ), ), titleText: LocaleKeys.mySubscription.tr(), - subTitle: AppState().getproviderSubscription.first.subscriptionName ?? "Silver", + subTitle: AppState().getproviderSubscription.first.name ?? "Silver", isForLanguage: false, needBorderBelow: true, onTap: () { diff --git a/lib/widgets/button/show_fill_button.dart b/lib/widgets/button/show_fill_button.dart index b59e56a..06d5f2b 100644 --- a/lib/widgets/button/show_fill_button.dart +++ b/lib/widgets/button/show_fill_button.dart @@ -2,6 +2,7 @@ import 'package:flutter/material.dart'; import 'package:mc_common_app/extensions/string_extensions.dart'; import 'package:mc_common_app/theme/colors.dart'; import 'package:mc_common_app/widgets/extensions/extensions_widget.dart'; +import 'package:mc_common_app/classes/consts.dart'; class ShowFillButton extends StatelessWidget { final String title; @@ -28,7 +29,7 @@ class ShowFillButton extends StatelessWidget { this.radius = 0, this.maxWidth = 88, this.maxHeight = 45, - this.fontSize = 16, + this.fontSize = 15, this.horizontalPadding = 16, this.isFlatButton = false, this.isBold = false, @@ -43,25 +44,25 @@ class ShowFillButton extends StatelessWidget { Widget build(BuildContext context) { return isFlatButton ? Container( - height: maxHeight, - padding: const EdgeInsets.only( - left: 20, - right: 20, - ), - child: showButton(), - ) + height: maxHeight, + padding: const EdgeInsets.only( + left: 20, + right: 20, + ), + child: showButton(), + ) : Padding( - padding: margin ?? const EdgeInsets.all(0.0), - child: ConstrainedBox( - constraints: BoxConstraints( - minHeight: maxHeight, - minWidth: maxWidth, - maxHeight: maxHeight, - maxWidth: maxWidth, - ), - child: showButton(), - ), - ); + padding: margin ?? const EdgeInsets.all(0.0), + child: ConstrainedBox( + constraints: BoxConstraints( + minHeight: maxHeight, + minWidth: maxWidth, + maxHeight: maxHeight, + maxWidth: maxWidth, + ), + child: showButton(), + ), + ); } Widget showButton() { @@ -70,10 +71,10 @@ class ShowFillButton extends StatelessWidget { color: isDisabled ? MyColors.grey98Color.withOpacity(0.3) : (isFlatButton - ? null - : isFilled - ? backgroundColor - : null), + ? null + : isFilled + ? backgroundColor + : null), margin: EdgeInsets.symmetric(horizontal: horizontalMargin, vertical: verticalMargin), child: MaterialButton( onPressed: onPressed, @@ -83,23 +84,25 @@ class ShowFillButton extends StatelessWidget { ), child: iconWidget != null ? Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - iconWidget!, - title.toText( - fontSize: fontSize, - isBold: isBold, - color: isDisabled ? MyColors.lightTextColor : txtColor, - maxLines: 1, - ), - ], - ) + mainAxisAlignment: MainAxisAlignment.center, + children: [ + iconWidget!, + title.toText( + fontSize: fontSize, + isBold: isBold, + fontWeight: MyFonts.Medium, + color: isDisabled ? MyColors.lightTextColor : txtColor, + maxLines: 1, + ), + ], + ) : title.toText( - fontSize: fontSize, - isBold: isBold, - color: isDisabled ? MyColors.lightTextColor : txtColor, - maxLines: 1, - ), + fontSize: fontSize, + isBold: isBold, + fontWeight: MyFonts.Medium, + color: isDisabled ? MyColors.lightTextColor : txtColor, + maxLines: 1, + ), ), ); }