import 'package:wanisdriver/utils/colors.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import 'package:shared_preferences/shared_preferences.dart'; import '../Provider/SignUp_provider.dart'; import '../Provider/language_provider.dart'; import '../config/AppSnackbar.dart'; import '../config/constants/arabe.dart' as Language; import '../widgets/CustomTextFieldWidget.dart'; import '../widgets/custom_button.dart'; import '../widgets/custom_text.dart'; class SignUpScreenAddPassword extends StatefulWidget { const SignUpScreenAddPassword({super.key}); @override State createState() => _SignUpScreenAddPasswordState(); } class _SignUpScreenAddPasswordState extends State { final passwordController = TextEditingController(); final confirmpasswordController = TextEditingController(); @override void initState() { super.initState(); } @override Widget build(BuildContext context) { final languageProvider = context.watch(); bool isArabic = languageProvider.currentLangCode == Language.ar; final isDark = Theme.of(context).brightness == Brightness.dark; final provider = context.watch(); // /Create account return Scaffold( backgroundColor: Theme.of(context).brightness == Brightness.dark? AppColors.blackBackgroundColor: AppColors.whiteBackgroundColor, appBar: AppBar( backgroundColor: Theme.of(context).brightness == Brightness.dark ? AppColors.blackBackgroundColor : AppColors.whiteBackgroundColor, elevation: 0, leading: Padding( padding: const EdgeInsets.all(8.0), child: Container( decoration: BoxDecoration( shape: BoxShape.circle, color: Theme.of(context).brightness == Brightness.dark ? Colors.grey.shade800 : Colors.grey.shade200, ), child: IconButton( icon: Icon( Icons.arrow_back, color: Theme.of(context).brightness == Brightness.dark ? AppColors.white : AppColors.black, size: 20, ), onPressed: () => Navigator.pop(context), ), ), ), title: Txt( text: "Create Password", style: TextStyle( color: Theme.of(context).brightness == Brightness.dark ? AppColors.white : AppColors.black, fontSize: 18, fontWeight: FontWeight.w600, fontFamily: 'Poppins', ), ), centerTitle: true, ), body: SingleChildScrollView( padding: const EdgeInsets.symmetric(horizontal: 10.0, vertical: 30), child: Column( children: [ Container( padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 20), decoration: BoxDecoration( color: Theme.of(context).brightness == Brightness.dark? AppColors.blackBackgroundColor: AppColors.whiteBackgroundColor, borderRadius: BorderRadius.circular(20), boxShadow: [ BoxShadow( color:Theme.of(context).brightness == Brightness.dark? Colors.white24: Colors.black12, blurRadius: 10, offset: const Offset(0, 5), ), ], ), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Txt( text: 'Create Your Password', style: TextStyle( fontSize: 28, fontWeight: FontWeight.bold, fontFamily: 'Poppins', color: isDark ? AppColors.whiteBackgroundColor : AppColors.blackBackgroundColor, ), ), const SizedBox(height: 16), Txt( text: 'You ll need this password to sign in to your account', style: TextStyle( fontSize: 16, fontFamily: 'Poppins', fontWeight: FontWeight.w600, color: isDark ? AppColors.darkSecondaryText : const Color(0xFF666666), ), ), const SizedBox(height: 30), //Password CustomTextFieldWidget( controller: passwordController, label: 'Password', icon: Icons.lock_outline, isPassword: true, keybordType: TextInputType.text, isRequired: true, ), const SizedBox(height: 20), //Confirm password CustomTextFieldWidget( controller: confirmpasswordController, label: 'Confirm Password', icon: Icons.lock_outline, isPassword: true, keybordType: TextInputType.text, isRequired: true, ), const SizedBox(height: 20), //Next button CustomButton( borderRadius: 10, height: 50, isloading: provider.loader, onClick: () async { final password = passwordController.text; final confirmPassword = confirmpasswordController.text; if (password != confirmPassword) { //_showError("Passwords do not match."); AppSnackbar.showError("Error", "Passwords do not match."); return; } if (password.length < 8) { //_showError("Password must be at least 8 characters long."); AppSnackbar.showError("Error", "Password must be at least 8 characters long."); return; } final provider = Provider.of(context, listen: false); // All validations passed provider.setPassword(password); // Navigator.push( // context, // MaterialPageRoute( // builder: (_) => OtpVerificationScreen(phoneNumber: phoneController.text.trim(),)), // ); await provider.signUpDriver(); }, title: 'Continue', width: MediaQuery.of(context).size.width , backgroundColor: Theme.of(context).brightness == Brightness.dark ?AppColors.darkPrimaryColor:AppColors.primaryColor, ), ], ), ), const SizedBox(height: 25), ], ), ), ); } }