fist commit ftc staff app clone
This commit is contained in:
165
lib/view/custom_widgets/auth/custom_forget_password_dialog.dart
Normal file
165
lib/view/custom_widgets/auth/custom_forget_password_dialog.dart
Normal file
@@ -0,0 +1,165 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:ftc_mobile_app/ftc_mobile_app.dart';
|
||||
import 'package:ftc_mobile_app/utilities/extensions/custom_extensions.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
class CustomForgetPasswordDialog extends StatelessWidget {
|
||||
const CustomForgetPasswordDialog({
|
||||
Key? key,
|
||||
required this.dialogMessageText,
|
||||
required this.headingText,
|
||||
required this.dialogMessageTextBold,
|
||||
required this.dialogButtonAcceptText,
|
||||
required this.dialogButtonCloseText,
|
||||
// this.acceptFunction,
|
||||
}) : super(key: key);
|
||||
|
||||
final String headingText;
|
||||
final String dialogMessageText;
|
||||
final String dialogMessageTextBold;
|
||||
final String dialogButtonAcceptText;
|
||||
|
||||
// final Function? acceptFunction;
|
||||
final String dialogButtonCloseText;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
TextEditingController emailController = TextEditingController();
|
||||
RxString emailErrorMsg = "".obs;
|
||||
|
||||
bool validateEmail() {
|
||||
if (emailController.text.isEmpty) {
|
||||
emailErrorMsg.value = ConstantText.kEmailIsRequired;
|
||||
} else if (!GetUtils.isEmail(emailController.text)) {
|
||||
emailErrorMsg.value = ConstantText.kInvalidEmail;
|
||||
} else {
|
||||
emailErrorMsg.value = "";
|
||||
}
|
||||
return emailErrorMsg.isEmpty;
|
||||
}
|
||||
|
||||
return AlertDialog(
|
||||
surfaceTintColor: CustomAppColors.kPrimaryColor,
|
||||
shape: LinearBorder.top(side: BorderSide.none),
|
||||
backgroundColor: CustomAppColors.kWhiteColor,
|
||||
shadowColor: CustomAppColors.kWhiteColor,
|
||||
titlePadding: EdgeInsets.only(top: 20.h),
|
||||
content: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
CustomTextWidget(
|
||||
text: headingText,
|
||||
isExpanded: false,
|
||||
fontSize: 16.sp,
|
||||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
Container(
|
||||
padding: EdgeInsets.all(10.sp),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
CustomTextWidget(
|
||||
text: dialogMessageText,
|
||||
isExpanded: false,
|
||||
fontSize: 10.sp,
|
||||
fontWeight: FontWeight.w400,
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
SizedBox(
|
||||
height: 3.h,
|
||||
),
|
||||
dialogMessageTextBold != ""
|
||||
? CustomTextWidget(
|
||||
text: dialogMessageTextBold,
|
||||
isExpanded: false,
|
||||
fontSize: 10.sp,
|
||||
fontWeight: FontWeight.bold,
|
||||
textAlign: TextAlign.left,
|
||||
)
|
||||
: Container(),
|
||||
],
|
||||
),
|
||||
),
|
||||
// SizedBox(height: 10.h,),
|
||||
Padding(
|
||||
padding: EdgeInsets.only(top: 5.0.h),
|
||||
child: CustomTextFieldWidget(
|
||||
controller: emailController,
|
||||
hintText: ConstantText.kPleaseInputEmail,
|
||||
heading: ConstantText.kEmailHeading,
|
||||
onChange: (_) {
|
||||
validateEmail();
|
||||
},
|
||||
),
|
||||
),
|
||||
Obx(() {
|
||||
return CustomErrorMsg(
|
||||
message: emailErrorMsg.value,
|
||||
);
|
||||
}),
|
||||
16.verticalSpace,
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: SizedBox(
|
||||
height: 32.h,
|
||||
child: ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
minimumSize: Size(double.infinity, 30.h),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(5),
|
||||
),
|
||||
backgroundColor: CustomAppColors.kSecondaryColor),
|
||||
onPressed: () async {
|
||||
if (validateEmail()) {
|
||||
Navigator.of(context).pop();
|
||||
var response = await AuthService()
|
||||
.forgetPassword(email: emailController.text)
|
||||
.showLoader();
|
||||
if (response == true) {
|
||||
FrequentFunctions.showToast(
|
||||
message:
|
||||
"A password reset link has been sent to your registered email.",
|
||||
);
|
||||
}
|
||||
// Add functionality for the "Agree" button.
|
||||
}
|
||||
},
|
||||
child: CustomTextWidget(
|
||||
text: dialogButtonAcceptText,
|
||||
fontColor: CustomAppColors.kPrimaryColor,
|
||||
fontSize: 14.sp,
|
||||
fontWeight: FontWeight.w400),
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(width: 10.h),
|
||||
Expanded(
|
||||
child: SizedBox(
|
||||
height: 32.h,
|
||||
child: ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
minimumSize: Size(double.infinity, 30.h),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(5),
|
||||
),
|
||||
backgroundColor: CustomAppColors.kLightGreyColor),
|
||||
onPressed: () {
|
||||
// Add functionality for the "pop" button.
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
child: CustomTextWidget(
|
||||
text: dialogButtonCloseText,
|
||||
fontColor: CustomAppColors.kPrimaryColor,
|
||||
fontSize: 14.sp,
|
||||
fontWeight: FontWeight.w400),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
1
lib/view/custom_widgets/auth/export_auth_widgets.dart
Normal file
1
lib/view/custom_widgets/auth/export_auth_widgets.dart
Normal file
@@ -0,0 +1 @@
|
||||
export 'custom_forget_password_dialog.dart';
|
||||
Reference in New Issue
Block a user