|
|
|
|
@ -44,85 +44,90 @@ class _UpdateUserContactInfoBottomSheetState extends State<UpdateUserContactInfo
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
return Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
|
children: [
|
|
|
|
|
AppTextFormField(
|
|
|
|
|
labelText: "Email",
|
|
|
|
|
backgroundColor: AppColor.fieldBgColor(context),
|
|
|
|
|
initialValue: widget.uEmail,
|
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
|
hintText: "email@example.com",
|
|
|
|
|
labelStyle: AppTextStyles.textFieldLabelStyle,
|
|
|
|
|
hintStyle: AppTextStyles.textFieldLabelStyle,
|
|
|
|
|
textInputType: TextInputType.emailAddress,
|
|
|
|
|
showShadow: false,
|
|
|
|
|
onChange: (value) {
|
|
|
|
|
email = value;
|
|
|
|
|
},
|
|
|
|
|
style: Theme.of(context).textTheme.titleMedium,
|
|
|
|
|
),
|
|
|
|
|
12.height,
|
|
|
|
|
AppTextFormField(
|
|
|
|
|
labelText: "Phone Number",
|
|
|
|
|
backgroundColor: AppColor.fieldBgColor(context),
|
|
|
|
|
initialValue: widget.uPhoneNo,
|
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
|
hintText: "05xxxxxxxx",
|
|
|
|
|
labelStyle: AppTextStyles.textFieldLabelStyle,
|
|
|
|
|
hintStyle: AppTextStyles.textFieldLabelStyle,
|
|
|
|
|
textInputType: TextInputType.phone,
|
|
|
|
|
showShadow: false,
|
|
|
|
|
onChange: (value) {
|
|
|
|
|
phoneNo = value;
|
|
|
|
|
},
|
|
|
|
|
style: Theme.of(context).textTheme.titleMedium,
|
|
|
|
|
),
|
|
|
|
|
12.height,
|
|
|
|
|
AppTextFormField(
|
|
|
|
|
labelText: "Extension No",
|
|
|
|
|
backgroundColor: AppColor.fieldBgColor(context),
|
|
|
|
|
initialValue: widget.uExtensionNo,
|
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
|
hintText: "1234",
|
|
|
|
|
labelStyle: AppTextStyles.textFieldLabelStyle,
|
|
|
|
|
hintStyle: AppTextStyles.textFieldLabelStyle,
|
|
|
|
|
textInputType: const TextInputType.numberWithOptions(decimal: true),
|
|
|
|
|
showShadow: false,
|
|
|
|
|
onChange: (value) {
|
|
|
|
|
extensionNo = value;
|
|
|
|
|
},
|
|
|
|
|
style: Theme.of(context).textTheme.titleMedium,
|
|
|
|
|
),
|
|
|
|
|
12.height,
|
|
|
|
|
AppFilledButton(
|
|
|
|
|
label: "Update",
|
|
|
|
|
buttonColor: context.isDark? AppColor.primary10:AppColor.neutral50,
|
|
|
|
|
onPressed: () async {
|
|
|
|
|
FocusManager.instance.primaryFocus!.unfocus();
|
|
|
|
|
if (email.isEmpty || !Validator.isEmail(email)) {
|
|
|
|
|
"Please enter valid email".showToast;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (phoneNo.isEmpty || phoneNo.length != 10) {
|
|
|
|
|
"Please enter valid phone number".showToast;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (extensionNo.isEmpty) {
|
|
|
|
|
"Please enter extension".showToast;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
showDialog(context: context, barrierDismissible: false, builder: (context) => const AppLazyLoading());
|
|
|
|
|
bool status = await context.userProvider.updateContactInfo(widget.userID, email, phoneNo, extensionNo);
|
|
|
|
|
Navigator.pop(context);
|
|
|
|
|
if (status) {
|
|
|
|
|
return Padding(
|
|
|
|
|
padding: EdgeInsets.only(
|
|
|
|
|
bottom: MediaQuery.of(context).viewInsets.bottom + MediaQuery.of(context).padding.bottom,
|
|
|
|
|
),
|
|
|
|
|
child: Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
|
children: [
|
|
|
|
|
AppTextFormField(
|
|
|
|
|
labelText: "Email",
|
|
|
|
|
backgroundColor: AppColor.fieldBgColor(context),
|
|
|
|
|
initialValue: widget.uEmail,
|
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
|
hintText: "email@example.com",
|
|
|
|
|
labelStyle: AppTextStyles.textFieldLabelStyle,
|
|
|
|
|
hintStyle: AppTextStyles.textFieldLabelStyle,
|
|
|
|
|
textInputType: TextInputType.emailAddress,
|
|
|
|
|
showShadow: false,
|
|
|
|
|
onChange: (value) {
|
|
|
|
|
email = value;
|
|
|
|
|
},
|
|
|
|
|
style: Theme.of(context).textTheme.titleMedium,
|
|
|
|
|
),
|
|
|
|
|
12.height,
|
|
|
|
|
AppTextFormField(
|
|
|
|
|
labelText: "Phone Number",
|
|
|
|
|
backgroundColor: AppColor.fieldBgColor(context),
|
|
|
|
|
initialValue: widget.uPhoneNo,
|
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
|
hintText: "05xxxxxxxx",
|
|
|
|
|
labelStyle: AppTextStyles.textFieldLabelStyle,
|
|
|
|
|
hintStyle: AppTextStyles.textFieldLabelStyle,
|
|
|
|
|
textInputType: TextInputType.phone,
|
|
|
|
|
showShadow: false,
|
|
|
|
|
onChange: (value) {
|
|
|
|
|
phoneNo = value;
|
|
|
|
|
},
|
|
|
|
|
style: Theme.of(context).textTheme.titleMedium,
|
|
|
|
|
),
|
|
|
|
|
12.height,
|
|
|
|
|
AppTextFormField(
|
|
|
|
|
labelText: "Extension No",
|
|
|
|
|
backgroundColor: AppColor.fieldBgColor(context),
|
|
|
|
|
initialValue: widget.uExtensionNo,
|
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
|
hintText: "1234",
|
|
|
|
|
labelStyle: AppTextStyles.textFieldLabelStyle,
|
|
|
|
|
hintStyle: AppTextStyles.textFieldLabelStyle,
|
|
|
|
|
textInputType: const TextInputType.numberWithOptions(decimal: true),
|
|
|
|
|
showShadow: false,
|
|
|
|
|
onChange: (value) {
|
|
|
|
|
extensionNo = value;
|
|
|
|
|
},
|
|
|
|
|
style: Theme.of(context).textTheme.titleMedium,
|
|
|
|
|
),
|
|
|
|
|
12.height,
|
|
|
|
|
AppFilledButton(
|
|
|
|
|
label: "Update",
|
|
|
|
|
buttonColor: context.isDark ? AppColor.primary10 : AppColor.neutral50,
|
|
|
|
|
onPressed: () async {
|
|
|
|
|
FocusManager.instance.primaryFocus!.unfocus();
|
|
|
|
|
if (email.isEmpty || !Validator.isEmail(email)) {
|
|
|
|
|
"Please enter valid email".showToast;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (phoneNo.isEmpty || phoneNo.length != 10) {
|
|
|
|
|
"Please enter valid phone number".showToast;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (extensionNo.isEmpty) {
|
|
|
|
|
"Please enter extension".showToast;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
showDialog(context: context, barrierDismissible: false, builder: (context) => const AppLazyLoading());
|
|
|
|
|
bool status = await context.userProvider.updateContactInfo(widget.userID, email, phoneNo, extensionNo);
|
|
|
|
|
Navigator.pop(context);
|
|
|
|
|
widget.onUpdate(email, phoneNo, extensionNo);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
if (status) {
|
|
|
|
|
Navigator.pop(context);
|
|
|
|
|
widget.onUpdate(email, phoneNo, extensionNo);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|