aamir_dev
Aamir 11 months ago
parent 2fcc2792a3
commit 803ade0b9d

@ -33,242 +33,240 @@ class _CompleteProfilePageState extends State<CompleteProfilePage> {
confirmPassword = ""; confirmPassword = "";
late String password = ""; late String password = "";
bool isChecked = false; bool isChecked = false;
late UserVM userVM;
DropValue? city; DropValue? city;
DropValue? gender; DropValue? gender;
@override @override
void initState() { void initState() {
userVM = Provider.of<UserVM>(context, listen: false);
getcities();
super.initState(); super.initState();
} }
getcities() async {
print("Country ID = " + AppState().getUserRegisterCountrySelection.id.toString());
await userVM.getAllCitiesForUser(AppState().getUserRegisterCountrySelection.id);
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Consumer(builder: (BuildContext context, UserVM userVM, Widget? child) {
appBar: CustomAppBar( print("Country ID = " + AppState().getUserRegisterCountrySelection.id.toString());
isRemoveBackButton: widget.user.data!.roleId == 7 ? false : true, userVM.getAllCitiesForUser(AppState().getUserRegisterCountrySelection.id);
title: widget.user.data!.roleId == 7 ? "" : LocaleKeys.signUp.tr(), return Scaffold(
), appBar: CustomAppBar(
body: SizedBox( isRemoveBackButton: widget.user.data!.roleId == 7 ? false : true,
width: double.infinity, title: widget.user.data!.roleId == 7 ? "" : LocaleKeys.signUp.tr(),
height: double.infinity, ),
child: SingleChildScrollView( body: SizedBox(
child: Padding( width: double.infinity,
padding: const EdgeInsets.all(20), height: double.infinity,
child: Column( child: SingleChildScrollView(
children: [ child: Padding(
6.height, padding: const EdgeInsets.all(20),
LocaleKeys.completeProfile.tr().toText( child: Column(
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,
),
),
12.height,
TxtField(
hint: LocaleKeys.firstName.tr(),
value: firstName,
onChanged: (v) {
firstName = v;
},
),
12.height,
TxtField(
hint: LocaleKeys.surname.tr(),
value: lastName,
onChanged: (v) {
lastName = v;
},
),
12.height,
Container(
padding: const EdgeInsets.only(right: 0, left: 0, top: 0, bottom: 0),
child: Builder(builder: (context) {
List<DropValue> 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,
// isButtonEnable: email!.length > 0 ? true : false,
buttonTitle: LocaleKeys.verify.tr(),
onChanged: (v) {
email = v;
},
),
12.height,
userVM.userCities != null
? Container(
padding: const EdgeInsets.only(right: 0, left: 0, top: 0, bottom: 0),
child: Builder(builder: (context) {
List<DropValue> 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,
maxLines: 1,
value: password,
onChanged: (v) {
password = v;
},
),
12.height,
TxtField(
hint: LocaleKeys.confirmPass.tr(),
isPasswordEnabled: true,
maxLines: 1,
value: confirmPassword,
onChanged: (v) {
confirmPassword = v;
},
),
50.height,
Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.center,
children: [ children: [
Consumer(builder: (BuildContext context, UserVM userVM, Widget? child) { 6.height,
return Checkbox( LocaleKeys.completeProfile.tr().toText(
value: userVM.completeProfilePageCheckbox, height: 23 / 24,
activeColor: MyColors.darkPrimaryColor, fontSize: 24,
onChanged: (value) { letterSpacing: -1.44,
userVM.updateCompleteProfilePageCheckbox(value!); ),
}, 12.height,
); Padding(
}), padding: const EdgeInsets.symmetric(horizontal: 20),
Expanded( child: LocaleKeys.profileMsg.tr().toText(
child: Text.rich( color: MyColors.lightTextColor,
TextSpan( textAlign: TextAlign.center,
children: [ fontSize: 14,
height: 23 / 24,
letterSpacing: -0.48,
),
),
12.height,
TxtField(
hint: LocaleKeys.firstName.tr(),
value: firstName,
onChanged: (v) {
firstName = v;
},
),
12.height,
TxtField(
hint: LocaleKeys.surname.tr(),
value: lastName,
onChanged: (v) {
lastName = v;
},
),
12.height,
Container(
padding: const EdgeInsets.only(right: 0, left: 0, top: 0, bottom: 0),
child: Builder(builder: (context) {
List<DropValue> 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,
// isButtonEnable: email!.length > 0 ? true : false,
buttonTitle: LocaleKeys.verify.tr(),
onChanged: (v) {
email = v;
},
),
12.height,
userVM.userCities != null
? Container(
padding: const EdgeInsets.only(right: 0, left: 0, top: 0, bottom: 0),
child: Builder(builder: (context) {
List<DropValue> 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,
maxLines: 1,
value: password,
onChanged: (v) {
password = v;
},
),
12.height,
TxtField(
hint: LocaleKeys.confirmPass.tr(),
isPasswordEnabled: true,
maxLines: 1,
value: confirmPassword,
onChanged: (v) {
confirmPassword = v;
},
),
50.height,
Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Consumer(builder: (BuildContext context, UserVM userVM, Widget? child) {
return Checkbox(
value: userVM.completeProfilePageCheckbox,
activeColor: MyColors.darkPrimaryColor,
onChanged: (value) {
userVM.updateCompleteProfilePageCheckbox(value!);
},
);
}),
Expanded(
child: Text.rich(
TextSpan( TextSpan(
text: LocaleKeys.termsOfService.tr(), children: [
style: const TextStyle(fontSize: 12, fontWeight: MyFonts.Medium), TextSpan(
text: LocaleKeys.termsOfService.tr(),
style: const TextStyle(fontSize: 12, fontWeight: MyFonts.Medium),
),
TextSpan(
text: " ${LocaleKeys.terms.tr()}",
style: const TextStyle(
decoration: TextDecoration.underline,
fontSize: 12,
color: MyColors.darkPrimaryColor,
fontWeight: MyFonts.Bold,
))
],
), ),
TextSpan( ).onPress(() {
text: " ${LocaleKeys.terms.tr()}", navigateWithName(context, AppRoutes.settingOptionsTermsAndConditions);
style: const TextStyle( }),
decoration: TextDecoration.underline, )
fontSize: 12, // Column(
color: MyColors.darkPrimaryColor, // children: [
fontWeight: MyFonts.Bold, // LocaleKeys.termsOfService.tr().toText(fontSize: 12),
)) // LocaleKeys.terms.tr().toText(fontSize: 12, color: MyColors.darkPrimaryColor),
], // ],
), // ),
).onPress(() { // Theme(
navigateWithName(context, AppRoutes.settingOptionsTermsAndConditions); // data: ThemeData(unselectedWidgetColor: Colors.transparent),
}), // child: Checkbox(
) // value: false,
// Column( // onChanged: (_) {},
// children: [ // ),
// LocaleKeys.termsOfService.tr().toText(fontSize: 12), // )
// LocaleKeys.terms.tr().toText(fontSize: 12, color: MyColors.darkPrimaryColor), ],
// ], ),
// ), 16.height,
// Theme( Consumer(builder: (BuildContext context, UserVM userVM, Widget? child) {
// data: ThemeData(unselectedWidgetColor: Colors.transparent), return ShowFillButton(
// child: Checkbox( title: LocaleKeys.save.tr(),
// value: false, maxWidth: double.infinity,
// onChanged: (_) {}, isDisabled: !userVM.completeProfilePageCheckbox,
// ), onPressed: () {
// ) if (!userVM.completeProfilePageCheckbox) {
return;
}
bool validateStatus = userVM.dataValidation(password: password,
firstName: firstName,
lastName: lastName,
email: email,
city: city,
gender: gender);
if (validateStatus) {
userVM.performCompleteProfile(
context,
password: password,
confirmPassword: confirmPassword!,
firstName: firstName!,
lastName: lastName!,
email: email!,
userId: widget.user.data!.userId ?? "",
isNeedToPassToken: widget.user.data!.isNeedToPassToken,
cityID: city!.id.toString(),
genderID: gender!.id.toString(),
);
}
});
}),
16.height,
], ],
), ),
16.height, ),
Consumer(builder: (BuildContext context, UserVM userVM, Widget? child) {
return ShowFillButton(
title: LocaleKeys.save.tr(),
maxWidth: double.infinity,
isDisabled: !userVM.completeProfilePageCheckbox,
onPressed: () {
if (!userVM.completeProfilePageCheckbox) {
return;
}
bool validateStatus = userVM.dataValidation(password: password,
firstName: firstName,
lastName: lastName,
email: email,
city: city,
gender: gender);
if (validateStatus) {
userVM.performCompleteProfile(
context,
password: password,
confirmPassword: confirmPassword!,
firstName: firstName!,
lastName: lastName!,
email: email!,
userId: widget.user.data!.userId ?? "",
isNeedToPassToken: widget.user.data!.isNeedToPassToken,
cityID: city!.id.toString(),
genderID: gender!.id.toString(),
);
}
});
}),
16.height,
],
), ),
), ),
), );
), }
); );
} }
} }

@ -1,3 +1,4 @@
import 'package:mc_common_app/classes/app_state.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';
@ -78,8 +79,9 @@ class _RegisterPageState extends State<RegisterCustomerPage> {
DropdownField( DropdownField(
dropdownValue: selectedDrop, dropdownValue: selectedDrop,
(DropValue value) { (DropValue value) {
print("========");
selectedDrop = value; selectedDrop = value;
AppState().setUserRegisterCountrySelection = value;
setState(() { setState(() {
countryCode = value.subValue; countryCode = value.subValue;
countryId = value.id; countryId = value.id;

Loading…
Cancel
Save