import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import '../../Provider/SignUp_provider.dart'; import '../../Provider/language_provider.dart'; import '../../Provider/passwordProvider.dart'; import '../../config/AppSnackbar.dart'; import '../../config/constants/arabe.dart' as Language; import '../../utils/colors.dart'; import '../../widgets/CustomTextFieldWidget.dart'; import '../../widgets/PurpleHeader.dart'; import '../../widgets/custom_button.dart'; import '../../widgets/custom_text.dart'; class ChangePasswordLastStepScreen extends StatefulWidget { final String? code; const ChangePasswordLastStepScreen({super.key,this.code}); @override State createState() => _ChangePasswordLastStepScreenState(); } class _ChangePasswordLastStepScreenState extends State { final confirmpasswordController = TextEditingController(); @override Widget build(BuildContext context) { final passwordProvider = context.watch(); final signupProvider = context.watch(); final passwordController = passwordProvider.passwordController; final languageProvider = context.watch(); bool isArabic = languageProvider.currentLangCode == Language.ar; return Scaffold( backgroundColor: Colors.white, appBar: AppBar( backgroundColor: Colors.white, // title: const Txt( // text: 'Change password', // style: TextStyle( // fontSize: 32.0, // fontWeight: FontWeight.bold, // letterSpacing: 1, // color: Colors.black, // ), // ), ), body: Padding( padding: const EdgeInsets.symmetric(horizontal: 14.0, vertical: 20), child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [ Txt( text: "Forgot Password?", style: TextStyle( fontSize: 18, fontWeight: FontWeight.w700, fontFamily: isArabic ? 'Baloo_Bhaijaan_2' : 'Poppins', color: Colors.black, ), ), const SizedBox(height: 20), Txt( text: "Enter your email address below and we'll send you a link to reset your password.", style: TextStyle( fontSize: 15, fontWeight: FontWeight.w500, fontFamily: isArabic ? 'Baloo_Bhaijaan_2' : 'Poppins', color: Colors.black, ), ),const SizedBox(height: 30), CustomTextFieldWidget( controller: passwordController, label: 'Password', icon: Icons.lock_outline, isPassword: true, keybordType: TextInputType.text, ), const SizedBox(height: 20), CustomTextFieldWidget( controller: confirmpasswordController, label: 'Confirm Password', icon: Icons.lock_outline, isPassword: true, keybordType: TextInputType.text, ), const SizedBox(height: 20), Spacer(), Center( child: CustomButton( borderRadius: 25, height: 55, onClick: () async { final emailRegex = RegExp(r'^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$'); final upperCaseRegex = RegExp(r'[A-Z]'); if (passwordController.text != confirmpasswordController.text) { //_showError("Passwords do not match."); AppSnackbar.showError("Error", "Passwords do not match."); return; } if (passwordController.text.length < 8) { //_showError("Password must be at least 8 characters long."); AppSnackbar.showError( "Error", "Password must be at least 8 characters long."); return; } if (!upperCaseRegex.hasMatch(passwordController.text)) { //_showError("Password must contain at least one uppercase letter."); AppSnackbar.showError("Error", "Password must contain at least one uppercase letter."); return; } passwordProvider.setPassword(passwordController.text); signupProvider.ResetPassword(passwordController.text,passwordProvider.phoneController.text,widget.code!); // passwordProvider.changePasswordFinalStep(); String newPassword,String phonenumber,String code }, title: 'Change password', loadercolor: Colors.white, isloading: passwordProvider.loader, width: MediaQuery.of(context).size.width * 0.75, backgroundColor: Theme.of(context).brightness == Brightness.dark ?AppColors.darkPrimaryColor:AppColors.primaryColor, ), ), ], ), ), ); } }