diff --git a/lib/classes/app_state.dart b/lib/classes/app_state.dart index 964f7be..18dfa20 100644 --- a/lib/classes/app_state.dart +++ b/lib/classes/app_state.dart @@ -17,6 +17,7 @@ class AppState { bool? get getIsLogged => isLogged; AppType currentAppType = AppType.provider; + UserType userType = UserType.customer; void setAppType(AppType appType) { currentAppType = appType; diff --git a/lib/classes/consts.dart b/lib/classes/consts.dart index 7623f20..5ae6c81 100644 --- a/lib/classes/consts.dart +++ b/lib/classes/consts.dart @@ -105,6 +105,16 @@ class ApiConsts { static String getMatchedServices = "${baseUrlServices}api/ServiceProviders/ServiceProviderBranchServicesMapping_Get"; static String duplicateItems = "${baseUrlServices}api/ServiceProviders/ServiceItemCopy_Create"; + //Branch Users + + static String getAllProviderDealers = "${baseUrlServices}api/ServiceProviders/DealershipUserBranchWise_Get"; + + // /api/ServiceProviders/BranchUser_Get + //DealershipUserBranchWise_Get + static String getBranchUser = "${baseUrlServices}api/ServiceProviders/BranchUser_Get"; + static String assignDealerToBranch = "${baseUrlServices}api/ServiceProviders/BranchUser_Create"; + static String removeDealerFromBranch = "${baseUrlServices}api/ServiceProviders/BranchUser_Update"; + static List closingUrls = ["PayFortResponse"]; } diff --git a/lib/models/post_params_model.dart b/lib/models/post_params_model.dart index 780210b..e3dc4ae 100644 --- a/lib/models/post_params_model.dart +++ b/lib/models/post_params_model.dart @@ -19,7 +19,7 @@ class PostParamsModel { } Map toJson() { - final Map data = new Map(); + final Map data = Map(); data['VersionID'] = this.versionID; data['Channel'] = this.channel; data['LanguageID'] = this.languageID; diff --git a/lib/models/user/branch_user.dart b/lib/models/user/branch_user.dart new file mode 100644 index 0000000..4e6edfa --- /dev/null +++ b/lib/models/user/branch_user.dart @@ -0,0 +1,48 @@ +class BranchUser { + int id; + String? userId; + int? serviceProviderId; + int? dealershipUserID; + String firstName; + String lastName; + String mobileNo; + String email; + bool isBranchUser; + + BranchUser({ + required this.id, + required this.userId, + required this.serviceProviderId, + required this.dealershipUserID, + required this.firstName, + required this.lastName, + required this.mobileNo, + required this.email, + required this.isBranchUser, + }); + + factory BranchUser.fromJson(Map json) => + BranchUser( + id: json["id"], + userId: json.containsKey("userID") ? json["userID"] : null, + serviceProviderId: json.containsKey("serviceProviderID") ? json["serviceProviderID"] : null, + dealershipUserID: json.containsKey("dealershipUserID") ? json["dealershipUserID"] : null, + firstName: json["firstName"], + lastName: json["lastName"], + mobileNo: json["mobileNo"], + email: json["email"], + isBranchUser: json.containsKey("isBranchUser") ? json["isBranchUser"] : false, + ); + + Map toJson() => + { + "id": id, + "userID": userId, + "serviceProviderID": serviceProviderId, + "firstName": firstName, + "lastName": lastName, + "mobileNo": mobileNo, + "email": email, + "isBranchUser": isBranchUser, + }; +} diff --git a/lib/models/user/register_user.dart b/lib/models/user/register_user.dart index 5f5f79d..578ad04 100644 --- a/lib/models/user/register_user.dart +++ b/lib/models/user/register_user.dart @@ -22,18 +22,18 @@ class RegisterUserRespModel { final String? message; factory RegisterUserRespModel.fromJson(Map json) => RegisterUserRespModel( - messageStatus: json["messageStatus"] == null ? null : json["messageStatus"], - totalItemsCount: json["totalItemsCount"], - data: json["data"] == null ? null : Data.fromJson(json["data"]), - message: json["message"] == null ? null : json["message"], - ); + messageStatus: json["messageStatus"] == null ? null : json["messageStatus"], + totalItemsCount: json["totalItemsCount"], + data: json["data"] == null ? null : Data.fromJson(json["data"]), + message: json["message"] == null ? null : json["message"], + ); Map toJson() => { - "messageStatus": messageStatus == null ? null : messageStatus, - "totalItemsCount": totalItemsCount, - "data": data == null ? null : data!.toJson(), - "message": message == null ? null : message, - }; + "messageStatus": messageStatus == null ? null : messageStatus, + "totalItemsCount": totalItemsCount, + "data": data == null ? null : data!.toJson(), + "message": message == null ? null : message, + }; } class Data { @@ -58,6 +58,7 @@ class Data { this.providerId, this.customerId, this.dealershipId, + required this.isNeedToPassToken, }); final int? id; @@ -67,7 +68,7 @@ class Data { final String? mobileNo; final String? email; final dynamic? userImageUrl; - final int? roleId; + int? roleId; final dynamic? roleName; final bool? isEmailVerified; final List? serviceProviderBranch; @@ -80,50 +81,52 @@ class Data { final dynamic? providerId; final dynamic? customerId; final dynamic? dealershipId; + bool isNeedToPassToken; factory Data.fromJson(Map json) => Data( - id: json["id"] == null ? null : json["id"], - userId: json["userID"] == null ? null : json["userID"], - firstName: json["firstName"], - lastName: json["lastName"], - mobileNo: json["mobileNo"] == null ? null : json["mobileNo"], - email: json["email"] == null ? null : json["email"], - userImageUrl: json["userImageUrl"], - roleId: json["roleID"] == null ? null : json["roleID"], - roleName: json["roleName"], - isEmailVerified: json["isEmailVerified"] == null ? null : json["isEmailVerified"], - serviceProviderBranch: json["serviceProviderBranch"] == null ? null : List.from(json["serviceProviderBranch"].map((x) => x)), - isVerified: json["isVerified"] == null ? null : json["isVerified"], - userRoles: json["userRoles"] == null ? null : List.from(json["userRoles"].map((x) => x)), - isCustomer: json["isCustomer"] == null ? null : json["isCustomer"], - isProviderDealership: json["isProviderDealership"] == null ? null : json["isProviderDealership"], - isProviderIndividual: json["isProviderIndividual"] == null ? null : json["isProviderIndividual"], - isDealershipUser: json["isDealershipUser"] == null ? null : json["isDealershipUser"], - providerId: json["providerID"], - customerId: json["customerID"], - dealershipId: json["dealershipID"], - ); + id: json["id"] == null ? null : json["id"], + userId: json["userID"] == null ? null : json["userID"], + firstName: json["firstName"], + lastName: json["lastName"], + mobileNo: json["mobileNo"] == null ? null : json["mobileNo"], + email: json["email"] == null ? null : json["email"], + userImageUrl: json["userImageUrl"], + roleId: json["roleID"] == null ? null : json["roleID"], + roleName: json["roleName"], + isEmailVerified: json["isEmailVerified"] == null ? null : json["isEmailVerified"], + serviceProviderBranch: json["serviceProviderBranch"] == null ? null : List.from(json["serviceProviderBranch"].map((x) => x)), + isVerified: json["isVerified"] == null ? null : json["isVerified"], + userRoles: json["userRoles"] == null ? null : List.from(json["userRoles"].map((x) => x)), + isCustomer: json["isCustomer"] == null ? null : json["isCustomer"], + isProviderDealership: json["isProviderDealership"] == null ? null : json["isProviderDealership"], + isProviderIndividual: json["isProviderIndividual"] == null ? null : json["isProviderIndividual"], + isDealershipUser: json["isDealershipUser"] == null ? null : json["isDealershipUser"], + providerId: json["providerID"], + customerId: json["customerID"], + dealershipId: json["dealershipID"], + isNeedToPassToken: false, + ); Map toJson() => { - "id": id == null ? null : id, - "userID": userId == null ? null : userId, - "firstName": firstName, - "lastName": lastName, - "mobileNo": mobileNo == null ? null : mobileNo, - "email": email == null ? null : email, - "userImageUrl": userImageUrl, - "roleID": roleId == null ? null : roleId, - "roleName": roleName, - "isEmailVerified": isEmailVerified == null ? null : isEmailVerified, - "serviceProviderBranch": serviceProviderBranch == null ? null : List.from(serviceProviderBranch!.map((x) => x)), - "isVerified": isVerified == null ? null : isVerified, - "userRoles": userRoles == null ? null : List.from(userRoles!.map((x) => x)), - "isCustomer": isCustomer == null ? null : isCustomer, - "isProviderDealership": isProviderDealership == null ? null : isProviderDealership, - "isProviderIndividual": isProviderIndividual == null ? null : isProviderIndividual, - "isDealershipUser": isDealershipUser == null ? null : isDealershipUser, - "providerID": providerId, - "customerID": customerId, - "dealershipID": dealershipId, - }; + "id": id == null ? null : id, + "userID": userId == null ? null : userId, + "firstName": firstName, + "lastName": lastName, + "mobileNo": mobileNo == null ? null : mobileNo, + "email": email == null ? null : email, + "userImageUrl": userImageUrl, + "roleID": roleId == null ? null : roleId, + "roleName": roleName, + "isEmailVerified": isEmailVerified == null ? null : isEmailVerified, + "serviceProviderBranch": serviceProviderBranch == null ? null : List.from(serviceProviderBranch!.map((x) => x)), + "isVerified": isVerified == null ? null : isVerified, + "userRoles": userRoles == null ? null : List.from(userRoles!.map((x) => x)), + "isCustomer": isCustomer == null ? null : isCustomer, + "isProviderDealership": isProviderDealership == null ? null : isProviderDealership, + "isProviderIndividual": isProviderIndividual == null ? null : isProviderIndividual, + "isDealershipUser": isDealershipUser == null ? null : isDealershipUser, + "providerID": providerId, + "customerID": customerId, + "dealershipID": dealershipId, + }; } diff --git a/lib/models/user/user.dart b/lib/models/user/user.dart index f1f0ee7..2d2b83c 100644 --- a/lib/models/user/user.dart +++ b/lib/models/user/user.dart @@ -4,6 +4,9 @@ import 'dart:convert'; +import '../../classes/app_state.dart'; +import '../../utils/enums.dart'; + User userFromJson(String str) => User.fromJson(json.decode(str)); String userToJson(User data) => json.encode(data.toJson()); @@ -22,18 +25,18 @@ class User { String? message; factory User.fromJson(Map json) => User( - totalItemsCount: json["totalItemsCount"], - data: json["data"] == null ? null : UserData.fromJson(json["data"]), - messageStatus: json["messageStatus"] == null ? null : json["messageStatus"], - message: json["message"] == null ? null : json["message"], - ); + totalItemsCount: json["totalItemsCount"], + data: json["data"] == null ? null : UserData.fromJson(json["data"]), + messageStatus: json["messageStatus"], + message: json["message"], + ); Map toJson() => { - "totalItemsCount": totalItemsCount, - "data": data == null ? null : data!.toJson(), - "messageStatus": messageStatus == null ? null : messageStatus, - "message": message == null ? null : message, - }; + "totalItemsCount": totalItemsCount, + "data": data == null ? null : data!.toJson(), + "messageStatus": messageStatus, + "message": message, + }; } class UserData { @@ -50,18 +53,18 @@ class UserData { UserInfo? userInfo; factory UserData.fromJson(Map json) => UserData( - accessToken: json["accessToken"] == null ? null : json["accessToken"], - refreshToken: json["refreshToken"] == null ? null : json["refreshToken"], - expiryDate: json["expiryDate"] == null ? null : DateTime.parse(json["expiryDate"]), - userInfo: json["userInfo"] == null ? null : UserInfo.fromJson(json["userInfo"]), - ); + accessToken: json["accessToken"], + refreshToken: json["refreshToken"], + expiryDate: json["expiryDate"] == null ? null : DateTime.parse(json["expiryDate"]), + userInfo: json["userInfo"] == null ? null : UserInfo.fromJson(json["userInfo"]), + ); Map toJson() => { - "accessToken": accessToken == null ? null : accessToken, - "refreshToken": refreshToken == null ? null : refreshToken, - "expiryDate": expiryDate == null ? null : expiryDate!.toIso8601String(), - "userInfo": userInfo == null ? null : userInfo!.toJson(), - }; + "accessToken": accessToken, + "refreshToken": refreshToken, + "expiryDate": expiryDate == null ? null : expiryDate!.toIso8601String(), + "userInfo": userInfo == null ? null : userInfo!.toJson(), + }; } class UserInfo { @@ -107,47 +110,76 @@ class UserInfo { int? customerId; dynamic dealershipId; - factory UserInfo.fromJson(Map json) => UserInfo( - id: json["id"] == null ? null : json["id"], - userId: json["userID"] == null ? null : json["userID"], - firstName: json["firstName"] == null ? null : json["firstName"], - lastName: json["lastName"] == null ? null : json["lastName"], - mobileNo: json["mobileNo"] == null ? null : json["mobileNo"], - email: json["email"] == null ? null : json["email"], - userImageUrl: json["userImageUrl"], - roleId: json["roleID"] == null ? null : json["roleID"], - roleName: json["roleName"] == null ? null : json["roleName"], - isEmailVerified: json["isEmailVerified"] == null ? null : json["isEmailVerified"], - serviceProviderBranch: json["serviceProviderBranch"] == null ? null : List.from(json["serviceProviderBranch"].map((x) => x)), - isVerified: json["isVerified"] == null ? null : json["isVerified"], - userRoles: json["userRoles"] == null ? null : List.from(json["userRoles"].map((x) => x)), - isCustomer: json["isCustomer"] == null ? null : json["isCustomer"], - isProviderDealership: json["isProviderDealership"] == null ? null : json["isProviderDealership"], - isDealershipUser: json["isDealershipUser"] == null ? null : json["isDealershipUser"], - providerId: json["providerID"], - customerId: json["customerID"] == null ? null : json["customerID"], - dealershipId: json["dealershipID"], - ); + UserInfo.fromJson(Map json) { + if (json["roleID"] == 5) { + AppState().userType = UserType.providerDealer; + } else if (json["roleID"] == 6) { + AppState().userType = UserType.providerIndividual; + } else { + AppState().userType = UserType.customer; + } + id = json["id"]; + userId = json["userID"]; + firstName = json["firstName"]; + lastName = json["lastName"]; + mobileNo = json["mobileNo"]; + email = json["email"]; + userImageUrl = json["userImageUrl"]; + roleId = json["roleID"]; + roleName = json["roleName"]; + isEmailVerified = json["isEmailVerified"]; + serviceProviderBranch = json["serviceProviderBranch"] == null ? null : List.from(json["serviceProviderBranch"].map((x) => x)); + isVerified = json["isVerified"]; + userRoles = json["userRoles"] == null ? null : List.from(json["userRoles"].map((x) => x)); + isCustomer = json["isCustomer"]; + isProviderDealership = json["isProviderDealership"]; + isDealershipUser = json["isDealershipUser"]; + providerId = json["providerID"]; + customerId = json["customerID"]; + dealershipId = json["dealershipID"]; + } + + // factory UserInfo.fromJson(Map json) => UserInfo( + // id: json["id"], + // userId: json["userID"], + // firstName: json["firstName"], + // lastName: json["lastName"], + // mobileNo: json["mobileNo"], + // email: json["email"], + // userImageUrl: json["userImageUrl"], + // roleId: json["roleID"], + // roleName: json["roleName"], + // isEmailVerified: json["isEmailVerified"], + // serviceProviderBranch: json["serviceProviderBranch"] == null ? null : List.from(json["serviceProviderBranch"].map((x) => x)), + // isVerified: json["isVerified"], + // userRoles: json["userRoles"] == null ? null : List.from(json["userRoles"].map((x) => x)), + // isCustomer: json["isCustomer"], + // isProviderDealership: json["isProviderDealership"], + // isDealershipUser: json["isDealershipUser"], + // providerId: json["providerID"], + // customerId: json["customerID"], + // dealershipId: json["dealershipID"], + // ); Map toJson() => { - "id": id == null ? null : id, - "userID": userId == null ? null : userId, - "firstName": firstName == null ? null : firstName, - "lastName": lastName == null ? null : lastName, - "mobileNo": mobileNo == null ? null : mobileNo, - "email": email == null ? null : email, - "userImageUrl": userImageUrl, - "roleID": roleId == null ? null : roleId, - "roleName": roleName == null ? null : roleName, - "isEmailVerified": isEmailVerified == null ? null : isEmailVerified, - "serviceProviderBranch": serviceProviderBranch == null ? null : List.from(serviceProviderBranch!.map((x) => x)), - "isVerified": isVerified == null ? null : isVerified, - "userRoles": userRoles == null ? null : List.from(userRoles!.map((x) => x)), - "isCustomer": isCustomer == null ? null : isCustomer, - "isProviderDealership": isProviderDealership == null ? null : isProviderDealership, - "isDealershipUser": isDealershipUser == null ? null : isDealershipUser, - "providerID": providerId, - "customerID": customerId == null ? null : customerId, - "dealershipID": dealershipId, - }; + "id": id, + "userID": userId, + "firstName": firstName, + "lastName": lastName, + "mobileNo": mobileNo, + "email": email, + "userImageUrl": userImageUrl, + "roleID": roleId, + "roleName": roleName, + "isEmailVerified": isEmailVerified, + "serviceProviderBranch": serviceProviderBranch == null ? null : List.from(serviceProviderBranch!.map((x) => x)), + "isVerified": isVerified, + "userRoles": userRoles == null ? null : List.from(userRoles!.map((x) => x)), + "isCustomer": isCustomer, + "isProviderDealership": isProviderDealership, + "isDealershipUser": isDealershipUser, + "providerID": providerId, + "customerID": customerId, + "dealershipID": dealershipId, + }; } diff --git a/lib/repositories/user_repo.dart b/lib/repositories/user_repo.dart index 278cf92..1a5b2b1 100644 --- a/lib/repositories/user_repo.dart +++ b/lib/repositories/user_repo.dart @@ -27,11 +27,11 @@ import 'package:mc_common_app/models/user/verify_email.dart'; import 'package:mc_common_app/utils/shared_prefrence.dart'; abstract class UserRepo { - Future basicOtp(String phoneNo, {int otpType = 1, int roleId = 4, int countryId = 1}); + Future basicOtp(String phoneNo, {int otpType = 1, int roleId = 4, int countryId = 1, bool isNeedToPassToken = false}); - Future basicVerify(String phoneNo, String otp, String userToken); + Future basicVerify(String phoneNo, String otp, String userToken, {bool isNeedToPassToken = false}); - Future basicComplete(String userId, String firstName, String lastName, String email, String password); + Future basicComplete(String userId, String firstName, String lastName, String email, String password, {bool isNeedToPassToken = false}); Future loginV1(String phoneNo, String password); @@ -76,31 +76,45 @@ abstract class UserRepo { class UserRepoImp implements UserRepo { @override - Future basicOtp(String phoneNo, {int otpType = 1, int roleId = 4, int countryId = 1}) async { + Future basicOtp(String phoneNo, {int otpType = 1, int roleId = 4, int countryId = 1, bool isNeedToPassToken = false}) async { var postParams = {"countryID": countryId, "userMobileNo": phoneNo, "otpType": otpType, "userRole": roleId}; - return await injector.get().postJsonForObject((json) => BasicOtpRespModel.fromJson(json), ApiConsts.BasicOTP, postParams); + String? t; + if (isNeedToPassToken) { + t = AppState().getUser.data!.accessToken ?? ""; + debugPrint("token " + t); + } + return await injector.get().postJsonForObject((json) => BasicOtpRespModel.fromJson(json), ApiConsts.BasicOTP, postParams, token: t); } @override - Future basicVerify(String phoneNo, String otp, String userToken) async { + Future basicVerify(String phoneNo, String otp, String userToken, {bool isNeedToPassToken = false}) async { var postParams = { "userMobileNo": phoneNo, "userOTP": otp, "userToken": userToken, }; - return await injector.get().postJsonForObject((json) => RegisterUserRespModel.fromJson(json), ApiConsts.BasicVerify, postParams); + String? t; + if (isNeedToPassToken) { + t = AppState().getUser.data!.accessToken ?? ""; + debugPrint("token " + t); + } + return await injector.get().postJsonForObject((json) => RegisterUserRespModel.fromJson(json), ApiConsts.BasicVerify, postParams, token: t); } @override - Future basicComplete(String userId, String firstName, String lastName, String email, String password) async { + Future basicComplete(String userId, String firstName, String lastName, String email, String password, {bool isNeedToPassToken = false}) async { Map postParams; if (email.isEmpty) { postParams = {"userID": userId, "firstName": firstName, "lastName": lastName, "companyName": "string", "isEmailVerified": true, "password": password}; } else { postParams = {"userID": userId, "firstName": firstName, "lastName": lastName, "email": email, "companyName": "string", "isEmailVerified": true, "password": password}; } - - return await injector.get().postJsonForObject((json) => RegisterUserRespModel.fromJson(json), ApiConsts.BasicComplete, postParams); + String? t; + if (isNeedToPassToken) { + t = AppState().getUser.data!.accessToken ?? ""; + debugPrint("token " + t); + } + return await injector.get().postJsonForObject((json) => RegisterUserRespModel.fromJson(json), ApiConsts.BasicComplete, postParams, token: t); } @override @@ -285,6 +299,7 @@ class UserRepoImp implements UserRepo { UserInfo info = UserInfo.fromJson(jsonDecode(mdata)); User user = User(); user.data = UserData(accessToken: refresh.data!.accessToken ?? "", refreshToken: refresh.data!.refreshToken ?? "", userInfo: info); + AppState().setUser = user; return refresh.data!.accessToken ?? ""; } diff --git a/lib/utils/enums.dart b/lib/utils/enums.dart index dc9e841..1f7d838 100644 --- a/lib/utils/enums.dart +++ b/lib/utils/enums.dart @@ -5,6 +5,12 @@ // unverified, // } +enum UserType { + providerDealer, + providerIndividual, + customer, +} + enum AdPostStatus { pendingForReview, pendingForPayment, diff --git a/lib/utils/navigator.dart b/lib/utils/navigator.dart index f8bc636..d59f386 100644 --- a/lib/utils/navigator.dart +++ b/lib/utils/navigator.dart @@ -4,8 +4,8 @@ navigateWithName(BuildContext context, String routeName, {Object? arguments}) { Navigator.pushNamed(context, routeName, arguments: arguments); } -navigateReplaceWithName(BuildContext context, String routeName, {Object? arguments}) { - Navigator.pushReplacementNamed(context, routeName, arguments: arguments); +Future navigateReplaceWithName(BuildContext context, String routeName, {Object? arguments}) async { + await Navigator.pushReplacementNamed(context, routeName, arguments: arguments); } navigateReplaceWithNameUntilRoute(BuildContext context, String routeName, {Object? arguments}) { diff --git a/lib/view_models/user_view_model.dart b/lib/view_models/user_view_model.dart index dbf6362..6bf41a5 100644 --- a/lib/view_models/user_view_model.dart +++ b/lib/view_models/user_view_model.dart @@ -142,19 +142,26 @@ class UserVM extends BaseVM { } } - Future performCompleteProfile( - BuildContext context, { + Future performCompleteProfile(BuildContext context, { required String password, required String confirmPassword, required String firstName, required String lastName, required String email, required String? userId, + bool isNeedToPassToken = false, }) async { if (Utils.passwordValidateStructure(password)) { if (password == confirmPassword) { Utils.showLoading(context); - RegisterUserRespModel user = await userRepo.basicComplete(userId ?? "", firstName, lastName, email, password); + RegisterUserRespModel user = await userRepo.basicComplete( + userId ?? "", + firstName, + lastName, + email, + password, + isNeedToPassToken: isNeedToPassToken, + ); Utils.hideLoading(context); if (user.messageStatus == 1) { Utils.showToast(LocaleKeys.successfullyRegistered.tr()); @@ -334,7 +341,6 @@ class UserVM extends BaseVM { RegisterUserRespModel verifiedUser = RegisterUserRespModel.fromJson(jsonDecode(response2.body)); if (verifiedUser.messageStatus == 1) { User user = User.fromJson(jsonDecode(response2.body)); - if (appType == AppType.provider) { if (user.data!.userInfo!.roleId == 5 || user.data!.userInfo!.roleId == 6) { AppState().setUser = user; @@ -466,20 +472,33 @@ class UserVM extends BaseVM { return await userRepo.getAllCountries(); } - Future performBasicOtpRegisterPage(BuildContext context, {required String countryCode, required String phoneNum, required int role}) async { + Future performBasicOtpRegisterPage(BuildContext context, + {required String countryCode, required String phoneNum, required int role, bool isNeedToPassToken = false, VoidCallback? reloadPage}) async { Utils.showLoading(context); - BasicOtpRespModel basicOtp = await userRepo.basicOtp(countryCode + phoneNum, roleId: role); + BasicOtpRespModel basicOtp = await userRepo.basicOtp(countryCode + phoneNum, roleId: role, isNeedToPassToken: isNeedToPassToken); Utils.hideLoading(context); if (basicOtp.messageStatus == 1) { showMDialog(context, child: OtpDialog( onClick: (String code) async { - pop(context); + if (reloadPage == null) + pop(context); Utils.showLoading(context); - RegisterUserRespModel user = await userRepo.basicVerify(countryCode + phoneNum, code, basicOtp.data!.userToken ?? ""); + RegisterUserRespModel user = await userRepo.basicVerify( + countryCode + phoneNum, + code, + basicOtp.data!.userToken ?? "", + isNeedToPassToken: isNeedToPassToken, + ); Utils.hideLoading(context); if (user.messageStatus == 1) { Utils.showToast(user.message ?? ""); - navigateReplaceWithName(context, AppRoutes.completeProfile, arguments: user); + user.data!.roleId = role; + user.data!.isNeedToPassToken = isNeedToPassToken; + navigateReplaceWithName(context, AppRoutes.completeProfile, arguments: user).then((value) { + if (reloadPage != null) { + reloadPage(); + } + }); } else { Utils.showToast(user.message ?? ""); } diff --git a/lib/views/user/complete_profile_page.dart b/lib/views/user/complete_profile_page.dart index af11e10..db5b30d 100644 --- a/lib/views/user/complete_profile_page.dart +++ b/lib/views/user/complete_profile_page.dart @@ -35,8 +35,9 @@ class _CompleteProfilePageState extends State { @override Widget build(BuildContext context) { return Scaffold( - appBar: CustomAppBar( isRemoveBackButton: true, - title: LocaleKeys.signUp.tr(), + appBar: CustomAppBar( + isRemoveBackButton: widget.user.data!.roleId == 7 ? false : true, + title: widget.user.data!.roleId == 7 ? "" : LocaleKeys.signUp.tr(), ), body: SizedBox( width: double.infinity, @@ -47,7 +48,11 @@ class _CompleteProfilePageState extends State { child: Column( children: [ 6.height, - LocaleKeys.completeProfile.tr().toText(height: 23 / 24, fontSize: 24, letterSpacing: -1.44,), + LocaleKeys.completeProfile.tr().toText( + height: 23 / 24, + fontSize: 24, + letterSpacing: -1.44, + ), 12.height, Padding( padding: const EdgeInsets.symmetric(horizontal: 20), @@ -55,7 +60,7 @@ class _CompleteProfilePageState extends State { color: MyColors.lightTextColor, textAlign: TextAlign.center, fontSize: 14, - height: 23 / 24, + height: 23 / 24, letterSpacing: -0.48, ), ), @@ -139,7 +144,12 @@ class _CompleteProfilePageState extends State { title: LocaleKeys.save.tr(), maxWidth: double.infinity, onPressed: () { - bool validateStatus = userVM.dataValidation(password: password, firstName: firstName, lastName: lastName, email: email); + bool validateStatus = userVM.dataValidation( + password: password, + firstName: firstName, + lastName: lastName, + email: email, + ); if (validateStatus) { userVM.performCompleteProfile( context, @@ -149,6 +159,7 @@ class _CompleteProfilePageState extends State { lastName: lastName!, email: email!, userId: widget.user.data!.userId ?? "", + isNeedToPassToken: widget.user.data!.isNeedToPassToken, ); } }), diff --git a/lib/widgets/bottom_sheet.dart b/lib/widgets/bottom_sheet.dart index b4a8b80..cd920ad 100644 --- a/lib/widgets/bottom_sheet.dart +++ b/lib/widgets/bottom_sheet.dart @@ -1,10 +1,11 @@ import 'package:flutter/material.dart'; import 'package:mc_common_app/extensions/int_extensions.dart'; -void showMyBottomSheet(BuildContext context, {required Widget child, VoidCallback? callBackFunc}) { +void showMyBottomSheet(BuildContext context, {bool isDismissible = true, required Widget child, VoidCallback? callBackFunc}) { showModalBottomSheet( context: context, isScrollControlled: true, + isDismissible: isDismissible, backgroundColor: Colors.transparent, builder: (BuildContext context) { return Container( @@ -40,9 +41,10 @@ void showMyBottomSheet(BuildContext context, {required Widget child, VoidCallbac ).then((value) { // print("BACK FROM DELEGATE!!!!"); // print("value: $value"); - if (value == "delegate_reload") { - if (callBackFunc != null) callBackFunc(); - } + // if (value == "delegate_reload") { + // if (callBackFunc != null) callBackFunc(); + // } + if (callBackFunc != null) callBackFunc(); }); } diff --git a/lib/widgets/extensions/extensions_widget.dart b/lib/widgets/extensions/extensions_widget.dart index ab7487b..e5fb5db 100644 --- a/lib/widgets/extensions/extensions_widget.dart +++ b/lib/widgets/extensions/extensions_widget.dart @@ -23,12 +23,13 @@ extension ExtendedText on Widget { } extension ContainerExt on Widget { - Widget toWhiteContainer({required double width, double? allPading, EdgeInsets? pading, EdgeInsets? margin, VoidCallback? onTap, Color? backgroundColor}) { + Widget toWhiteContainer({required double width, double? allPading, EdgeInsets? pading, EdgeInsets? margin, VoidCallback? onTap, Color? backgroundColor, double borderRadius = 0}) { return InkWell( onTap: onTap, child: Container( decoration: BoxDecoration( color: backgroundColor ?? MyColors.white, + borderRadius: BorderRadius.circular(borderRadius), boxShadow: const [ BoxShadow( blurRadius: 8, @@ -75,12 +76,12 @@ extension ContainerExt on Widget { boxShadow: !isShadowEnabled ? null : [ - BoxShadow( - color: const Color(0xff000000).withOpacity(.05), - blurRadius: 26, - offset: const Offset(0, -3), - ), - ], + BoxShadow( + color: const Color(0xff000000).withOpacity(.05), + blurRadius: 26, + offset: const Offset(0, -3), + ), + ], ), padding: padding ?? EdgeInsets.all(paddingAll), margin: margin ?? EdgeInsets.all(marginAll), @@ -354,5 +355,3 @@ extension LocaleSetup on MultiProvider { extension WidgetExtensions on Widget { Widget onPress(VoidCallback onTap) => InkWell(onTap: onTap, child: this); } - -