diff --git a/assets/langs/ar-SA.json b/assets/langs/ar-SA.json index 24c5b32..01b8045 100644 --- a/assets/langs/ar-SA.json +++ b/assets/langs/ar-SA.json @@ -708,7 +708,7 @@ "updateUserDetails": "تحديث تفاصيل المستخدم", "enterNewFirstName": "أدخل الاسم الأول", "enterNewLastName": "أدخل الاسم الأخير", - "userDetailsUpdated": "يتم تحديث تفاصيل المستخدم" + "userDetailsUpdated": "يتم تحديث تفاصيل المستخدم", "itemNoLongerAvailable": "لم يعد هذا العنصر متاحًا.", "reactivateAd": "إعادة تنشيط الإعلان", "dealOutsideApp": "تمت الصفقة خارج التطبيق مع عميل آخر.", diff --git a/assets/langs/en-US.json b/assets/langs/en-US.json index 3eb6430..65c26db 100644 --- a/assets/langs/en-US.json +++ b/assets/langs/en-US.json @@ -738,8 +738,7 @@ "blockedByAdmin": "Blocked by admin", "active": "Active", "paymentType": "Payment Type", - "searchByCreatedDate": "Search By Created Date" - "itemNoLongerAvailable": "This item is no longer available.", + "searchByCreatedDate": "Search By Created Date", "updateUserDetails": "Update User Details", "enterNewFirstName": "Enter First Name", "enterNewLastName": "Enter Last Name", diff --git a/lib/classes/consts.dart b/lib/classes/consts.dart index 2ae3e1d..a7a73f3 100644 --- a/lib/classes/consts.dart +++ b/lib/classes/consts.dart @@ -39,6 +39,7 @@ class ApiConsts { static String logoutUser = "${baseUrlServices}api/Account/Logout"; static String updateUserImage = "${baseUrlServices}api/User_UpdateProfileImage"; static String getUserImage = "${baseUrlServices}api/ProfileImage"; + static String userUpdate = "${baseUrlServices}api/User_Update"; static String providerComplaintCreate = "${baseUrlServices}api/ServiceProviders/ProviderComplaint_Create"; //Profile diff --git a/lib/config/routes.dart b/lib/config/routes.dart index 4af01bf..d23a216 100644 --- a/lib/config/routes.dart +++ b/lib/config/routes.dart @@ -44,6 +44,7 @@ import 'package:mc_common_app/views/user/register_page.dart'; import 'package:mc_common_app/views/user/register_provider_page.dart'; import 'package:mc_common_app/views/user/register_selection_page.dart'; import 'package:mc_common_app/views/splash/splash_page.dart'; +import 'package:mc_common_app/views/user/update_user_city_country.dart'; import 'package:mc_common_app/views/user/update_user_details.dart'; import 'package:mc_common_app/views/user/vertify_password_page.dart'; import 'package:flutter/material.dart'; @@ -170,6 +171,7 @@ class AppRoutes { //Chat static const String chatView = "/chatView"; static const String updateUserDetails = "/updateUserDetails"; + static const String updateUserCity = "/updateUserCity"; static const String initialRoute = splash; static final Map routes = { @@ -190,6 +192,7 @@ class AppRoutes { changeMobilePage: (context) => ChangeMobilePage(), changeEmailPage: (context) => const ChangeEmailPage(), updateUserDetails: (context) => const UpdateUserDetails(), + updateUserCity: (context) => const UpdateUserCityCountry(), changePassword: (context) => const ChangePasswordPage(), editAccountPage: (context) => const EditAccountPage(), profileView: (context) => const ProfileScreen(), diff --git a/lib/generated/codegen_loader.g.dart b/lib/generated/codegen_loader.g.dart index 5a4d936..94e96d1 100644 --- a/lib/generated/codegen_loader.g.dart +++ b/lib/generated/codegen_loader.g.dart @@ -721,11 +721,11 @@ class CodegenLoader extends AssetLoader{ "customerLocation": "موقع العميل", "deliveryAvailable": "التوصيل متاح", "viewed": "تم المشاهدة", - "itemNoLongerAvailable": "لم يعد هذا العنصر متاحًا.", "updateUserDetails": "تحديث تفاصيل المستخدم", "enterNewFirstName": "أدخل الاسم الأول", "enterNewLastName": "أدخل الاسم الأخير", "userDetailsUpdated": "يتم تحديث تفاصيل المستخدم", + "itemNoLongerAvailable": "لم يعد هذا العنصر متاحًا.", "reactivateAd": "إعادة تنشيط الإعلان", "dealOutsideApp": "تمت الصفقة خارج التطبيق مع عميل آخر.", "noAgreementCustomer": "لا يوجد اتفاق من جانب العميل.", @@ -1390,7 +1390,7 @@ static const Map en_US = { "priceRange": "Price Range", "cancelOffer": "Cancel Offer", "pleaseSpecify": "Please Specify", - "customerNotResponding": "Customer Not Responding", + "customerNotResponding": "The customer is not responding.", "cancelRequestPrompt": "Do you want to cancel this request?", "requestPermanentlyCancelled": "Your request will be permanently cancelled. You cannot undo this action.", "awaitingResponseFromCustomer": "Awaiting Response From Customer", @@ -1410,7 +1410,7 @@ static const Map en_US = { "customerCarePrompt": "Got any question? We are here to service. Click here to talk to our customer care right now.", "callNow": "Call Now", "condition": "Condition", - "servicesNotAvailableHomeLocation": "Some services are not available on home location.", + "servicesNotAvailableHomeLocation": "This location will be same for all services", "additionalChargesNotice": "These charges are additional to the actual service charges. For heavy items the charges may vary.", "selectServiceLocation": "Select Service Location", "apptOn": "Appt On", @@ -1467,10 +1467,6 @@ static const Map en_US = { "deliveryAvailable": "Delivery Available", "viewed": "Viewed", "itemNoLongerAvailable": "This item is no longer available.", - "updateUserDetails": "Update User Details", - "enterNewFirstName": "Enter First Name", - "enterNewLastName": "Enter Last Name", - "userDetailsUpdated": "User Details is Updated" "reactivateAd": "Reactivate Ad", "dealOutsideApp": "The deal was done outside the app with another customer.", "noAgreementCustomer": "There is no agreement from the customer side.", @@ -1506,7 +1502,11 @@ static const Map en_US = { "blockedByAdmin": "Blocked by admin", "active": "Active", "paymentType": "Payment Type", - "searchByCreatedDate": "Search By Created Date" + "searchByCreatedDate": "Search By Created Date", + "updateUserDetails": "Update User Details", + "enterNewFirstName": "Enter First Name", + "enterNewLastName": "Enter Last Name", + "userDetailsUpdated": "User Details is Updated" }; static const Map> mapLocales = {"ar_SA": ar_SA, "en_US": en_US}; } diff --git a/lib/models/user_models/user.dart b/lib/models/user_models/user.dart index c8c055b..659edaf 100644 --- a/lib/models/user_models/user.dart +++ b/lib/models/user_models/user.dart @@ -25,14 +25,16 @@ class User { int? messageStatus; String? message; - factory User.fromJson(Map json) => User( + factory User.fromJson(Map json) => + User( totalItemsCount: json["totalItemsCount"], data: json["data"] == null ? null : UserData.fromJson(json["data"]), messageStatus: json["messageStatus"], message: json["message"], ); - Map toJson() => { + Map toJson() => + { "totalItemsCount": totalItemsCount, "data": data?.toJson(), "messageStatus": messageStatus, @@ -53,14 +55,16 @@ class UserData { DateTime? expiryDate; UserInfo? userInfo; - factory UserData.fromJson(Map json) => UserData( + factory UserData.fromJson(Map json) => + UserData( 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() => { + Map toJson() => + { "accessToken": accessToken, "refreshToken": refreshToken, "expiryDate": expiryDate?.toIso8601String(), @@ -69,34 +73,38 @@ class UserData { } class UserInfo { - UserInfo( - {this.id, - this.userId, - this.firstName, - this.lastName, - this.mobileNo, - this.email, - this.userImageUrl, - this.roleId, - this.roleName, - this.isEmailVerified, - this.serviceProviderBranch, - this.isVerified, - this.userRoles, - this.isCustomer, - this.isProviderDealership, - this.isDealershipUser, - this.providerId, - this.customerId, - this.countryId, - this.cityId, - this.dealershipId, - this.userLocalImage}); + UserInfo({this.id, + this.userId, + this.firstName, + this.lastName, + this.mobileNo, + this.email, + this.userImageUrl, + this.roleId, + this.roleName, + this.isEmailVerified, + this.serviceProviderBranch, + this.isVerified, + this.userRoles, + this.isCustomer, + this.isProviderDealership, + this.isDealershipUser, + this.providerId, + this.customerId, + this.countryId, + this.cityId, + this.dealershipId, + this.userLocalImage, + this.cityName, + this.countryName, + }); int? id; String? userId; String? firstName; String? lastName; + String? countryName; + String? cityName; String? mobileNo; String? email; dynamic userImageUrl; @@ -130,6 +138,8 @@ class UserInfo { userId = json["userID"]; firstName = json["firstName"]; lastName = json["lastName"]; + cityName = json["cityName"]; + countryName = json["countryName"]; mobileNo = json["mobileNo"]; email = json["email"]; userImageUrl = json["userImageUrl"]; @@ -172,11 +182,14 @@ class UserInfo { // dealershipId: json["dealershipID"], // ); - Map toJson() => { + Map toJson() => + { "id": id, "userID": userId, "firstName": firstName, "lastName": lastName, + "countryName": countryName, + "cityName": cityName, "mobileNo": mobileNo, "email": email, "userImageUrl": userImageUrl, diff --git a/lib/repositories/user_repo.dart b/lib/repositories/user_repo.dart index 571549c..9ce6d57 100644 --- a/lib/repositories/user_repo.dart +++ b/lib/repositories/user_repo.dart @@ -55,7 +55,7 @@ abstract class UserRepo { Future changePassword(String currentPassword, String newPassword); - Future> updateUserInfo(String firstName, String lastName); + Future> updateUserInfo(String firstName, String lastName, String? city); Future changeMobileNoOTPRequest(countryID, String mobileNo, String password); @@ -166,6 +166,11 @@ class UserRepoImp implements UserRepo { return await injector.get().getJsonForObject((json) => Country.fromJson(json), ApiConsts.getAllCountry); } + // @override + // Future getAllCountriesForUser() async { + // return await injector.get().getJsonForObject((json) => Country.fromJson(json), ApiConsts.getAllCountry); + // } + @override Future getAllCites(String countryId) async { var postParams = { @@ -257,8 +262,8 @@ class UserRepoImp implements UserRepo { } @override - Future> updateUserInfo(String firstName, String lastName) async { - var postParams = {"userID": "${AppState().getUser.data!.userInfo!.userId}", "firstName": "${firstName}", "lastName": "${lastName}", "genderID": 1, "cityID": 1}; + Future> updateUserInfo(String firstName, String lastName, String? city) async { + var postParams = {"userID": "${AppState().getUser.data!.userInfo!.userId}", "firstName": "${firstName}", "lastName": "${lastName}", "genderID": 1, "cityID": city ?? 1}; String t = AppState().getUser.data!.accessToken ?? ""; return await injector.get().postJsonForObject((json) => json, ApiConsts.userUpdate, postParams, token: t); } diff --git a/lib/view_models/subscriptions_view_model.dart b/lib/view_models/subscriptions_view_model.dart index aa57cc1..21a87de 100644 --- a/lib/view_models/subscriptions_view_model.dart +++ b/lib/view_models/subscriptions_view_model.dart @@ -1,3 +1,4 @@ +import 'dart:convert'; import 'dart:developer'; import 'package:mc_common_app/classes/app_state.dart'; @@ -189,7 +190,9 @@ class SubscriptionsVM extends BaseVM { mySubscriptionsBySp.clear(); setState(ViewState.busy); // allSubscriptions.data + print("====================== SUB ============="); for (var element in allSubscriptions.data!) { + print("SuBBB "+ element.subscriptionType.toString()); if (element.subscriptionTypeEnum == SubscriptionTypeEnum.current) { mySubscriptionsBySp.add(element); } diff --git a/lib/view_models/user_view_model.dart b/lib/view_models/user_view_model.dart index 7c32ace..fd6cbee 100644 --- a/lib/view_models/user_view_model.dart +++ b/lib/view_models/user_view_model.dart @@ -18,6 +18,7 @@ import 'package:mc_common_app/models/subscriptions_models/subscription_model.dar import 'package:mc_common_app/models/user_models/basic_otp.dart'; import 'package:mc_common_app/models/user_models/change_email.dart'; import 'package:mc_common_app/models/user_models/change_mobile.dart'; +import 'package:mc_common_app/models/user_models/cities.dart'; import 'package:mc_common_app/models/user_models/confirm_email.dart'; import 'package:mc_common_app/models/user_models/confirm_mobile.dart'; import 'package:mc_common_app/models/user_models/confirm_password.dart'; @@ -63,6 +64,9 @@ class UserVM extends BaseVM { _loginOtherAccount = value; } + Country? userCountries; + Cities? userCities; + void updateCompleteProfilePageCheckbox(bool newValue) { completeProfilePageCheckbox = newValue; notifyListeners(); @@ -165,15 +169,17 @@ class UserVM extends BaseVM { } } - Future userDetailsUpdate(BuildContext context, String firstName, String lastName) async { + Future userDetailsUpdate(BuildContext context, String firstName, String lastName, String? city) async { Utils.showLoading(context); - Map res = await userRepo.updateUserInfo(firstName, lastName); + Map res = await userRepo.updateUserInfo(firstName, lastName, city); Utils.hideLoading(context); if (res["data"] != null && res["data"].isNotEmpty) { + print(res["data"]); User localUser = AppState().getUser; if (localUser.data != null) { localUser.data!.userInfo!.firstName = res["data"]["firstName"]; localUser.data!.userInfo!.lastName = res["data"]["lastName"]; + // localUser.data!.userInfo!.cityId = res["data"]["cityId"]; AppState().setUser = localUser; } Utils.showToast(LocaleKeys.userDetailsUpdated.tr()); @@ -572,6 +578,16 @@ class UserVM extends BaseVM { return await userRepo.getAllCountries(); } + Future getAllCountriesForUser() async { + userCountries = await userRepo.getAllCountries(); + notifyListeners(); + } + + Future getAllCitiesForUser(int countryId) async { + userCities = await userRepo.getAllCites(countryId.toString()); + notifyListeners(); + } + Future performBasicOtpRegisterPage(BuildContext context, {required String countryCode, required String phoneNum, required int role, bool isNeedToPassToken = false, VoidCallback? reloadPage}) async { Utils.showLoading(context); diff --git a/lib/views/profile/profile_view.dart b/lib/views/profile/profile_view.dart index 3684fa5..d555ad5 100644 --- a/lib/views/profile/profile_view.dart +++ b/lib/views/profile/profile_view.dart @@ -72,21 +72,21 @@ class _ProfileScreenState extends State { decoration: BoxDecoration( image: AppState().getUser.data!.userInfo!.userLocalImage != null ? DecorationImage( - image: FileImage(AppState().getUser.data!.userInfo!.userLocalImage!), - fit: BoxFit.cover, - ) + image: FileImage(AppState().getUser.data!.userInfo!.userLocalImage!), + fit: BoxFit.cover, + ) : AppState().getUser.data!.userInfo!.userImageUrl != null - ? DecorationImage( - image: CachedNetworkImageProvider( - AppState().getUser.data!.userInfo!.userImageUrl, - ), - fit: BoxFit.cover, - ) - : DecorationImage( - image: AssetImage( - MyAssets.icLogoWhitePng, - ), - ), + ? DecorationImage( + image: CachedNetworkImageProvider( + AppState().getUser.data!.userInfo!.userImageUrl, + ), + fit: BoxFit.cover, + ) + : DecorationImage( + image: AssetImage( + MyAssets.icLogoWhitePng, + ), + ), ), child: BackdropFilter( filter: ImageFilter.blur(sigmaX: 7.0, sigmaY: 7.0), @@ -111,7 +111,7 @@ class _ProfileScreenState extends State { children: [ "${AppState().getUser.data!.userInfo!.firstName} ${AppState().getUser.data!.userInfo!.lastName ?? ""}".toText(fontSize: 20).paddingOnly(left: 25, right: 10), MyAssets.icEdit.buildSvg(width: 15).onPress( - () async { + () async { Navigator.pushNamed(context, AppRoutes.updateUserDetails); }, ), @@ -131,11 +131,13 @@ class _ProfileScreenState extends State { ), ], CustomProfileOptionsTile( - titleText: LocaleKeys.country.tr(), - subtitleText: "Saudi Arabia", + titleText: LocaleKeys.city.tr(), + subtitleText: "${AppState().getUser.data!.userInfo!.cityName ?? ""}, ${AppState().getUser.data!.userInfo!.countryName ?? ""}", needBorderBelow: true, - needEditButton: false, - onTap: () {}, + needEditButton: true, + onTap: () { + Navigator.pushNamed(context, AppRoutes.updateUserCity); + }, ), CustomProfileOptionsTile( titleText: LocaleKeys.email.tr(), @@ -161,11 +163,7 @@ class _ProfileScreenState extends State { }, ), ], - ).toContainer(width: double.infinity, - isShadowEnabled: true, - paddingAll: 10, - margin: const EdgeInsets.fromLTRB(24, 20, 24, 0), - borderRadius: 0), + ).toContainer(width: double.infinity, isShadowEnabled: true, paddingAll: 10, margin: const EdgeInsets.fromLTRB(24, 20, 24, 0), borderRadius: 0), ], ), ), @@ -173,83 +171,69 @@ class _ProfileScreenState extends State { ], ), Positioned( - top: MediaQuery - .of(context) - .size - .height * 0.24, + top: MediaQuery.of(context).size.height * 0.24, child: Container( height: 100, alignment: Alignment.centerLeft, child: ClipOval( child: AppState().getUser.data!.userInfo!.userLocalImage != null ? Image.file( - AppState().getUser.data!.userInfo!.userLocalImage!, - width: 100, - height: 100, - fit: BoxFit.fill, - ) + AppState().getUser.data!.userInfo!.userLocalImage!, + width: 100, + height: 100, + fit: BoxFit.fill, + ) : CachedNetworkImage( - imageUrl: "${AppState().getUser.data!.userInfo!.userImageUrl}", - imageBuilder: (context, imageProvider) => - Container( - decoration: BoxDecoration( - image: DecorationImage( - image: imageProvider, - fit: BoxFit.cover, + imageUrl: "${AppState().getUser.data!.userInfo!.userImageUrl}", + imageBuilder: (context, imageProvider) => Container( + decoration: BoxDecoration( + image: DecorationImage( + image: imageProvider, + fit: BoxFit.cover, + ), ), ), + placeholder: (context, url) => const Center(child: CircularProgressIndicator()), + errorWidget: (context, url, error) => const Icon(Icons.error), + width: 100, + height: 100, + fit: BoxFit.fill, + fadeInCurve: Curves.easeIn, + fadeInDuration: const Duration(milliseconds: 1000), + useOldImageOnUrlChange: false, ), - placeholder: (context, url) => const Center(child: CircularProgressIndicator()), - errorWidget: (context, url, error) => const Icon(Icons.error), - width: 100, - height: 100, - fit: BoxFit.fill, - fadeInCurve: Curves.easeIn, - fadeInDuration: const Duration(milliseconds: 1000), - useOldImageOnUrlChange: false, - ), ), ).horPaddingMain(), ), Positioned( - top: MediaQuery - .of(context) - .size - .height * 0.30, - right: MediaQuery - .of(context) - .size - .height * 0.03, + top: MediaQuery.of(context).size.height * 0.30, + right: MediaQuery.of(context).size.height * 0.03, child: Container( height: 40, width: 40, padding: const EdgeInsets.all(8), decoration: BoxDecoration(color: MyColors.white, shape: BoxShape.circle, border: Border.all(color: MyColors.darkTextColor, width: 0.1)), - child: Center(child: MyAssets.icEdit.buildSvg(),), + child: Center( + child: MyAssets.icEdit.buildSvg(), + ), ).onPress( - () async { + () async { await model.updateUserImage(context); }, ), ), Positioned( - top: MediaQuery - .of(context) - .size - .height * 0.05, - left: MediaQuery - .of(context) - .size - .height * 0.03, + top: MediaQuery.of(context).size.height * 0.05, + left: MediaQuery.of(context).size.height * 0.03, child: const Icon(Icons.arrow_back_ios, color: Colors.black, size: 18) .toContainer( - padding: const EdgeInsets.only(left: 5), - borderRadius: 100, - borderColor: MyColors.lightGreyEFColor, - isEnabledBorder: true, - height: 40, - width: 40, - ) + padding: const EdgeInsets.only(left: 5), + borderRadius: 100, + borderColor: MyColors.lightGreyEFColor, + isEnabledBorder: true, + height: 40, + width: 40, + ) .onPress(() => pop(context))), ], ); diff --git a/lib/views/user/change_email_page.dart b/lib/views/user/change_email_page.dart index 1e2685a..d75d23c 100644 --- a/lib/views/user/change_email_page.dart +++ b/lib/views/user/change_email_page.dart @@ -41,12 +41,12 @@ class _ChangeEmailPageState extends State { padding: const EdgeInsets.all(20), child: Column( children: [ - LocaleKeys.enterEmail.tr().toText( - height: 23 / 24, - fontSize: 24, - letterSpacing: -1.44, - ), - 12.height, + // LocaleKeys.enterEmail.tr().toText( + // height: 23 / 24, + // fontSize: 24, + // letterSpacing: -1.44, + // ), + // 12.height, TxtField( hint: LocaleKeys.enterNewEmail.tr(), onChanged: (v) => email = v, diff --git a/lib/views/user/change_mobile_page.dart b/lib/views/user/change_mobile_page.dart index f74cef0..10a5808 100644 --- a/lib/views/user/change_mobile_page.dart +++ b/lib/views/user/change_mobile_page.dart @@ -39,12 +39,12 @@ class _ChangeMobilePageState extends State { padding: const EdgeInsets.all(20), child: Column( children: [ - LocaleKeys.enterNewPhoneNumber.tr().toText( - height: 23 / 24, - fontSize: 24, - letterSpacing: -1.44, - ), - 12.height, + // LocaleKeys.enterNewPhoneNumber.tr().toText( + // height: 23 / 24, + // fontSize: 24, + // letterSpacing: -1.44, + // ), + // 12.height, TxtField( hint: LocaleKeys.enterNewPhoneNumber.tr(), onChanged: (v) => mobileNo = v, diff --git a/lib/views/user/change_password_page.dart b/lib/views/user/change_password_page.dart index cea9f1e..7704885 100644 --- a/lib/views/user/change_password_page.dart +++ b/lib/views/user/change_password_page.dart @@ -39,12 +39,12 @@ class _ChangePasswordPageState extends State { padding: const EdgeInsets.all(20), child: Column( children: [ - LocaleKeys.enterNewPassword.tr().toText( - height: 23 / 24, - fontSize: 24, - letterSpacing: -1.44, - ), - 12.height, + // LocaleKeys.enterNewPassword.tr().toText( + // height: 23 / 24, + // fontSize: 24, + // letterSpacing: -1.44, + // ), + // 12.height, TxtField( hint: LocaleKeys.enterOldPassword.tr(), onChanged: (v) => currentPassword = v, diff --git a/lib/views/user/update_user_city_country.dart b/lib/views/user/update_user_city_country.dart new file mode 100644 index 0000000..0f36c8b --- /dev/null +++ b/lib/views/user/update_user_city_country.dart @@ -0,0 +1,105 @@ +import 'package:mc_common_app/classes/app_state.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/models/general_models/widgets_models.dart'; +import 'package:mc_common_app/view_models/ad_view_model.dart'; +import 'package:mc_common_app/view_models/user_view_model.dart'; +import 'package:mc_common_app/widgets/common_widgets/app_bar.dart'; +import 'package:mc_common_app/widgets/button/show_fill_button.dart'; +import 'package:mc_common_app/widgets/dropdown/dropdow_field.dart'; +import 'package:mc_common_app/widgets/txt_field.dart'; +import 'package:easy_localization/easy_localization.dart'; +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; + +class UpdateUserCityCountry extends StatefulWidget { + const UpdateUserCityCountry({Key? key}) : super(key: key); + + @override + State createState() => _UpdateUserCityCountryState(); +} + +class _UpdateUserCityCountryState extends State { + DropValue? city; + DropValue? country; + + @override + void initState() { + context.read().getAllCountriesForUser(); + super.initState(); + } + + @override + Widget build(BuildContext context) { + return Consumer(builder: (BuildContext context, UserVM uVM, Widget? child) { + return Scaffold( + appBar: CustomAppBar( + title: "Update City", + ), + body: Column( + children: [ + uVM.userCountries != null + ? Container( + padding: const EdgeInsets.only(right: 20, left: 20, top: 12), + child: Builder(builder: (context) { + List userCountryDrop = []; + for (var element in uVM.userCountries!.data!) { + if (AppState().getUser.data!.userInfo!.countryId == element.id) { + country = DropValue(element.id?.toInt() ?? 0, element.countryName ?? "", ""); + } + userCountryDrop.add(DropValue(element.id?.toInt() ?? 0, element.countryName ?? "", "")); + } + return DropdownField( + (DropValue value) async { + country = value; + await uVM.getAllCitiesForUser(country!.id); + setState(() {}); + }, + list: userCountryDrop, + dropdownValue: country != null && country != -1 ? DropValue(country!.id, country!.value, "") : null, + hint: country != null && country != -1 ? country!.value : "Country", + // errorValue: adVM.vehicleCountryId.errorValue, + ); + })) + : SizedBox(), + uVM.userCities != null + ? Container( + padding: const EdgeInsets.only(right: 20, left: 20, top: 12), + child: Builder(builder: (context) { + List userCityDrop = []; + for (var element in uVM.userCities!.data!) { + if (AppState().getUser.data!.userInfo!.cityId == element.id) { + city = DropValue(element.id?.toInt() ?? 0, element.cityName ?? "", ""); + } + userCityDrop.add(DropValue(element.id?.toInt() ?? 0, element.cityName ?? "", "")); + } + return DropdownField( + (DropValue value) { + city = value; + setState(() {}); + }, + list: userCityDrop, + dropdownValue: city != null && city != -1 ? DropValue(city!.id, city!.value, "") : null, + hint: city != null && city != -1 ? city!.value : "City", + // errorValue: adVM.vehicleCountryId.errorValue, + ); + })) + : SizedBox(), + 20.height, + Padding( + padding: const EdgeInsets.all(20.0), + child: ShowFillButton( + title: LocaleKeys.confirm.tr(), + maxWidth: double.infinity, + onPressed: () async { + await uVM.userDetailsUpdate(context, AppState().getUser.data!.userInfo!.firstName!, AppState().getUser.data!.userInfo!.lastName!, city != null ? city?.id.toString() : null); + }, + ), + ), + ], + ), + ); + }); + } +} diff --git a/lib/views/user/update_user_details.dart b/lib/views/user/update_user_details.dart index 0d6c361..4731bd2 100644 --- a/lib/views/user/update_user_details.dart +++ b/lib/views/user/update_user_details.dart @@ -55,7 +55,7 @@ class _UpdateUserDetailsState extends State { title: LocaleKeys.confirm.tr(), maxWidth: double.infinity, onPressed: () async { - await userVM.userDetailsUpdate(context, firstname, lastname); + await userVM.userDetailsUpdate(context, firstname, lastname, null); }, ), diff --git a/pubspec.yaml b/pubspec.yaml index dfc2ea3..91acd57 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -22,7 +22,7 @@ dependencies: sizer: ^3.0.4 fluttertoast: ^8.0.8 shared_preferences: ^2.0.6 - file_picker: ^8.1.2 + file_picker: ^8.0.7 image_picker: ^1.1.2 equatable: ^2.0.3 logger: ^2.4.0 @@ -34,7 +34,7 @@ dependencies: badges: ^3.0.2 carousel_slider: 5.0.0 dropdown_button2: ^2.0.0 - flutter_inappwebview: ^6.1.5 + flutter_inappwebview: ^6.0.0 country_code_picker: ^3.0.0 table_calendar: ^3.0.9 intl: any @@ -47,8 +47,8 @@ dependencies: # Firebase Packages - firebase_messaging: ^15.1.3 - firebase_core: ^3.6.0 + firebase_messaging: ^15.0.4 + firebase_core: ^3.3.0 flutter_local_notifications: ^18.0.0 @@ -62,7 +62,7 @@ dependencies: # Auth local_auth: ^2.2.0 # huawei_fido: ^6.3.0+305 - device_info_plus: ^11.0.0 + device_info_plus: ^10.1.0 dev_dependencies: