diff --git a/assets/langs/ar-SA.json b/assets/langs/ar-SA.json index 01b8045..e65240d 100644 --- a/assets/langs/ar-SA.json +++ b/assets/langs/ar-SA.json @@ -744,5 +744,13 @@ "blockedByAdmin": "تم حظرها من قبل المسؤول", "active": "نشط", "paymentType": "نوع الدفع", - "searchByCreatedDate": "البحث حسب تاريخ الإنشاء" + "searchByCreatedDate": "البحث حسب تاريخ الإنشاء", + "cityNameMandatory": "المدينة إلزامية", + "genderMandatory": "الجنس إلزامي", + "updateCity": "تحديث المدينة", + "userGender": "جنس", + "userMale": "ذكر", + "userFemale": "أنثى" + + } \ No newline at end of file diff --git a/assets/langs/en-US.json b/assets/langs/en-US.json index 65c26db..65eea5d 100644 --- a/assets/langs/en-US.json +++ b/assets/langs/en-US.json @@ -742,6 +742,11 @@ "updateUserDetails": "Update User Details", "enterNewFirstName": "Enter First Name", "enterNewLastName": "Enter Last Name", - "userDetailsUpdated": "User Details is Updated" - + "userDetailsUpdated": "User Details is Updated", + "cityNameMandatory": "City is mandatory", + "genderMandatory": "Gender is mandatory", + "updateCity": "Update City", + "userGender": "Gender", + "userMale": "Male", + "userFemale": "Female" } \ No newline at end of file diff --git a/lib/classes/app_state.dart b/lib/classes/app_state.dart index 4d528d9..09ddd54 100644 --- a/lib/classes/app_state.dart +++ b/lib/classes/app_state.dart @@ -4,6 +4,7 @@ import 'package:mc_common_app/models/subscriptions_models/provider_subscription_ 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'; +import 'package:mc_common_app/widgets/dropdown/dropdow_field.dart'; class AppState { static final AppState _instance = AppState._internal(); @@ -70,4 +71,13 @@ class AppState { set setproviderSubscription(List? value) { _providerSubscription = value; } + + + DropValue? _userRegisterCountrySelection ; + + DropValue get getUserRegisterCountrySelection => _userRegisterCountrySelection!; + + set setUserRegisterCountrySelection(DropValue value) { + _userRegisterCountrySelection = value; + } } diff --git a/lib/generated/codegen_loader.g.dart b/lib/generated/codegen_loader.g.dart index 94e96d1..6a25b80 100644 --- a/lib/generated/codegen_loader.g.dart +++ b/lib/generated/codegen_loader.g.dart @@ -760,7 +760,13 @@ class CodegenLoader extends AssetLoader{ "blockedByAdmin": "تم حظرها من قبل المسؤول", "active": "نشط", "paymentType": "نوع الدفع", - "searchByCreatedDate": "البحث حسب تاريخ الإنشاء" + "searchByCreatedDate": "البحث حسب تاريخ الإنشاء", + "cityNameMandatory": "المدينة إلزامية", + "genderMandatory": "الجنس إلزامي", + "updateCity": "تحديث المدينة", + "userGender": "جنس", + "userMale": "ذكر", + "userFemale": "أنثى" }; static const Map en_US = { "firstTimeLogIn": "First Time Log In", @@ -1506,7 +1512,13 @@ static const Map en_US = { "updateUserDetails": "Update User Details", "enterNewFirstName": "Enter First Name", "enterNewLastName": "Enter Last Name", - "userDetailsUpdated": "User Details is Updated" + "userDetailsUpdated": "User Details is Updated", + "cityNameMandatory": "City is mandatory", + "genderMandatory": "Gender is mandatory", + "updateCity": "Update City", + "userGender": "Gender", + "userMale": "Male", + "userFemale": "Female" }; static const Map> mapLocales = {"ar_SA": ar_SA, "en_US": en_US}; } diff --git a/lib/generated/locale_keys.g.dart b/lib/generated/locale_keys.g.dart index 4d6b505..be7dc15 100644 --- a/lib/generated/locale_keys.g.dart +++ b/lib/generated/locale_keys.g.dart @@ -684,6 +684,10 @@ abstract class LocaleKeys { static const customerLocation = 'customerLocation'; static const deliveryAvailable = 'deliveryAvailable'; static const viewed = 'viewed'; + static const updateUserDetails = 'updateUserDetails'; + static const enterNewFirstName = 'enterNewFirstName'; + static const enterNewLastName = 'enterNewLastName'; + static const userDetailsUpdated = 'userDetailsUpdated'; static const itemNoLongerAvailable = 'itemNoLongerAvailable'; static const reactivateAd = 'reactivateAd'; static const dealOutsideApp = 'dealOutsideApp'; @@ -720,9 +724,11 @@ abstract class LocaleKeys { static const active = 'active'; static const paymentType = 'paymentType'; static const searchByCreatedDate = 'searchByCreatedDate'; - static const updateUserDetails = 'updateUserDetails'; - static const enterNewFirstName = 'enterNewFirstName'; - static const enterNewLastName = 'enterNewLastName'; - static const userDetailsUpdated = 'userDetailsUpdated'; + static const cityNameMandatory = 'cityNameMandatory'; + static const genderMandatory = 'genderMandatory'; + static const updateCity = 'updateCity'; + static const userGender = 'userGender'; + static const userMale = 'userMale'; + static const userFemale = 'userFemale'; } diff --git a/lib/repositories/user_repo.dart b/lib/repositories/user_repo.dart index 9ce6d57..589681e 100644 --- a/lib/repositories/user_repo.dart +++ b/lib/repositories/user_repo.dart @@ -31,7 +31,7 @@ abstract class UserRepo { Future basicVerify(String phoneNo, String otp, String userToken, {bool isNeedToPassToken = false}); - Future basicComplete(String userId, String firstName, String lastName, String email, String password, {bool isNeedToPassToken = false}); + Future basicComplete(String userId, String firstName, String lastName, String email, String password, String cityID, String genderID, {bool isNeedToPassToken = false}); Future loginV1(String phoneNo, String password); @@ -106,12 +106,12 @@ class UserRepoImp implements UserRepo { } @override - Future basicComplete(String userId, String firstName, String lastName, String email, String password, {bool isNeedToPassToken = false}) async { + Future basicComplete(String userId, String firstName, String lastName, String email, String password, String cityID, String genderID, {bool isNeedToPassToken = false}) async { Map postParams; if (email.isEmpty) { - postParams = {"userID": userId, "firstName": firstName, "lastName": lastName, "companyName": "string", "isEmailVerified": true, "password": password}; + postParams = {"userID": userId, "firstName": firstName, "lastName": lastName, "companyName": "string", "isEmailVerified": true, "password": password, "cityID": cityID, "genderID": genderID}; } else { - postParams = {"userID": userId, "firstName": firstName, "lastName": lastName, "email": email, "companyName": "string", "isEmailVerified": true, "password": password}; + postParams = {"userID": userId, "firstName": firstName, "lastName": lastName, "email": email, "companyName": "string", "isEmailVerified": true, "password": password, "cityID": cityID, "genderID": genderID}; } String? t; if (isNeedToPassToken) { diff --git a/lib/view_models/user_view_model.dart b/lib/view_models/user_view_model.dart index fd6cbee..d06f1c6 100644 --- a/lib/view_models/user_view_model.dart +++ b/lib/view_models/user_view_model.dart @@ -45,6 +45,7 @@ import 'package:mc_common_app/views/location_views/map_selection_widget.dart'; import 'package:mc_common_app/widgets/dialog/dialogs.dart'; import 'package:mc_common_app/widgets/dialog/message_dialog.dart'; import 'package:mc_common_app/widgets/dialog/otp_dialog.dart'; +import 'package:mc_common_app/widgets/dropdown/dropdow_field.dart'; import 'package:mc_common_app/widgets/tab/login_email_tab.dart'; import 'package:provider/provider.dart'; @@ -198,11 +199,13 @@ class UserVM extends BaseVM { required String email, required String? userId, bool isNeedToPassToken = false, + required String cityID, + required String genderID, }) async { if (Utils.passwordValidateStructure(password)) { if (password == confirmPassword) { Utils.showLoading(context); - RegisterUserRespModel user = await userRepo.basicComplete(userId ?? "", firstName, lastName, email, password, isNeedToPassToken: isNeedToPassToken); + RegisterUserRespModel user = await userRepo.basicComplete(userId ?? "", firstName, lastName, email, password, cityID, genderID, isNeedToPassToken: isNeedToPassToken); Utils.hideLoading(context); if (user.messageStatus == 1) { Utils.showToast(LocaleKeys.successfullyRegistered.tr()); @@ -225,6 +228,8 @@ class UserVM extends BaseVM { required String? firstName, required String? lastName, required String? email, + required DropValue? city, + required DropValue? gender, }) { bool isValid = true; if (firstName!.isEmpty) { @@ -249,6 +254,13 @@ class UserVM extends BaseVM { //("Please accept terms"); isValid = false; } + else if (city == null) { + Utils.showToast(LocaleKeys.cityNameMandatory.tr()); + isValid = false; + } else if (gender == null) { + Utils.showToast(LocaleKeys.genderMandatory.tr()); + isValid = false; + } return isValid; } diff --git a/lib/views/user/complete_profile_page.dart b/lib/views/user/complete_profile_page.dart index d484d6f..eb93b4e 100644 --- a/lib/views/user/complete_profile_page.dart +++ b/lib/views/user/complete_profile_page.dart @@ -1,3 +1,4 @@ +import 'package:mc_common_app/classes/app_state.dart'; import 'package:mc_common_app/classes/consts.dart'; import 'package:mc_common_app/config/routes.dart'; import 'package:mc_common_app/theme/colors.dart'; @@ -9,6 +10,7 @@ import 'package:mc_common_app/utils/navigator.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/extensions/extensions_widget.dart'; import 'package:mc_common_app/widgets/txt_field.dart'; import 'package:easy_localization/easy_localization.dart'; @@ -25,17 +27,29 @@ class CompleteProfilePage extends StatefulWidget { } class _CompleteProfilePageState extends State { - String? firstName = "", lastName = "", email = "", confirmPassword = ""; + String? firstName = "", + lastName = "", + email = "", + confirmPassword = ""; late String password = ""; bool isChecked = false; late UserVM userVM; + DropValue? city; + DropValue? gender; @override void initState() { userVM = Provider.of(context, listen: false); + getcities(); + super.initState(); } + getcities() async { + print("Country ID = " + AppState().getUserRegisterCountrySelection.id.toString()); + await userVM.getAllCitiesForUser(AppState().getUserRegisterCountrySelection.id); + } + @override Widget build(BuildContext context) { return Scaffold( @@ -53,20 +67,20 @@ class _CompleteProfilePageState extends State { children: [ 6.height, LocaleKeys.completeProfile.tr().toText( - height: 23 / 24, - fontSize: 24, - letterSpacing: -1.44, - ), + height: 23 / 24, + fontSize: 24, + letterSpacing: -1.44, + ), 12.height, Padding( padding: const EdgeInsets.symmetric(horizontal: 20), child: LocaleKeys.profileMsg.tr().toText( - color: MyColors.lightTextColor, - textAlign: TextAlign.center, - fontSize: 14, - height: 23 / 24, - letterSpacing: -0.48, - ), + color: MyColors.lightTextColor, + textAlign: TextAlign.center, + fontSize: 14, + height: 23 / 24, + letterSpacing: -0.48, + ), ), 12.height, TxtField( @@ -85,6 +99,32 @@ class _CompleteProfilePageState extends State { }, ), 12.height, + Container( + padding: const EdgeInsets.only(right: 0, left: 0, top: 0, bottom: 0), + child: Builder(builder: (context) { + List userGender = []; + userGender.add(DropValue(1.toInt(), "${LocaleKeys.userMale.tr()}", "", isEnabled: true)); + userGender.add(DropValue(2.toInt(), "${LocaleKeys.userFemale.tr()}", "", isEnabled: true)); + // for (var element in userVM.userCities!.data!) { + // if (AppState().getUser.data != null) { + // if (AppState().getUser.data!.userInfo!.cityId == element.id) { + // city = DropValue(element.id?.toInt() ?? 0, element.cityName ?? "", ""); + // } + // } + // + // } + return DropdownField( + (DropValue value) { + gender = value; + setState(() {}); + }, + list: userGender, + dropdownValue: gender != null && gender != -1 ? DropValue(gender!.id, gender!.value, "") : null, + hint: gender != null && gender != -1 ? gender!.value : "${LocaleKeys.userGender.tr()} *", + // errorValue: adVM.vehicleCountryId.errorValue, + ); + })), + 12.height, TxtField( hint: LocaleKeys.email.tr(), value: email, @@ -95,6 +135,32 @@ class _CompleteProfilePageState extends State { }, ), 12.height, + userVM.userCities != null + ? Container( + padding: const EdgeInsets.only(right: 0, left: 0, top: 0, bottom: 0), + child: Builder(builder: (context) { + List userCityDrop = []; + for (var element in userVM.userCities!.data!) { + if (AppState().getUser.data != null) { + 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 : "${LocaleKeys.city.tr()} *", + // errorValue: adVM.vehicleCountryId.errorValue, + ); + })) + : SizedBox(), + 12.height, TxtField( hint: LocaleKeys.createPass.tr(), isPasswordEnabled: true, @@ -175,12 +241,12 @@ class _CompleteProfilePageState extends State { if (!userVM.completeProfilePageCheckbox) { return; } - bool validateStatus = userVM.dataValidation( - password: password, - firstName: firstName, - lastName: lastName, - email: email, - ); + bool validateStatus = userVM.dataValidation(password: password, + firstName: firstName, + lastName: lastName, + email: email, + city: city, + gender: gender); if (validateStatus) { userVM.performCompleteProfile( context, @@ -191,6 +257,8 @@ class _CompleteProfilePageState extends State { email: email!, userId: widget.user.data!.userId ?? "", isNeedToPassToken: widget.user.data!.isNeedToPassToken, + cityID: city!.id.toString(), + genderID: gender!.id.toString(), ); } }); diff --git a/lib/views/user/register_provider_page.dart b/lib/views/user/register_provider_page.dart index aa9cb5a..8df8486 100644 --- a/lib/views/user/register_provider_page.dart +++ b/lib/views/user/register_provider_page.dart @@ -1,5 +1,6 @@ import 'dart:developer'; +import 'package:mc_common_app/classes/app_state.dart'; import 'package:mc_common_app/config/dependency_injection.dart'; import 'package:mc_common_app/extensions/int_extensions.dart'; import 'package:mc_common_app/extensions/string_extensions.dart'; @@ -118,8 +119,12 @@ class _RegisterPageState extends State { if (snapshot.hasData) { List dropList = []; snapshot.data?.data?.forEach((element) { - dropList.add(DropValue(element.id ?? 0, - EasyLocalization.of(context)?.currentLocale?.countryCode == "SA" ? "${element.countryNameN ?? ""} ${element.countryCode ?? ""}" : "${element.countryName ?? ""} ${element.countryCode ?? ""}", element.countryCode ?? "")); + dropList.add(DropValue( + element.id ?? 0, + EasyLocalization.of(context)?.currentLocale?.countryCode == "SA" + ? "${element.countryNameN ?? ""} ${element.countryCode ?? ""}" + : "${element.countryName ?? ""} ${element.countryCode ?? ""}", + element.countryCode ?? "")); }); return Column( children: [ @@ -132,6 +137,7 @@ class _RegisterPageState extends State { DropdownField( (DropValue value) { selectedDrop = value; + AppState().setUserRegisterCountrySelection = value; setState(() { countryCode = value.subValue; countryId = value.id; diff --git a/lib/views/user/update_user_city_country.dart b/lib/views/user/update_user_city_country.dart index 0f36c8b..5107c5c 100644 --- a/lib/views/user/update_user_city_country.dart +++ b/lib/views/user/update_user_city_country.dart @@ -35,7 +35,7 @@ class _UpdateUserCityCountryState extends State { return Consumer(builder: (BuildContext context, UserVM uVM, Widget? child) { return Scaffold( appBar: CustomAppBar( - title: "Update City", + title: LocaleKeys.updateCity.tr(), ), body: Column( children: [ @@ -58,7 +58,7 @@ class _UpdateUserCityCountryState extends State { }, list: userCountryDrop, dropdownValue: country != null && country != -1 ? DropValue(country!.id, country!.value, "") : null, - hint: country != null && country != -1 ? country!.value : "Country", + hint: country != null && country != -1 ? country!.value : "${LocaleKeys.country.tr()} *", // errorValue: adVM.vehicleCountryId.errorValue, ); })) @@ -81,7 +81,7 @@ class _UpdateUserCityCountryState extends State { }, list: userCityDrop, dropdownValue: city != null && city != -1 ? DropValue(city!.id, city!.value, "") : null, - hint: city != null && city != -1 ? city!.value : "City", + hint: city != null && city != -1 ? city!.value : "${LocaleKeys.city.tr()} *", // errorValue: adVM.vehicleCountryId.errorValue, ); }))