diff --git a/lib/config/my_router.dart b/lib/config/my_router.dart index f413c71d..cdfe3b13 100644 --- a/lib/config/my_router.dart +++ b/lib/config/my_router.dart @@ -304,7 +304,6 @@ import '../presentation/Screens/auth_verification/otp_verification.dart'; import '../presentation/Screens/profilepage.dart'; import '../presentation/routes/auth_routes/login_route.dart'; import '../presentation/routes/bottom_bar_routes/tab_routes/home_route.dart'; -import '../presentation/routes/drawer_routes/Drawer Items/edit_profile.dart'; import '../presentation/routes/drawer_routes/Drawer Items/feedback.dart'; import '../presentation/routes/drawer_routes/Drawer Items/manage_users.dart'; @@ -313,7 +312,7 @@ final GoRouter router = GoRouter( GoRoute( path: '/', //builder: (context, state) => LoginRoute(), - builder: (context, state) => LoginRoute(), + builder: (context, state) => MyHomePage(), ), GoRoute( path: '/myhomepage', @@ -330,11 +329,10 @@ final GoRouter router = GoRouter( ), ), GoRoute( - path: '/changepassword/:userId', - builder: (context, state) { - final userId = state.pathParameters['userId']!; - return Changepassword(userId: userId); - }, + path: '/changepassword', + builder: (context, state) => Changepassword( + userId: '', + ), ), GoRoute( path: '/createNewPw/:userId/:email', @@ -358,11 +356,10 @@ final GoRouter router = GoRouter( builder: (context, state) => FeedbackForm(), ), GoRoute( - path: '/profile/:userId', - builder: (context, state) { - final userId = state.pathParameters['userId']!; - return ProfileScreen(userId: userId); - }, + path: '/profile', + builder: (context, state) => ProfileScreen( + userId: '', + ), ), // GoRoute( // path: '/manageuser', @@ -372,13 +369,10 @@ final GoRouter router = GoRouter( // return ManageUserRouter(title: title); // }, // ), - GoRoute( - path: '/editProfile', - builder: (context, state) => EditProfile(), - ), GoRoute( path: '/manageuser', builder: (context, state) => ManageUserRouter(), ), ], ); + diff --git a/lib/presentation/Screens/auth_verification/changepassword.dart b/lib/presentation/Screens/auth_verification/changepassword.dart index 9b86c2e1..702da9a2 100644 --- a/lib/presentation/Screens/auth_verification/changepassword.dart +++ b/lib/presentation/Screens/auth_verification/changepassword.dart @@ -58,7 +58,7 @@ class _ResetPasswordScreenState extends State { //print('userDetails ->: $userData'); if (userData['items'].isNotEmpty) { // Email exists; retrieve user ID - // final userId = userData['items'][0]['id']; + final userId = userData['items'][0]['id']; // Proceed with OTP request final otpResponse = await http.post( @@ -87,15 +87,17 @@ class _ResetPasswordScreenState extends State { ); // Navigate to the Email Verification screen - context.go( - '/mailverification', - extra: { - 'email': email, - 'userId': widget.userId, // Pass user ID to the next screen - 'otp': otp, - 'otpId': otpId, - 'sendVerificationCode': sendVerificationCode, - }, + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => EmailVerificationScreen( + email: email, + userId: widget.userId, // Pass user ID to the next screen + otp: otp, + otpId: otpId, + sendVerificationCode: sendVerificationCode, + ), + ), ); } else { final error = @@ -130,12 +132,6 @@ class _ResetPasswordScreenState extends State { } } - @override - void initState() { - super.initState(); - print(widget.userId); - } - @override void dispose() { _emailController.dispose(); diff --git a/lib/presentation/Screens/auth_verification/registration.dart b/lib/presentation/Screens/auth_verification/registration.dart index 41c6d0e1..97204028 100644 --- a/lib/presentation/Screens/auth_verification/registration.dart +++ b/lib/presentation/Screens/auth_verification/registration.dart @@ -275,7 +275,7 @@ class _RegisterScreenState extends State { buildIconContainer(Icons.report, Color(0xFF7DAFBC)), SizedBox(height: 20), Text( - "Your registration is pending for verification", + "Your registration is pending for Admin Approval.", textAlign: TextAlign.center, style: TextStyle( fontSize: 16, @@ -284,7 +284,7 @@ class _RegisterScreenState extends State { ), SizedBox(height: 10), Text( - "Kindly verify your mail to proceed further.", + "Access will be granted once your account is approved.", textAlign: TextAlign.center, style: TextStyle( fontSize: 14, @@ -293,11 +293,14 @@ class _RegisterScreenState extends State { ), SizedBox(height: 10), ElevatedButton( - onPressed: () { + onPressed: () => { Navigator.pushReplacement( context, - MaterialPageRoute(builder: (context) => LoginRoute()), - ); + MaterialPageRoute(builder: (context) => LoginRoute() + + //ProfileScreen(userId: userID) + ), + ), }, child: Text( 'Go to Login', @@ -452,8 +455,8 @@ class _RegisterScreenState extends State { suffixIcon: IconButton( icon: Icon( _obscurePassword - ? Icons.visibility_off - : Icons.visibility, + ? Icons.visibility + : Icons.visibility_off, color: Colors.blue, ), onPressed: () { @@ -484,8 +487,8 @@ class _RegisterScreenState extends State { suffixIcon: IconButton( icon: Icon( _obscureConfirmPassword - ? Icons.visibility_off - : Icons.visibility, + ? Icons.visibility + : Icons.visibility_off, color: Colors.blue, ), onPressed: () { diff --git a/lib/presentation/Screens/profilepage.dart b/lib/presentation/Screens/profilepage.dart index 48ce4ac6..c155b517 100644 --- a/lib/presentation/Screens/profilepage.dart +++ b/lib/presentation/Screens/profilepage.dart @@ -306,7 +306,7 @@ class _ProfileScreenState extends State { leading: IconButton( icon: Icon(Icons.arrow_back_ios_new, color: Colors.black), onPressed: () { - print("Back Button"); + context.go('/myhomepage'); }, ), title: Text( diff --git a/lib/presentation/routes/auth_routes/login_route.dart b/lib/presentation/routes/auth_routes/login_route.dart index 5ebb61e0..cbf28f0a 100644 --- a/lib/presentation/routes/auth_routes/login_route.dart +++ b/lib/presentation/routes/auth_routes/login_route.dart @@ -1,9 +1,10 @@ +import 'package:excel/excel.dart'; import 'package:external_repos/external_repos.dart'; import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; import 'package:flutter_hooks/flutter_hooks.dart'; import 'package:go_router/go_router.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; -import 'package:shared_preferences/shared_preferences.dart'; import 'package:the_validator/the_validator.dart'; import 'package:uae_stat/config/my_theme.dart'; import 'package:uae_stat/domain/use_cases/auth_use_case.dart'; @@ -18,322 +19,729 @@ import 'package:uae_stat/presentation/components/space.dart'; import 'package:uae_stat/presentation/components/themed_text_field.dart'; import 'package:uae_stat/presentation/routes/bottom_bar_routes/tab_routes/home_route.dart'; +import '../../Screens/profilepage.dart'; import '../../Screens/auth_verification/registration.dart'; import 'package:pocketbase/pocketbase.dart'; -class LoginRoute extends HookConsumerWidget { - final pb = PocketBase('https://pb.venbait.in'); - // final _pb = PocketBase('http://127.0.0.1:8090'); - LoginRoute({super.key}); - dynamic userData; +// class LoginRoute extends HookConsumerWidget { +// final pb = PocketBase('https://pb.venbait.in'); +// // final _pb = PocketBase('http://127.0.0.1:8090'); +// LoginRoute({super.key}); +// +// static final formKey = GlobalKey(); +// +// Future profileStatus(String userId) async { +// try { +// // Authenticate admin +// final adminAuth = await pb.admins.authWithPassword( +// 'pb@venbainfotech.com', +// 'pb@venbainfotech.com', +// ); +// final String adminToken = adminAuth.token; +// print('adminToken: $adminToken'); +// +// // Fetch user details +// final userDetailsResponse = await pb.collection('users').getOne( +// userId, +// headers: { +// 'Authorization': 'Bearer $adminToken', +// }, +// ); +// print('userDetailsLogin: $userDetailsResponse'); +// +// // Check if 'is_profile_completed' is true or false +// if (userDetailsResponse != null && +// userDetailsResponse.data['is_profile_completed'] != null) { +// return userDetailsResponse.data['is_profile_completed']; +// } else { +// return false; // Default to false if the field is missing or response is null +// } +// } catch (e) { +// print('Error fetching user details: $e'); +// return false; // Return false on error +// } +// } +// +// @override +// Widget build(BuildContext context, WidgetRef ref) { +// final emailCtl = useTextEditingController(); +// final pwCtl = useTextEditingController(); +// final forgotPwBtn = TextButton( +// onPressed: () async { +// final forgotPwFormKey = GlobalKey(); +// final email = await showDialog( +// context: context, +// builder: (dialogCtx) => AlertDialog( +// title: Text( +// context.translate( +// 'Reset Password', +// 'إعادة تعيين كلمة المرور', +// ), +// ), +// content: Form( +// key: forgotPwFormKey, +// child: TextFormField( +// validator: FieldValidator.email(), +// controller: emailCtl, +// decoration: InputDecoration( +// labelText: context.translate( +// 'Email address', +// 'عنوان البريد الإلكتروني', +// ), +// ), +// ), +// ), +// actions: [ +// TextButton( +// onPressed: Navigator.of(dialogCtx, rootNavigator: true).pop, +// child: Text( +// context.translate( +// 'Return', +// 'يعود', +// ), +// ), +// ), +// ElevatedButton( +// onPressed: () { +// final isValid = forgotPwFormKey.currentState!.validate(); +// if (!isValid) return; +// Navigator.of(dialogCtx, rootNavigator: true).pop( +// emailCtl.text, +// ); +// }, +// child: Text( +// context.translate( +// 'Send Reset Email', +// 'إرسال إعادة تعيين البريد الإلكتروني', +// ), +// ), +// ), +// ], +// ), +// ); +// if (email == null) return; +// if (!context.mounted) return; +// await context.loaderWithErrorDialog( +// () => ref +// .read( +// authUseCaseProvider.notifier, +// ) +// .requestPwReset(email), +// ); +// if (!context.mounted) return; +// context.simpleDialog( +// title: context.translate( +// 'Success!', +// 'نجاح', +// ), +// content: context.translate( +// 'An email has been sent to $email with further details.', +// 'تم إرسال بريد إلكتروني إلى $email يتضمن المزيد من التفاصيل.', +// ), +// ); +// }, +// child: Text( +// context.translate( +// 'Forgot Password?', +// 'هل نسيت كلمة السر؟', +// ), +// style: TextStyle( +// fontFamily: context.translate( +// 'Roboto', +// 'NotoKufi', +// ), +// fontWeight: FontWeight.bold, +// fontSize: 14, +// color: MyTheme.topicColor(IndicatorTopic.economy).shade600, +// ), +// ), +// ); +// final loginBtn = SizedBox( +// width: double.infinity, +// child: ElevatedButton( +// onPressed: () { +// context.go('/profile'); +// }, +// // async { +// // final isValid = formKey.currentState!.validate(); +// // if (!isValid) return; +// // final session = await context.loaderWithErrorDialog( +// // () => ref +// // .read( +// // authUseCaseProvider.notifier, +// // ) +// // .login( +// // emailCtl.text, +// // pwCtl.text, +// // ), +// // errorDialogBuilder: ( +// // error, [ +// // StackTrace? stackTrace, +// // ]) { +// // if (error == LoginError.invalidEmailPw) { +// // return context.simpleDialog( +// // title: context.translate( +// // 'Incorrect credentials', +// // 'أوراق غير صحيحة', +// // ), +// // content: context.translate( +// // 'Your email or password is invalid. Please try again.', +// // 'بريدك الإلكتروني أو كلمة المرور غير صالحة. حاول مرة اخرى.', +// // ), +// // ); +// // } +// // if (error == LoginError.emailAddressNotVerified) { +// // return context.simpleDialog( +// // title: context.translate( +// // 'Verification Error', +// // 'خطأ التحقق', +// // ), +// // content: context.translate( +// // '${emailCtl.text} is not a verified email address. Please check your email for a verification link.', +// // '${emailCtl.text} ليس عنوان بريد إلكتروني تم التحقق منه. يرجى التحقق من بريدك الإلكتروني للحصول على رابط التحقق.', +// // ), +// // extraAction: ElevatedButton( +// // onPressed: () { +// // context.go('/profile'); +// // }, +// // // async { +// // // Navigator.of( +// // // context, +// // // rootNavigator: true, +// // // ).pop(); +// // // await context.loaderWithErrorDialog( +// // // () => ref +// // // .read(authUseCaseProvider.notifier) +// // // .requestVerificationEmail(emailCtl.text), +// // // ); +// // // if (!context.mounted) return; +// // // context.simpleDialog( +// // // title: 'Email Re-sent', +// // // content: +// // // 'We\'ve sent you the verification email at ${emailCtl.text} again.', +// // // ); +// // // }, +// // child: Text( +// // context.translate( +// // 'I did not receive an email', +// // 'لم أتلق بريدًا إلكترونيًا', +// // ), +// // ), +// // ), +// // ); +// // } +// // return context.simpleDialog(); +// // }, +// // ); +// // // if (!context.mounted || session == null) return; +// // // Extract userId from the session +// // // final userId = session.id; +// // // +// // // final bool isUpdate = await profileStatus(userId); +// // // +// // // print('Is profile completed: $isUpdate'); +// // +// // // if (isUpdate) { +// // // Navigator.pushReplacement( +// // // context, +// // // MaterialPageRoute(builder: (context) => DemoHome()), +// // // ); +// // // } +// // // else { +// // +// // // Navigator.pushReplacement( +// // // context, +// // // MaterialPageRoute( +// // // builder: (context) => ProfileScreen(userId: userId)), +// // // ); +// // //} +// // +// // // context.go('/${context.language}/${BottomNavBarItem.home.routePath}'); +// // }, +// style: ButtonStyle( +// shape: WidgetStatePropertyAll( +// RoundedRectangleBorder( +// borderRadius: BorderRadius.circular(10), +// ), +// ), +// padding: const WidgetStatePropertyAll( +// EdgeInsets.symmetric(vertical: 10.5), +// ), +// textStyle: WidgetStatePropertyAll( +// TextStyle( +// fontFamily: context.translate( +// 'Roboto', +// 'NotoKufi', +// ), +// fontSize: 16, +// fontWeight: FontWeight.w600, +// ), +// ), +// backgroundColor: WidgetStatePropertyAll( +// MyTheme.topicColor(IndicatorTopic.social), +// ), +// // surfaceTintColor: MaterialStatePropertyAll( +// // MyTheme.economy[800], +// // ), +// foregroundColor: const WidgetStatePropertyAll( +// Colors.white, +// ), +// ), +// child: Row( +// mainAxisAlignment: MainAxisAlignment.center, +// children: [ +// Text( +// context.translate( +// 'Login', +// 'تسجيل الدخول', +// ), +// ), +// 6.horizontalSpace, +// const Icon(Icons.chevron_right_outlined), +// ], +// ), +// ), +// ); +// final form = Form( +// key: formKey, +// child: Column( +// children: [ +// ThemedFormField( +// hintText: context.translate( +// 'Email', +// 'بريد إلكتروني', +// ), +// validator: FieldValidator.email(), +// imgPath: MiscIconAssetPath.person, +// controller: emailCtl, +// ), +// 15.verticalSpace, +// ThemedFormField( +// validator: (text) { +// if (text!.length < 10) { +// return 'The password must be at least 10 characters'; +// } +// return FieldValidator.password(minLength: 10)(text); +// }, +// hintText: context.translate( +// 'Password', +// 'كلمة المرور', +// ), +// imgPath: MiscIconAssetPath.lock, +// controller: pwCtl, +// isObscurable: true, +// ), +// // 6.verticalSpace, +// Align( +// alignment: AlignmentDirectional.topEnd, +// child: forgotPwBtn, +// ), +// 10.verticalSpace, +// loginBtn, +// ], +// ), +// ); +// final helloAndPleaseLoginTexts = Column( +// children: [ +// Text( +// context.translate( +// 'Hello Again!', +// 'مرحبا مجددا!', +// ), +// style: TextStyle( +// fontFamily: context.translate( +// 'Roboto', +// 'NotoKufi', +// ), +// fontSize: 40, +// fontWeight: FontWeight.w300, +// ), +// ), +// 10.verticalSpace, +// Text( +// context.translate( +// 'Please login to access UAE’s key official statistics', +// 'يرجى تسجيل الدخول للوصول إلى الإحصاءات الرسمية الرئيسية لدولة الإمارات العربية المتحدة', +// ), +// textAlign: TextAlign.center, +// style: TextStyle( +// fontFamily: context.translate( +// 'Roboto', +// 'NotoKufi', +// ), +// fontSize: 18, +// color: const Color(0xff898C81), +// fontWeight: FontWeight.w700, +// ), +// ), +// ], +// ); +// final dontHaveAnAccountRegisterBtn = TextButton( +// onPressed: () => { +// Navigator.push( +// context, +// MaterialPageRoute(builder: (context) => RegisterScreen()), +// ), +// }, +// child: Text.rich( +// textAlign: TextAlign.center, +// TextSpan( +// style: TextStyle( +// fontFamily: context.translate( +// 'Roboto', +// 'NotoKufi', +// ), +// fontSize: 18, +// fontWeight: FontWeight.bold, +// ), +// children: [ +// TextSpan( +// text: context.translate( +// 'Don\'t have an account? ', +// 'ليس لديك حساب؟', +// ), +// style: const TextStyle( +// color: Color(0xff898C81), +// ), +// ), +// const TextSpan( +// text: ' ', +// ), +// TextSpan( +// text: context.translate( +// 'Register Now', +// 'سجل الان', +// ), +// style: TextStyle( +// color: MyTheme.topicColor(IndicatorTopic.economy).shade600, +// ), +// ), +// ], +// ), +// ), +// ); +// final continueAsGuestBtn = SizedBox( +// width: double.infinity, +// child: ElevatedButton( +// onPressed: () => context +// .go('/${context.language}/${BottomNavBarItem.home.routePath}'), +// style: ButtonStyle( +// shape: WidgetStatePropertyAll( +// RoundedRectangleBorder( +// borderRadius: BorderRadius.circular(10), +// ), +// ), +// padding: const WidgetStatePropertyAll( +// EdgeInsets.symmetric(vertical: 10.5), +// ), +// textStyle: WidgetStatePropertyAll( +// TextStyle( +// fontFamily: context.translate( +// 'Roboto', +// 'NotoKufi', +// ), +// fontSize: 16, +// fontWeight: FontWeight.w600, +// ), +// ), +// backgroundColor: WidgetStatePropertyAll( +// MyTheme.topicColor(IndicatorTopic.environment), +// ), +// foregroundColor: const WidgetStatePropertyAll( +// Colors.white, +// ), +// ), +// child: Row( +// mainAxisAlignment: MainAxisAlignment.center, +// children: [ +// Text( +// context.translate( +// 'Continue as Guest', +// 'استمر كضيف', +// ), +// ), +// 6.horizontalSpace, +// const Icon(Icons.chevron_right_outlined), +// ], +// ), +// ), +// ); +// final fcscBanner = Image.asset( +// BannerAssetPath.fcsc, +// height: 56, +// ); +// final screenWidth = MediaQuery.of(context).size.width; +// final listViewHorizontalPadding = +// screenWidth < 700 ? 30 : 30 + (screenWidth - 700) / 2; +// final scaffoldBody = ListView( +// padding: EdgeInsets.symmetric( +// horizontal: listViewHorizontalPadding.toDouble(), +// ), +// children: [ +// 36.verticalSpace, +// const Align( +// alignment: AlignmentDirectional.topEnd, +// child: LangToggle(), +// ), +// 16.verticalSpace, +// helloAndPleaseLoginTexts, +// 42.verticalSpace, +// form, +// 20.verticalSpace, +// dontHaveAnAccountRegisterBtn, +// 36.verticalSpace, +// continueAsGuestBtn, +// 72.verticalSpace, +// fcscBanner, +// ], +// ); +// final bgScaffold = Scaffold( +// backgroundColor: Colors.white, +// body: SafeArea(child: scaffoldBody), +// ); +// return bgScaffold; +// } +// } - static final formKey = GlobalKey(); - - Future profileStatus(String userId) async { - try { - // Authenticate admin - final adminAuth = await pb.admins.authWithPassword( - 'pb@venbainfotech.com', - 'pb@venbainfotech.com', - ); - final String adminToken = adminAuth.token; - print('adminToken: $adminToken'); - - // Fetch user details - final userDetailsResponse = await pb.collection('users').getOne( - userId, - headers: { - 'Authorization': 'Bearer $adminToken', - }, - ); - - print('userDetailsLogin: $userDetailsResponse'); - - // Check if user is verified - final bool? isVerified = userDetailsResponse.data['verified']; - final bool? isUserMailVerified = - userDetailsResponse.data['user_mail_verify']; - - // Check admin and email verification statuses - if (isVerified == false) { - throw Exception('Admin not approved'); - } - if (isUserMailVerified == false) { - throw Exception('Email not verified'); - } - userData = userDetailsResponse; - // Check if 'is_profile_completed' is true - final bool isProfileCompleted = - userDetailsResponse.data['is_profile_completed'] ?? false; - - return isProfileCompleted; - } catch (e) { - print('Error fetching user details: $e'); - rethrow; - } - } - - Future saveUserId(String userId) async { - final prefs = await SharedPreferences.getInstance(); - await prefs.setString('userId', userId); // Save userId locally - } +class LoginRoute extends StatefulWidget { + const LoginRoute({super.key}); @override - Widget build(BuildContext context, WidgetRef ref) { - final emailCtl = useTextEditingController(); - final pwCtl = useTextEditingController(); - final forgotPwBtn = TextButton( - onPressed: () async { - final forgotPwFormKey = GlobalKey(); - final email = await showDialog( - context: context, - builder: (dialogCtx) => AlertDialog( - title: Text( - context.translate( - 'Reset Password', - 'إعادة تعيين كلمة المرور', - ), + State createState() => _LoginRouteState(); +} + +class _LoginRouteState extends State { + final _formKey = GlobalKey(); + bool _obscurePassword = true; + @override + Widget build(BuildContext context) { + double screenheight = MediaQuery.of(context).size.height; + double screenwidth = MediaQuery.of(context).size.width; + return Scaffold( + body: Padding( + padding: const EdgeInsets.all(20.0), + child: Form( + key: _formKey, + child: SingleChildScrollView( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + SizedBox(height: screenheight / 6), + Text( + 'Hello Again !', + style: TextStyle( + fontSize: 32, fontWeight: FontWeight.w400), + ), + SizedBox(height: 5), + Text('Please login to access',style: TextStyle( + fontFamily: context.translate( + 'Roboto', + 'NotoKufi', + ), + color: Color(0xFF898C81), + fontSize: 18, fontWeight: FontWeight.bold),), + Text("UAE's key official statistics",style: TextStyle( + fontFamily: context.translate( + 'Roboto', + 'NotoKufi', + ), + color: Color(0xFF898C81), + fontSize: 16, fontWeight: FontWeight.bold),), + + SizedBox(height: 10), + // Display this if registration is pending approval + TextFormField( + // controller: _usernameController, + // focusNode: _focusNodes[0], + decoration: InputDecoration( + hintText: "Username", + //hintText: _showHints[0] ? 'Username' : null, + prefixIcon: Image.asset("assets/icons/misc/person.png",scale: 2,color: Colors.lightBlueAccent,), + border: OutlineInputBorder(borderRadius: BorderRadius.circular(15)), + focusedBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(10), + borderSide: BorderSide(color: Colors.blue.shade900,) + ), + enabledBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(10), // Keep rounded corners + borderSide: BorderSide( + color: Colors.blue,// Default border color + width: 1.0, // Border width when not focused + ), + ), + counterText: '', + ), + //validator: _validateUsername, + maxLength: + 40, // Set the maximum length to 20 characters + //maxLengthEnforcement: MaxLengthEnforcement.enforced, + ), + SizedBox(height: 20), + TextFormField( + // controller: _passwordController, + // focusNode: _focusNodes[2], + // obscureText: _obscurePassword, + decoration: InputDecoration( + hintText: "Password", + // hintText: _showHints[2] ? 'Enter your password' : null, + prefixIcon: Image.asset("assets/icons/misc/lock.png",scale: 2,color: Colors.lightBlueAccent,), + suffixIcon: IconButton( + icon: Icon( + _obscurePassword + ? Icons.visibility + : Icons.visibility_off, + color: Colors.grey, + ), + onPressed: () { + setState(() { + _obscurePassword = !_obscurePassword; + }); + }, + ), + border: OutlineInputBorder(borderRadius: BorderRadius.circular(15)), + focusedBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(10), + borderSide: BorderSide(color: Colors.blue.shade900,), + + ), + enabledBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(10), // Keep rounded corners + borderSide: BorderSide( + color: Colors.blue,// Default border color + width: 1.0, // Border width when not focused + ), + ), + counterText: '', + ), + //validator: _validatePassword, + maxLength: 40, + maxLengthEnforcement: MaxLengthEnforcement.enforced, + ), + + SizedBox(height: 10), + Row(mainAxisAlignment: MainAxisAlignment.end, + children: [Text("Forgot Password?", + style: TextStyle(color: Color(0xFF985400),fontWeight: FontWeight.bold + ),)],), + SizedBox(height: 20), + SizedBox( + width: screenwidth, + child: ElevatedButton( + onPressed: (){ + context.go('/profile'); + }, + //_registerUser, + style: ElevatedButton.styleFrom( + backgroundColor: Color( + 0xFFA7887A), // Brownish color for Register + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(10), + ), + ), + child: Row( + mainAxisSize: MainAxisSize.min, + children: [ + Text( + "Login", + style: TextStyle( + fontSize: 16, color: Colors.white), + ), + SizedBox(width: 8), + Icon(Icons.arrow_forward_ios, + color: Colors.white, + size: 10, + ), + ], + ), + ), + ), + SizedBox(height: screenheight/20), + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text( + "Don't have an account? ", + style: TextStyle( + fontFamily: context.translate( + 'Roboto', + 'NotoKufi', + ), + color: Color(0xFF898C81), + fontSize: 18, fontWeight: FontWeight.bold), + ), + InkWell( + onTap: (){ + context.go('/registration'); + }, + child: Text( + " Register Now", + style: TextStyle( + fontFamily: context.translate( + 'Roboto', + 'NotoKufi', + ), + color: Color(0xFF985400), + fontSize: 18, fontWeight: FontWeight.bold), + ), + ), + ],), + + SizedBox( + height: screenheight/20, + ), + SizedBox( + width: screenwidth, + child: ElevatedButton( + onPressed: () { + context.go('/myhomepage'); + }, + style: ElevatedButton.styleFrom( + backgroundColor: Color( + 0xFF82AFCB), // Blueish color for Login + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(10), + ), + ), + child: Row( + mainAxisSize: MainAxisSize.min, + children: [ + Text( + "Continue as guest", + style: TextStyle( + fontSize: 16, + color: Colors.white, + ), + ), + SizedBox(width: 8), + Icon(Icons.arrow_forward_ios, + color: Colors.white,size: 10,), + ], + ), + ), + ), + SizedBox( + height: screenheight/15, + ), + Center( + child: Container( + height: screenheight / 13, + width: screenwidth / 3, + decoration: BoxDecoration( + image: DecorationImage( + image: AssetImage( + "assets/splash_screen/logo.png"), // Background image asset + fit: BoxFit.fill, + ), + ), + )) + ], ), - content: Form( - key: forgotPwFormKey, - child: TextFormField( - validator: FieldValidator.email(), - controller: emailCtl, - decoration: InputDecoration( - labelText: context.translate( - 'Email address', - 'عنوان البريد الإلكتروني', - ), - ), - ), - ), - actions: [ - TextButton( - onPressed: Navigator.of(dialogCtx, rootNavigator: true).pop, - child: Text( - context.translate( - 'Return', - 'يعود', - ), - ), - ), - ElevatedButton( - onPressed: () { - final isValid = forgotPwFormKey.currentState!.validate(); - if (!isValid) return; - Navigator.of(dialogCtx, rootNavigator: true).pop( - emailCtl.text, - ); - }, - child: Text( - context.translate( - 'Send Reset Email', - 'إرسال إعادة تعيين البريد الإلكتروني', - ), - ), - ), - ], ), - ); - if (email == null) return; - if (!context.mounted) return; - await context.loaderWithErrorDialog( - () => ref - .read( - authUseCaseProvider.notifier, - ) - .requestPwReset(email), - ); - if (!context.mounted) return; - context.simpleDialog( - title: context.translate( - 'Success!', - 'نجاح', - ), - content: context.translate( - 'An email has been sent to $email with further details.', - 'تم إرسال بريد إلكتروني إلى $email يتضمن المزيد من التفاصيل.', - ), - ); - }, - child: Text( - context.translate( - 'Forgot Password?', - 'هل نسيت كلمة السر؟', - ), - style: TextStyle( - fontFamily: context.translate( - 'Roboto', - 'NotoKufi', - ), - fontWeight: FontWeight.bold, - fontSize: 14, - color: MyTheme.topicColor(IndicatorTopic.economy).shade600, - ), - ), - ); - final loginBtn = SizedBox( - width: double.infinity, - child: ElevatedButton( - onPressed: () async { - final isValid = formKey.currentState!.validate(); - if (!isValid) return; - final session = await context.loaderWithErrorDialog( - () => ref - .read( - authUseCaseProvider.notifier, - ) - .login( - emailCtl.text, - pwCtl.text, - ), - errorDialogBuilder: ( - error, [ - StackTrace? stackTrace, - ]) { - if (error == LoginError.invalidEmailPw) { - return context.simpleDialog( - title: context.translate( - 'Incorrect credentials', - 'أوراق غير صحيحة', - ), - content: context.translate( - 'Your email or password is invalid. Please try again.', - 'بريدك الإلكتروني أو كلمة المرور غير صالحة. حاول مرة اخرى.', - ), - ); - } - // if (error == LoginError.emailAddressNotVerified) { - // return context.simpleDialog( - // title: context.translate( - // 'Verification Error', - // 'خطأ التحقق', - // ), - // content: context.translate( - // '${emailCtl.text} is not a verified email address. Please check your email for a verification link.', - // '${emailCtl.text} ليس عنوان بريد إلكتروني تم التحقق منه. يرجى التحقق من بريدك الإلكتروني للحصول على رابط التحقق.', - // ), - // extraAction: ElevatedButton( - // onPressed: () async { - // Navigator.of( - // context, - // rootNavigator: true, - // ).pop(); - // await context.loaderWithErrorDialog( - // () => ref - // .read(authUseCaseProvider.notifier) - // .requestVerificationEmail(emailCtl.text), - // ); - // if (!context.mounted) return; - // context.simpleDialog( - // title: 'Email Re-sent', - // content: - // 'We\'ve sent you the verification email at ${emailCtl.text} again.', - // ); - // }, - // child: Text( - // context.translate( - // 'I did not receive an email', - // 'لم أتلق بريدًا إلكترونيًا', - // ), - // ), - // ), - // ); - // } - return context.simpleDialog(); - }, - ); - - if (!context.mounted || session == null) return; - final userId = session.id; - if (userId.isNotEmpty) { - await saveUserId(userId); - } - try { - final bool isProfileComplete = await profileStatus(userId); - print(isProfileComplete); - if (isProfileComplete) { - print('home'); - context.go('/myhomepage'); - } else { - print('profile'); - if (userId != null && userId.isNotEmpty) { - context.go('/profile/$userId'); - } else { - print('Error: userId is null or empty.'); - } - } - } catch (e) { - // Handle specific errors based on their message - if (e.toString().contains('Admin not approved')) { - context.simpleDialog( - title: context.translate( - 'Admin Approval Required', 'موافقة المسؤول مطلوبة'), - content: context.translate( - 'Your account has not been approved by the admin.', - 'لم تتم الموافقة على حسابك من قبل المسؤول.', - ), - ); - } else if (e.toString().contains('Email not verified')) { - context.simpleDialog( - title: context.translate( - 'Email Not Verified', 'البريد الإلكتروني غير مُحقق'), - content: context.translate( - 'Your email address is not verified. Please check your email.', - 'عنوان بريدك الإلكتروني غير مُحقق. يرجى التحقق من بريدك الإلكتروني.', - ), - ); - } else { - print('Unexpected error: $e'); - } - } - - // context.go('/${context.language}/${BottomNavBarItem.home.routePath}'); - }, - style: ButtonStyle( - shape: WidgetStatePropertyAll( - RoundedRectangleBorder( - borderRadius: BorderRadius.circular(10), - ), - ), - padding: const WidgetStatePropertyAll( - EdgeInsets.symmetric(vertical: 10.5), - ), - textStyle: WidgetStatePropertyAll( - TextStyle( - fontFamily: context.translate( - 'Roboto', - 'NotoKufi', - ), - fontSize: 16, - fontWeight: FontWeight.w600, - ), - ), - backgroundColor: WidgetStatePropertyAll( - MyTheme.topicColor(IndicatorTopic.social), - ), - // surfaceTintColor: MaterialStatePropertyAll( - // MyTheme.economy[800], - // ), - foregroundColor: const WidgetStatePropertyAll( - Colors.white, - ), - ), - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Text( - context.translate( - 'Login', - 'تسجيل الدخول', - ), - ), - 6.horizontalSpace, - const Icon(Icons.chevron_right_outlined), - ], ), ), ); +<<<<<<< HEAD +======= final form = Form( key: formKey, child: Column( @@ -532,5 +940,6 @@ class LoginRoute extends HookConsumerWidget { body: SafeArea(child: scaffoldBody), ); return bgScaffold; +>>>>>>> b0c5ebce3deb7da2aa24b0ea5ffe684df7dfb7bf } } diff --git a/pubspec.lock b/pubspec.lock index 589a7e9d..663307ad 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -414,10 +414,10 @@ packages: dependency: "direct dev" description: name: flutter_launcher_icons - sha256: "619817c4b65b322b5104b6bb6dfe6cda62d9729bd7ad4303ecc8b4e690a67a77" + sha256: "31cd0885738e87c72d6f055564d37fabcdacee743b396b78c7636c169cac64f5" url: "https://pub.dev" source: hosted - version: "0.14.1" + version: "0.14.2" flutter_lints: dependency: "direct dev" description: @@ -573,10 +573,10 @@ packages: dependency: "direct main" description: name: go_router - sha256: "8660b74171fafae4aa8202100fa2e55349e078281dadc73a241eb8e758534d9d" + sha256: "2fd11229f59e23e967b0775df8d5948a519cd7e1e8b6e849729e010587b46539" url: "https://pub.dev" source: hosted - version: "14.6.1" + version: "14.6.2" graphs: dependency: transitive description: @@ -733,10 +733,10 @@ packages: dependency: transitive description: name: io - sha256: "2ec25704aba361659e10e3e5f5d672068d332fc8ac516421d483a11e5cbd061e" + sha256: dfd5a80599cf0165756e3181807ed3e77daf6dd4137caaad72d0b7931597650b url: "https://pub.dev" source: hosted - version: "1.0.4" + version: "1.0.5" js: dependency: transitive description: @@ -821,10 +821,10 @@ packages: dependency: "direct main" description: name: mailer - sha256: "21fde1497c79f402cb5fa7c50abd58927d360139e492546c941ee10767684fac" + sha256: e907087cd00719898c493f720dd326af73b00b406ab4af8e79f15d7c5fc24035 url: "https://pub.dev" source: hosted - version: "6.2.0" + version: "6.3.0" marquee: dependency: "direct main" description: @@ -861,10 +861,10 @@ packages: dependency: transitive description: name: mime - sha256: "801fd0b26f14a4a58ccb09d5892c3fbdeff209594300a542492cf13fba9d247a" + sha256: "41a20518f0cb1256669420fdba0cd90d21561e560ac240f26ef8322e45bb7ed6" url: "https://pub.dev" source: hosted - version: "1.0.6" + version: "2.0.0" nested: dependency: transitive description: @@ -877,10 +877,10 @@ packages: dependency: transitive description: name: package_config - sha256: "1c5b77ccc91e4823a5af61ee74e6b972db1ef98c2ff5a18d3161c982a55448bd" + sha256: "92d4488434b520a62570293fbd33bb556c7d49230791c1b4bbd973baf6d2dc67" url: "https://pub.dev" source: hosted - version: "2.1.0" + version: "2.1.1" path: dependency: transitive description: @@ -901,18 +901,18 @@ packages: dependency: transitive description: name: path_provider_android - sha256: "8c4967f8b7cb46dc914e178daa29813d83ae502e0529d7b0478330616a691ef7" + sha256: "4adf4fd5423ec60a29506c76581bc05854c55e3a0b72d35bb28d661c9686edf2" url: "https://pub.dev" source: hosted - version: "2.2.14" + version: "2.2.15" path_provider_foundation: dependency: transitive description: name: path_provider_foundation - sha256: f234384a3fdd67f989b4d54a5d73ca2a6c422fa55ae694381ae0f4375cd1ea16 + sha256: "4843174df4d288f5e29185bd6e72a6fbdf5a4a4602717eed565497429f179942" url: "https://pub.dev" source: hosted - version: "2.4.0" + version: "2.4.1" path_provider_linux: dependency: transitive description: @@ -989,10 +989,10 @@ packages: dependency: transitive description: name: pub_semver - sha256: "40d3ab1bbd474c4c2328c91e3a7df8c6dd629b79ece4c4bd04bee496a224fb0c" + sha256: "7b3cfbf654f3edd0c6298ecd5be782ce997ddf0e00531b9464b55245185bbbbd" url: "https://pub.dev" source: hosted - version: "2.1.4" + version: "2.1.5" pubspec_parse: dependency: transitive description: @@ -1100,10 +1100,10 @@ packages: dependency: transitive description: name: shared_preferences_android - sha256: "3b9febd815c9ca29c9e3520d50ec32f49157711e143b7a4ca039eb87e8ade5ab" + sha256: "7f172d1b06de5da47b6264c2692ee2ead20bbbc246690427cdb4fc301cd0c549" url: "https://pub.dev" source: hosted - version: "2.3.3" + version: "2.3.4" shared_preferences_foundation: dependency: transitive description: @@ -1272,10 +1272,10 @@ packages: dependency: transitive description: name: timing - sha256: "70a3b636575d4163c477e6de42f247a23b315ae20e86442bebe32d3cabf61c32" + sha256: "62ee18aca144e4a9f29d212f5a4c6a053be252b895ab14b5821996cff4ed90fe" url: "https://pub.dev" source: hosted - version: "1.0.1" + version: "1.0.2" typed_data: dependency: transitive description: @@ -1360,10 +1360,10 @@ packages: dependency: transitive description: name: video_player_avfoundation - sha256: "0b146e5d82e886ff43e5a46c6bcbe390761b802864a6e2503eb612d69a405dfa" + sha256: "33224c19775fd244be2d6e3dbd8e1826ab162877bd61123bf71890772119a2b7" url: "https://pub.dev" source: hosted - version: "2.6.3" + version: "2.6.5" video_player_platform_interface: dependency: transitive description: