master_new_changes
Aamir.Muhammad 1 year ago
parent 623d21fc80
commit df0bb8fb28

@ -562,7 +562,7 @@
"inviteFriends": "Invite Friends", "inviteFriends": "Invite Friends",
"more": "More", "more": "More",
"language": "Language", "language": "Language",
"mySubscriptions": "My Subscription", "mySubscription": "My Subscription",
"subscriptions": "Subscriptions", "subscriptions": "Subscriptions",
"defineLicenses": "Define Licenses", "defineLicenses": "Define Licenses",
"logOut": "Log Out", "logOut": "Log Out",

@ -1,6 +1,7 @@
import 'package:google_maps_flutter/google_maps_flutter.dart'; 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/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/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/models/user_models/user.dart';
import 'package:mc_common_app/utils/enums.dart'; import 'package:mc_common_app/utils/enums.dart';
@ -62,11 +63,11 @@ class AppState {
LatLng get getCurrentLocation => currentLocation; LatLng get getCurrentLocation => currentLocation;
List<ProviderSubscriptionModel>? _providerSubscription; List<Subscription>? _providerSubscription;
List<ProviderSubscriptionModel> get getproviderSubscription => _providerSubscription!; List<Subscription> get getproviderSubscription => _providerSubscription!;
set setproviderSubscription(List<ProviderSubscriptionModel> value) { set setproviderSubscription(List<Subscription> value) {
_providerSubscription = value; _providerSubscription = value;
} }
} }

@ -1176,7 +1176,7 @@ static const Map<String,dynamic> en_US = {
"inviteFriends": "Invite Friends", "inviteFriends": "Invite Friends",
"more": "More", "more": "More",
"language": "Language", "language": "Language",
"mySubscriptions": "My Subscription", "mySubscription": "My Subscription",
"subscriptions": "Subscriptions", "subscriptions": "Subscriptions",
"defineLicenses": "Define Licenses", "defineLicenses": "Define Licenses",
"logOut": "Log Out", "logOut": "Log Out",

@ -21,14 +21,16 @@ class Document {
int? messageStatus; int? messageStatus;
String? message; String? message;
factory Document.fromJson(Map<String, dynamic> json) => Document( factory Document.fromJson(Map<String, dynamic> json) =>
Document(
totalItemsCount: json["totalItemsCount"] == null ? null : json["totalItemsCount"], totalItemsCount: json["totalItemsCount"] == null ? null : json["totalItemsCount"],
data: json["data"] == null ? null : List<DocumentData>.from(json["data"].map((x) => DocumentData.fromJson(x))), data: json["data"] == null ? null : List<DocumentData>.from(json["data"].map((x) => DocumentData.fromJson(x))),
messageStatus: json["messageStatus"] == null ? null : json["messageStatus"], messageStatus: json["messageStatus"] == null ? null : json["messageStatus"],
message: json["message"] == null ? null : json["message"], message: json["message"] == null ? null : json["message"],
); );
Map<String, dynamic> toJson() => { Map<String, dynamic> toJson() =>
{
"totalItemsCount": totalItemsCount == null ? null : totalItemsCount, "totalItemsCount": totalItemsCount == null ? null : totalItemsCount,
"data": data == null ? null : List<dynamic>.from(data!.map((x) => x.toJson())), "data": data == null ? null : List<dynamic>.from(data!.map((x) => x.toJson())),
"messageStatus": messageStatus == null ? null : messageStatus, "messageStatus": messageStatus == null ? null : messageStatus,
@ -37,18 +39,7 @@ class Document {
} }
class DocumentData { class DocumentData {
DocumentData({ DocumentData({this.id, this.serviceProviderId, this.documentId, this.documentUrl, this.status, this.comment, this.isActive, this.document, this.fileExt, this.documentName});
this.id,
this.serviceProviderId,
this.documentId,
this.documentUrl,
this.status,
this.comment,
this.isActive,
this.document,
this.fileExt,
this.documentName,
});
int? id; int? id;
int? serviceProviderId; int? serviceProviderId;
@ -61,7 +52,8 @@ class DocumentData {
String? fileExt; String? fileExt;
String? documentName; String? documentName;
factory DocumentData.fromJson(Map<String, dynamic> json) => DocumentData( factory DocumentData.fromJson(Map<String, dynamic> json) =>
DocumentData(
id: json["id"] == null ? null : json["id"], id: json["id"] == null ? null : json["id"],
serviceProviderId: json["serviceProviderID"] == null ? null : json["serviceProviderID"], serviceProviderId: json["serviceProviderID"] == null ? null : json["serviceProviderID"],
documentId: json["documentID"] == null ? null : json["documentID"], documentId: json["documentID"] == null ? null : json["documentID"],
@ -74,7 +66,8 @@ class DocumentData {
documentName: json["documentName"] == null ? null : json["documentName"], documentName: json["documentName"] == null ? null : json["documentName"],
); );
Map<String, dynamic> toJson() => { Map<String, dynamic> toJson() =>
{
"id": id == null ? null : id, "id": id == null ? null : id,
"serviceProviderID": serviceProviderId == null ? null : serviceProviderId, "serviceProviderID": serviceProviderId == null ? null : serviceProviderId,
"documentID": documentId == null ? null : documentId, "documentID": documentId == null ? null : documentId,

@ -22,6 +22,7 @@ class ProviderSubscriptionModel {
int? totalSubUsers; int? totalSubUsers;
int? totalAds; int? totalAds;
ProviderSubscriptionModel({ ProviderSubscriptionModel({
this.id, this.id,
this.subscriptionAppliedId, this.subscriptionAppliedId,

@ -41,17 +41,14 @@ class SubscriptionModel {
} }
class Subscription { class Subscription {
Subscription({ Subscription(
this.id, {this.id,
this.name, this.name,
this.description, this.description,
this.durationName, this.durationName,
this.durationDays, this.durationDays,
this.price, this.price,
this.currency, this.currency,
this.numberOfBranches,
this.numberOfSubUsers,
this.numberOfAds,
this.countryId, this.countryId,
this.countryName, this.countryName,
this.isSubscribed, this.isSubscribed,
@ -63,7 +60,16 @@ class Subscription {
this.isActive, this.isActive,
this.subscriptionTypeEnum, this.subscriptionTypeEnum,
this.isMyCurrentPackage, this.isMyCurrentPackage,
}); this.isRenewable,
this.subscriptionBranches,
this.subscriptionSubUsers,
this.subscriptionAds,
this.totalBranches,
this.totalSubUsers,
this.totalAds,
this.branchesRemaining,
this.subUsersRemaining,
this.adsRemaining});
int? id; int? id;
String? name; String? name;
@ -72,9 +78,6 @@ class Subscription {
int? durationDays; int? durationDays;
double? price; double? price;
String? currency; String? currency;
int? numberOfBranches;
int? numberOfSubUsers;
int? numberOfAds;
int? countryId; int? countryId;
String? countryName; String? countryName;
bool? isSubscribed; bool? isSubscribed;
@ -86,6 +89,17 @@ class Subscription {
bool? isActive; bool? isActive;
SubscriptionTypeEnum? subscriptionTypeEnum; SubscriptionTypeEnum? subscriptionTypeEnum;
bool? isMyCurrentPackage; 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<String, dynamic> json) => Subscription( factory Subscription.fromJson(Map<String, dynamic> json) => Subscription(
id: json["id"], id: json["id"],
@ -95,9 +109,6 @@ class Subscription {
durationDays: json["durationDays"], durationDays: json["durationDays"],
price: json["price"]?.toDouble(), price: json["price"]?.toDouble(),
currency: json["currency"], currency: json["currency"],
numberOfBranches: json["numberOfBranches"],
numberOfSubUsers: json["numberOfSubUsers"],
numberOfAds: json["numberOfAds"],
countryId: json["countryID"], countryId: json["countryID"],
countryName: json["countryName"], countryName: json["countryName"],
isSubscribed: json["isSubscribed"], isSubscribed: json["isSubscribed"],
@ -108,7 +119,18 @@ class Subscription {
isExpired: json["isExpired"], isExpired: json["isExpired"],
isActive: json["isActive"], isActive: json["isActive"],
isMyCurrentPackage: false, isMyCurrentPackage: false,
subscriptionTypeEnum: json["subscriptionType"] == null ? null : ((json['subscriptionType']) as int).toSubscriptionTypeEnum()); 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<String, dynamic> toJson() => { Map<String, dynamic> toJson() => {
"id": id, "id": id,
@ -118,9 +140,6 @@ class Subscription {
"durationDays": durationDays, "durationDays": durationDays,
"price": price, "price": price,
"currency": currency, "currency": currency,
"numberOfBranches": numberOfBranches,
"numberOfSubUsers": numberOfSubUsers,
"numberOfAds": numberOfAds,
"countryID": countryId, "countryID": countryId,
"countryName": countryName, "countryName": countryName,
"isSubscribed": isSubscribed, "isSubscribed": isSubscribed,
@ -130,5 +149,15 @@ class Subscription {
"dateEnd": dateEnd?.toIso8601String(), "dateEnd": dateEnd?.toIso8601String(),
"isExpired": isExpired, "isExpired": isExpired,
"isActive": isActive, "isActive": isActive,
"isRenewable": isRenewable,
"subscriptionBranches": subscriptionBranches,
"subscriptionSubUsers": subscriptionSubUsers,
"subscriptionAds": subscriptionAds,
"totalBranches": totalBranches,
"totalSubUsers": totalSubUsers,
"totalAds": totalAds,
"branchesRemaining": branchesRemaining,
"subUsersRemaining": subUsersRemaining,
"adsRemaining": adsRemaining,
}; };
} }

@ -12,7 +12,7 @@ abstract class CommonAppServices {
Future<File?> pickImageFromPhone(int sourceFlag); Future<File?> pickImageFromPhone(int sourceFlag);
Future<List<File>?> pickMultipleFiles(BuildContext context); Future<List<File>?> pickMultipleFiles(BuildContext context, {bool allowMultiple = true});
Future<File?> pickFile(BuildContext context, {required FileType fileType, List<String>? allowedExtensions}); Future<File?> pickFile(BuildContext context, {required FileType fileType, List<String>? allowedExtensions});
@ -36,12 +36,12 @@ class CommonServicesImp implements CommonAppServices {
} }
@override @override
Future<List<File>?> pickMultipleFiles(BuildContext context) async { Future<List<File>?> pickMultipleFiles(BuildContext context, {bool allowMultiple = true}) async {
FilePickerResult? result; FilePickerResult? result;
final status = await AppPermissions.checkStoragePermissions(context); final status = await AppPermissions.checkStoragePermissions(context);
if (status) { 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<File> pickedFiles = []; List<File> pickedFiles = [];

@ -189,16 +189,13 @@ class PaymentVM extends ChangeNotifier {
} }
onSubscriptionSuccess(BuildContext context) { onSubscriptionSuccess(BuildContext context) {
// pop(context); pop(context);
// pop(context);
// pop(context);
// context.read<SubscriptionsVM>().getMySubscriptions(AppState().getUser.data?.userInfo?.providerId.toString() ?? ""); // context.read<SubscriptionsVM>().getMySubscriptions(AppState().getUser.data?.userInfo?.providerId.toString() ?? "");
context context.read<SubscriptionsVM>().getSubscriptionBySP(AppState().getUser.data?.userInfo?.providerId.toString() ?? "", true);
.read<SubscriptionsVM>() // context.read<SubscriptionsVM>().mySubscriptionsBySp = [];
.mySubscriptionsBySp = []; // context.read<SubscriptionsVM>().getMySubscriptionsBySP();
context.read<SubscriptionsVM>().getMySubscriptionsBySP(AppState().getUser.data?.userInfo?.providerId.toString() ?? ""); navigateReplaceWithNameUntilRoute(context, AppRoutes.dashboard);
navigateReplaceWithNameUntilRoute(context, AppRoutes.mySubscriptionsPage);
} }
Future<void> onVisaCardSelected(BuildContext context, PaymentTypes paymentType) async { Future<void> onVisaCardSelected(BuildContext context, PaymentTypes paymentType) async {

@ -62,6 +62,9 @@ class ServiceVM extends BaseVM {
String branchName = ""; String branchName = "";
String branchDescription = ""; String branchDescription = "";
String branchErrorScreen = ""; String branchErrorScreen = "";
List<ImageModel> commerceCertificates = [];
List<ImageModel> commercialCertificates = [];
List<ImageModel> vatCertificates = [];
void updateSelectionOpenTime(String date) { void updateSelectionOpenTime(String date) {
openTime = date; openTime = date;
@ -116,29 +119,96 @@ class ServiceVM extends BaseVM {
notifyListeners(); notifyListeners();
} }
Future<void> selectFile(BuildContext context, int index) async { // Future<String?> selectFile(BuildContext context, int index) async {
final status = await AppPermissions.checkStoragePermissions(context); // final status = await AppPermissions.checkStoragePermissions(context);
if (status) { // if (status) {
final File? file = await commonServices.pickFile( // final File? file = await commonServices.pickFile(
context, // context,
fileType: FileType.custom, // fileType: FileType.custom,
allowedExtensions: ['png', 'pdf', 'jpeg'], // allowedExtensions: ['png', 'pdf', 'jpeg'],
); // );
if (file != null) { // if (file != null) {
int sizeInBytes = file.lengthSync(); // int sizeInBytes = file.lengthSync();
// double sizeInMb = sizeInBytes / (1024 * 1024); // // double sizeInMb = sizeInBytes / (1024 * 1024);
if (sizeInBytes > 1000000) { // if (sizeInBytes > 1000000) {
Utils.showToast(LocaleKeys.fileLarger.tr()); // Utils.showToast(LocaleKeys.fileLarger.tr());
} else { // } else {
document!.data![index].document = Utils.convertFileToBase64(file); // document!.data![index].document = Utils.convertFileToBase64(file);
document!.data![index].fileExt = Utils.checkFileExt(file.path); // document!.data![index].fileExt = Utils.checkFileExt(file.path);
document!.data![index].documentUrl = file.path; // document!.data![index].documentUrl = file.path;
setState(ViewState.idle); // setState(ViewState.idle);
// // return document!.data![index].document;
// }
// } else {
// // User canceled the picker
// }
// }
// }
// Future<String?> 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<void> pickPdfReceiptFile(BuildContext context, int documentID, int index) async {
List<ImageModel> imageModels = [];
List<File>? 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));
} }
} else { documentID == 1
// User canceled the picker ? 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<void> commerceRemove(String filePath) async {
int index = commerceCertificates.indexWhere((element) => element.filePath == filePath);
if (index == -1) {
return;
} }
commerceCertificates.removeAt(index);
notifyListeners();
} }
Future<void> commercialRemove(String filePath) async {
int index = commercialCertificates.indexWhere((element) => element.filePath == filePath);
if (index == -1) {
return;
}
commercialCertificates.removeAt(index);
notifyListeners();
}
Future<void> vatRemove(String filePath) async {
int index = vatCertificates.indexWhere((element) => element.filePath == filePath);
if (index == -1) {
return;
}
vatCertificates.removeAt(index);
notifyListeners();
} }
Future<GenericRespModel> updateDocument(List<DocumentData>? data) async { Future<GenericRespModel> updateDocument(List<DocumentData>? data) async {
@ -412,9 +482,7 @@ class ServiceVM extends BaseVM {
File file = File(imageModel.filePath!); File file = File(imageModel.filePath!);
List<int> imageBytes = await file.readAsBytes(); List<int> imageBytes = await file.readAsBytes();
String image = base64Encode(imageBytes); String image = base64Encode(imageBytes);
String fileName = file.path String fileName = file.path.split('/').last;
.split('/')
.last;
branchPostingImages = BranchPostingImages( branchPostingImages = BranchPostingImages(
imageName: fileName, imageName: fileName,
imageStr: image, imageStr: image,

@ -1,6 +1,7 @@
import 'dart:convert'; import 'dart:convert';
import 'package:mc_common_app/classes/app_state.dart'; 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/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/branch_user_selection_model.dart';
import 'package:mc_common_app/models/subscriptions_models/provider_subscription_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; late DropValue selectedMonthlyTab;
List<DropValue> monthlyTabs = []; List<DropValue> monthlyTabs = [];
late SubscriptionModel allSubscriptions; late SubscriptionModel allSubscriptions;
List<ProviderSubscriptionModel> mySubscriptionsBySp = []; List<Subscription> mySubscriptionsBySp = [];
List<Subscription> tempSubscriptions = []; List<Subscription> tempSubscriptions = [];
//My Subscriptions //My Subscriptions
@ -65,6 +66,7 @@ class SubscriptionsVM extends BaseVM {
selectedMonthlyTab = monthlyTabs.first; selectedMonthlyTab = monthlyTabs.first;
filterSubscriptions(); filterSubscriptions();
getMySubscriptionsBySP();
setState(ViewState.idle); setState(ViewState.idle);
} else { } else {
setState(ViewState.error); setState(ViewState.error);
@ -116,7 +118,12 @@ class SubscriptionsVM extends BaseVM {
} }
Future<GenericRespModel> createSubscriptionOrder(int subscriptionId, bool isStartNow, bool isRenew, {bool isDegrade = false, List<int>? listOfBranches, List<int>? listOfUsers}) async { Future<GenericRespModel> createSubscriptionOrder(int subscriptionId, bool isStartNow, bool isRenew, {bool isDegrade = false, List<int>? listOfBranches, List<int>? listOfUsers}) async {
Map<String, dynamic> map = {"providerID": AppState().getUser.data?.userInfo?.providerId.toString() ?? "", "subscriptionID": subscriptionId.toString(), "isStartNow": isStartNow.toString(), "isRenew": isRenew.toString()}; Map<String, dynamic> map = {
"providerID": AppState().getUser.data?.userInfo?.providerId.toString() ?? "",
"subscriptionID": subscriptionId.toString(),
"isStartNow": isStartNow.toString(),
"isRenew": isRenew.toString()
};
GenericRespModel genericRespModel = await subscriptionRepo.payForProviderSubscription(map); GenericRespModel genericRespModel = await subscriptionRepo.payForProviderSubscription(map);
return genericRespModel; return genericRespModel;
} }
@ -154,8 +161,9 @@ class SubscriptionsVM extends BaseVM {
if (selectedMonthlyTab.id == element.durationDays) { if (selectedMonthlyTab.id == element.durationDays) {
tempSubscriptions.add(element); tempSubscriptions.add(element);
} }
if (element.id == AppState().getproviderSubscription.first.subscriptionID) { if (element.subscriptionTypeEnum == SubscriptionTypeEnum.current) {
element.isMyCurrentPackage = true; element.isMyCurrentPackage = true;
// mySubscriptionsBySp.add(element);
} }
} }
} }
@ -176,10 +184,16 @@ class SubscriptionsVM extends BaseVM {
} }
// My Provider Subscription // My Provider Subscription
getMySubscriptionsBySP(String? serviceProviderID) async { getMySubscriptionsBySP() async {
setState(ViewState.busy); setState(ViewState.busy);
if (mySubscriptionsBySp.isEmpty) { 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; AppState().setproviderSubscription = mySubscriptionsBySp;
} }
setState(ViewState.idle); setState(ViewState.idle);

@ -1,18 +1,25 @@
import 'dart:async';
import 'dart:convert';
import 'dart:io'; import 'dart:io';
import 'package:easy_localization/easy_localization.dart'; import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:mc_common_app/classes/app_state.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/int_extensions.dart';
import 'package:mc_common_app/extensions/string_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/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/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/theme/colors.dart';
import 'package:mc_common_app/utils/enums.dart'; import 'package:mc_common_app/utils/enums.dart';
import 'package:mc_common_app/utils/utils.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/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/button/show_fill_button.dart';
import 'package:mc_common_app/widgets/common_widgets/app_bar.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:mc_common_app/widgets/txt_field.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
@ -26,12 +33,16 @@ class ProviderLicensePage extends StatefulWidget {
class _ProviderLicensePageState extends State<ProviderLicensePage> { class _ProviderLicensePageState extends State<ProviderLicensePage> {
late ServiceVM branchVM; late ServiceVM branchVM;
bool showAttachment = false;
String? attachedFile;
@override @override
void initState() { void initState() {
super.initState(); super.initState();
scheduleMicrotask(() {
branchVM = Provider.of<ServiceVM>(context, listen: false); branchVM = Provider.of<ServiceVM>(context, listen: false);
branchVM.getServiceProviderDocument(AppState().getUser.data!.userInfo!.providerId ?? 0); branchVM.getServiceProviderDocument(AppState().getUser.data!.userInfo!.providerId ?? 0);
});
} }
@override @override
@ -47,13 +58,9 @@ class _ProviderLicensePageState extends State<ProviderLicensePage> {
Expanded( Expanded(
child: SingleChildScrollView( child: SingleChildScrollView(
child: Padding( child: Padding(
padding: const EdgeInsets.all(20.0), padding: const EdgeInsets.all(0.0),
child: Column( child: Column(
children: [ children: [
// LocaleKeys.defineLicences.tr().toText20(isBold: true),
// 12.height,
// LocaleKeys.defineLicenese.tr().toText14(color: MyColors.lightTextColor),
20.height,
showWidget(model), showWidget(model),
], ],
), ),
@ -99,6 +106,7 @@ class _ProviderLicensePageState extends State<ProviderLicensePage> {
updateDocument(ServiceVM model) async { updateDocument(ServiceVM model) async {
Utils.showLoading(context); Utils.showLoading(context);
GenericRespModel res = await model.updateDocument(model.document!.data); GenericRespModel res = await model.updateDocument(model.document!.data);
Utils.hideLoading(context); Utils.hideLoading(context);
if (res.messageStatus == 1) { if (res.messageStatus == 1) {
@ -114,15 +122,12 @@ class _ProviderLicensePageState extends State<ProviderLicensePage> {
? Text(LocaleKeys.somethingWrong.tr()) ? Text(LocaleKeys.somethingWrong.tr())
: ListView.separated( : ListView.separated(
itemBuilder: (context, index) { itemBuilder: (context, index) {
DocumentData? document = model.document?.data![index];
return Column( return Column(
crossAxisAlignment: CrossAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center,
children: [ children: [
Text( 10.height,
model.document?.data![index].documentName ?? "", (document!.documentName! ?? "").toText(fontSize: 16, letterSpacing: -0.56, fontWeight: MyFonts.SemiBold),
style: const TextStyle(
fontSize: 16,
),
),
Padding( Padding(
padding: const EdgeInsets.only(left: 20, right: 20, top: 4, bottom: 8), 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), child: LocaleKeys.enter_licence_detail.tr().toText(fontSize: 14, color: MyColors.lightTextColor, textAlign: TextAlign.center),
@ -132,20 +137,34 @@ class _ProviderLicensePageState extends State<ProviderLicensePage> {
maxLines: 3, maxLines: 3,
isBackgroundEnabled: true, isBackgroundEnabled: true,
), ),
if ((model.document?.data![index].documentUrl ?? "").toString().isNotEmpty) 10.height,
Column( if (document.documentId == 1
children: [ ? model.commerceCertificates.isNotEmpty
8.height, : document.documentId == 2
(model.document?.data![index].documentUrl ?? "").toString().toText( ? model.commercialCertificates.isNotEmpty
fontSize: 14, : model.vatCertificates.isNotEmpty) ...[
color: MyColors.lightTextColor, 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);
},
), ),
8.height, ] else
...[
10.height,
InkWell( InkWell(
onTap: () async { onTap: () async {
model.selectFile(context, index); model.pickPdfReceiptFile(context, document.documentId!, index) ?? "";
}, },
child: Container( child: Container(
width: double.infinity, width: double.infinity,
@ -181,6 +200,7 @@ class _ProviderLicensePageState extends State<ProviderLicensePage> {
), ),
), ),
], ],
],
); );
}, },
separatorBuilder: (context, index) { separatorBuilder: (context, index) {
@ -189,32 +209,17 @@ class _ProviderLicensePageState extends State<ProviderLicensePage> {
itemCount: model.document!.data!.length, itemCount: model.document!.data!.length,
physics: const NeverScrollableScrollPhysics(), physics: const NeverScrollableScrollPhysics(),
shrinkWrap: true, shrinkWrap: true,
padding: EdgeInsets.symmetric(horizontal: 20),
); );
} else { } else {
return const Center( return Column(
children: [
20.height,
const Center(
child: CircularProgressIndicator(), 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
// }
// }
} }

@ -111,7 +111,7 @@ class _SettingOptionsLanguageState extends State<SettingOptionsLanguage> {
), ),
), ),
titleText: LocaleKeys.mySubscription.tr(), titleText: LocaleKeys.mySubscription.tr(),
subTitle: AppState().getproviderSubscription.first.subscriptionName ?? "Silver", subTitle: AppState().getproviderSubscription.first.name ?? "Silver",
isForLanguage: false, isForLanguage: false,
needBorderBelow: true, needBorderBelow: true,
onTap: () { onTap: () {

@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
import 'package:mc_common_app/extensions/string_extensions.dart'; import 'package:mc_common_app/extensions/string_extensions.dart';
import 'package:mc_common_app/theme/colors.dart'; import 'package:mc_common_app/theme/colors.dart';
import 'package:mc_common_app/widgets/extensions/extensions_widget.dart'; import 'package:mc_common_app/widgets/extensions/extensions_widget.dart';
import 'package:mc_common_app/classes/consts.dart';
class ShowFillButton extends StatelessWidget { class ShowFillButton extends StatelessWidget {
final String title; final String title;
@ -28,7 +29,7 @@ class ShowFillButton extends StatelessWidget {
this.radius = 0, this.radius = 0,
this.maxWidth = 88, this.maxWidth = 88,
this.maxHeight = 45, this.maxHeight = 45,
this.fontSize = 16, this.fontSize = 15,
this.horizontalPadding = 16, this.horizontalPadding = 16,
this.isFlatButton = false, this.isFlatButton = false,
this.isBold = false, this.isBold = false,
@ -89,6 +90,7 @@ class ShowFillButton extends StatelessWidget {
title.toText( title.toText(
fontSize: fontSize, fontSize: fontSize,
isBold: isBold, isBold: isBold,
fontWeight: MyFonts.Medium,
color: isDisabled ? MyColors.lightTextColor : txtColor, color: isDisabled ? MyColors.lightTextColor : txtColor,
maxLines: 1, maxLines: 1,
), ),
@ -97,6 +99,7 @@ class ShowFillButton extends StatelessWidget {
: title.toText( : title.toText(
fontSize: fontSize, fontSize: fontSize,
isBold: isBold, isBold: isBold,
fontWeight: MyFonts.Medium,
color: isDisabled ? MyColors.lightTextColor : txtColor, color: isDisabled ? MyColors.lightTextColor : txtColor,
maxLines: 1, maxLines: 1,
), ),

Loading…
Cancel
Save