From d33f051251bfdede0f72ce52b4d018312ce68f1b Mon Sep 17 00:00:00 2001 From: VINISTAN Date: Fri, 13 Dec 2024 17:22:28 +0530 Subject: [PATCH] Frontent design match --- lib/config/my_router.dart | 21 +- .../auth_verification/changepassword.dart | 25 +- .../auth_verification/registration.dart | 826 ++++++------ lib/presentation/Screens/profilepage.dart | 2 +- .../routes/auth_routes/login_route.dart | 1172 ++++++++++------- pubspec.lock | 48 +- 6 files changed, 1167 insertions(+), 927 deletions(-) diff --git a/lib/config/my_router.dart b/lib/config/my_router.dart index 62b87e6f..f00be582 100644 --- a/lib/config/my_router.dart +++ b/lib/config/my_router.dart @@ -300,6 +300,7 @@ import '../domain/use_cases/preferences_use_case.dart'; import '../presentation/Screens/auth_verification/changepassword.dart'; import '../presentation/Screens/auth_verification/confirm_password.dart'; import '../presentation/Screens/auth_verification/otp_verification.dart'; +import '../presentation/Screens/auth_verification/registration.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'; @@ -310,8 +311,12 @@ final GoRouter router = GoRouter( routes: [ GoRoute( path: '/', -//builder: (context, state) => LoginRoute(), - builder: (context, state) => MyHomePage(), + builder: (context, state) => LoginRoute(), + //builder: (context, state) => MyHomePage(), + ), + GoRoute( + path: '/login', + builder: (context, state) => LoginRoute(), ), GoRoute( path: '/myhomepage', @@ -352,18 +357,14 @@ final GoRouter router = GoRouter( userId: '', ), ), - // GoRoute( - // path: '/manageuser', - // builder: (context, state) { - // // Retrieve the title from extra or query params - // final title = state.extra as String? ?? 'Manage users'; - // return ManageUserRouter(title: title); - // }, - // ), GoRoute( path: '/manageuser', builder: (context, state) => ManageUserRouter(), ), + GoRoute( + path: '/registration', + builder: (context, state) => RegisterScreen(), + ), ], ); diff --git a/lib/presentation/Screens/auth_verification/changepassword.dart b/lib/presentation/Screens/auth_verification/changepassword.dart index 702da9a2..c5a99d0c 100644 --- a/lib/presentation/Screens/auth_verification/changepassword.dart +++ b/lib/presentation/Screens/auth_verification/changepassword.dart @@ -87,18 +87,19 @@ class _ResetPasswordScreenState extends State { ); // Navigate to the Email Verification screen - 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, - ), - ), - ); + context.go('/mailverification'); + // 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 = jsonDecode(otpResponse.body)['error'] ?? "Unknown error"; diff --git a/lib/presentation/Screens/auth_verification/registration.dart b/lib/presentation/Screens/auth_verification/registration.dart index 66689b16..34f33d5f 100644 --- a/lib/presentation/Screens/auth_verification/registration.dart +++ b/lib/presentation/Screens/auth_verification/registration.dart @@ -208,6 +208,7 @@ class _RegisterScreenState extends State { registrationSuccess = true; registrationFailed = false; // Show success message on success }); + context.go('/profile'); // Navigate to ProfileScreen after successful registration // Navigator.pushReplacement( @@ -241,8 +242,414 @@ class _RegisterScreenState extends State { double screenheight = MediaQuery.of(context).size.height; double screenwidth = MediaQuery.of(context).size.width; - Widget buildIconContainer(IconData icon, Color iconColor) { - return Container( + + return Scaffold( + backgroundColor: Colors.white, + body: registrationSuccess + ? registration_success(context) + : registrationFailed + ? registration_failed(context) + : 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( + 'Register', + style: TextStyle( + fontSize: 32, fontWeight: FontWeight.w400), + ), + SizedBox(height: 10), + Text('Please enter your details'), + + SizedBox(height: 20), + // Display this if registration is pending approval + TextFormField( + controller: _usernameController, + focusNode: _focusNodes[0], + decoration: InputDecoration( + hintText: _showHints[0] ? 'Username' : null, + prefixIcon: Icon( + Icons.person, + color: Colors.blue, + ), + border: OutlineInputBorder(), + counterText: '', + ), + validator: _validateUsername, + maxLength: + 40, // Set the maximum length to 20 characters + maxLengthEnforcement: MaxLengthEnforcement.enforced, + ), + SizedBox(height: 15), + TextFormField( + controller: _emailController, + focusNode: _focusNodes[1], + decoration: InputDecoration( + // hintText: 'Enter your email', + hintText: + _showHints[1] ? 'Enter your email' : null, + prefixIcon: Icon( + Icons.email, + color: Colors.blue, + ), + border: OutlineInputBorder(), + counterText: '', + ), + validator: _validateEmail, + maxLength: 320, + maxLengthEnforcement: MaxLengthEnforcement.enforced, + inputFormatters: [ + LengthLimitingTextInputFormatter( + 320), // Limit to 320 characters + ], + ), + SizedBox(height: 15), + TextFormField( + controller: _passwordController, + focusNode: _focusNodes[2], + obscureText: _obscurePassword, + decoration: InputDecoration( + hintText: + _showHints[2] ? 'Enter your password' : null, + prefixIcon: Icon( + Icons.lock, + color: Colors.blue, + ), + suffixIcon: IconButton( + icon: Icon( + _obscurePassword + ? Icons.visibility + : Icons.visibility_off, + color: Colors.blue, + ), + onPressed: () { + setState(() { + _obscurePassword = !_obscurePassword; + }); + }, + ), + border: OutlineInputBorder(), + counterText: '', + ), + validator: _validatePassword, + maxLength: 40, + maxLengthEnforcement: MaxLengthEnforcement.enforced, + ), + SizedBox(height: 15), + TextFormField( + controller: _confirmpasswordController, + focusNode: _focusNodes[3], + obscureText: _obscureConfirmPassword, + decoration: InputDecoration( + hintText: + _showHints[3] ? 'Confirm password' : null, + prefixIcon: Icon( + Icons.lock, + color: Colors.blue, + ), + suffixIcon: IconButton( + icon: Icon( + _obscureConfirmPassword + ? Icons.visibility + : Icons.visibility_off, + color: Colors.blue, + ), + onPressed: () { + setState(() { + _obscureConfirmPassword = + !_obscureConfirmPassword; + }); + }, + ), + border: OutlineInputBorder(), + counterText: '', + ), + validator: _validateConfirmPassword, + maxLength: 40, + maxLengthEnforcement: MaxLengthEnforcement.enforced, + inputFormatters: [ + LengthLimitingTextInputFormatter( + 64), // Limit to 40 characters + ], + ), + SizedBox(height: 10), + Row( + children: [ + Checkbox( + value: isChecked, + onChanged: (value) { + setState(() { + isChecked = value ?? false; + showError = false; + }); + }, + side: BorderSide( + color: showError ? Colors.red : Colors.grey, + width: 1.5, + ), + ), + Expanded( + child: Text.rich( + TextSpan( + text: 'I agree to ', + children: [ + TextSpan( + text: 'Terms & Conditions', + style: TextStyle(color: Colors.blue), + ), + TextSpan(text: ' and '), + TextSpan( + text: 'Privacy Policy', + style: TextStyle(color: Colors.blue), + ), + ], + ), + ), + ), + ], + ), + if (showError) + Row( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Padding( + padding: const EdgeInsets.only(left: 10.0), + child: Text( + 'Please agree to terms and conditions.', + style: TextStyle( + color: Colors.red[700], + fontSize: 12, + ), + ), + ), + ], + ), + SizedBox(height: 20), + SizedBox( + width: screenwidth / 1.3, + child: ElevatedButton( + onPressed: _registerUser, + style: ElevatedButton.styleFrom( + backgroundColor: Color( + 0xFFA7887A), // Brownish color for Register + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(10), + ), + ), + child: Row( + mainAxisSize: MainAxisSize.min, + children: [ + Text( + "Register", + style: TextStyle( + fontSize: 16, color: Colors.white), + ), + SizedBox(width: 8), + Icon(Icons.arrow_forward, + color: Colors.white), + ], + ), + ), + ), + SizedBox(height: 10), + Text( + "Already have an account?", + style: TextStyle( + fontSize: 16, color: Colors.grey[600]), + ), + SizedBox(height: 10), + SizedBox( + width: screenwidth / 1.3, + child: ElevatedButton( + onPressed: () { + // Add your login logic here + context.go('/login'); + }, + style: ElevatedButton.styleFrom( + backgroundColor: Color( + 0xFF82AFCB), // Blueish color for Login + 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, + color: Colors.white), + ], + ), + ), + ), + SizedBox( + height: 10, + ), + Center( + child: Container( + height: screenheight / 8, + width: screenwidth / 2, + decoration: BoxDecoration( + image: DecorationImage( + image: AssetImage( + "assets/splash_screen/logo.png"), // Background image asset + fit: BoxFit.fill, + ), + ), + )) + ], + ), + ), + ), + ), + ), + ); + } + + Widget registration_failed (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: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + SizedBox(height: screenheight / 8), + buildIconContainer(Icons.report, Colors.red), + SizedBox(height: 20), + Text( + "Sorry ${_usernameController.text}!", + textAlign: TextAlign.center, + style: TextStyle( + fontSize: 16, + fontWeight: FontWeight.w500, + color: Color(0xFF414042)), + ), + SizedBox(height: 10), + Text( + "Your registration process failed. For further assistance, please contact support.", + textAlign: TextAlign.center, + style: TextStyle( + fontSize: 14, + color: Color(0xFF898C81), + ), + ), + SizedBox(height: 10), + ElevatedButton( + onPressed: () => { + setState(() { + registrationFailed = false; + registrationSuccess = false; + _usernameController.clear(); + _emailController.clear(); + _passwordController.clear(); + _confirmpasswordController.clear(); + isChecked = false; + }) + }, + child: Text( + 'Retry', + ), + ), + SizedBox(height: screenheight / 5), + Center( + child: Container( + height: screenheight / 8, + width: screenwidth / 2, + decoration: BoxDecoration( + image: DecorationImage( + image: AssetImage( + "assets/splash_screen/logo.png"), // Background image asset + fit: BoxFit.fill, + ), + ), + )) + ], + ), + ), + ); + } + + Widget registration_success (BuildContext context) { + double screenheight = MediaQuery.of(context).size.height; + double screenwidth = MediaQuery.of(context).size.width; + return Padding( + padding: const EdgeInsets.all(20.0), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + SizedBox(height: screenheight / 8), + buildIconContainer(Icons.report, Color(0xFF7DAFBC)), + SizedBox(height: 20), + Text( + "Your registration is pending for Admin Approval.", + textAlign: TextAlign.center, + style: TextStyle( + fontSize: 16, + fontWeight: FontWeight.w500, + color: Color(0xFF414042)), + ), + SizedBox(height: 10), + Text( + "Access will be granted once your account is approved.", + textAlign: TextAlign.center, + style: TextStyle( + fontSize: 14, + color: Color(0xFF898C81), + ), + ), + SizedBox(height: 10), + ElevatedButton( + onPressed: () => { + context.go('/login') + // Navigator.pushReplacement( + // context, + // MaterialPageRoute(builder: (context) => LoginRoute() + // + // //ProfileScreen(userId: userID) + // ), + // ), + }, + child: Text( + 'Go to Login', + ), + ), + SizedBox(height: screenheight / 5), + Center( + child: Container( + height: screenheight / 8, + width: screenwidth / 2, + decoration: BoxDecoration( + image: DecorationImage( + image: AssetImage( + "assets/splash_screen/logo.png"), // Background image asset + fit: BoxFit.fill, + ), + ), + )) + ], + ), + ); + } + + Widget buildIconContainer(IconData icon, Color iconColor) { + return Scaffold( + body: Container( width: 60, height: 60, decoration: BoxDecoration( @@ -261,419 +668,8 @@ class _RegisterScreenState extends State { color: iconColor, size: 30, ), - ); - } - - return Scaffold( - backgroundColor: Colors.white, - body: registrationSuccess - ? Padding( - padding: const EdgeInsets.all(20.0), - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - SizedBox(height: screenheight / 8), - buildIconContainer(Icons.report, Color(0xFF7DAFBC)), - SizedBox(height: 20), - Text( - "Your registration is pending for Admin Approval.", - textAlign: TextAlign.center, - style: TextStyle( - fontSize: 16, - fontWeight: FontWeight.w500, - color: Color(0xFF414042)), - ), - SizedBox(height: 10), - Text( - "Access will be granted once your account is approved.", - textAlign: TextAlign.center, - style: TextStyle( - fontSize: 14, - color: Color(0xFF898C81), - ), - ), - SizedBox(height: 10), - ElevatedButton( - onPressed: () => { - Navigator.pushReplacement( - context, - MaterialPageRoute(builder: (context) => LoginRoute() - - //ProfileScreen(userId: userID) - ), - ), - }, - child: Text( - 'Go to Login', - ), - ), - SizedBox(height: screenheight / 5), - Center( - child: Container( - height: screenheight / 8, - width: screenwidth / 2, - decoration: BoxDecoration( - image: DecorationImage( - image: AssetImage( - "assets/splash_screen/logo.png"), // Background image asset - fit: BoxFit.fill, - ), - ), - )) - ], - ), - ) - : registrationFailed - ? Padding( - padding: const EdgeInsets.all(20.0), - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - SizedBox(height: screenheight / 8), - buildIconContainer(Icons.report, Colors.red), - SizedBox(height: 20), - Text( - "Sorry ${_usernameController.text}!", - textAlign: TextAlign.center, - style: TextStyle( - fontSize: 16, - fontWeight: FontWeight.w500, - color: Color(0xFF414042)), - ), - SizedBox(height: 10), - Text( - "Your registration process failed. For further assistance, please contact support.", - textAlign: TextAlign.center, - style: TextStyle( - fontSize: 14, - color: Color(0xFF898C81), - ), - ), - SizedBox(height: 10), - ElevatedButton( - onPressed: () => { - setState(() { - registrationFailed = false; - registrationSuccess = false; - _usernameController.clear(); - _emailController.clear(); - _passwordController.clear(); - _confirmpasswordController.clear(); - isChecked = false; - }) - }, - child: Text( - 'Retry', - ), - ), - SizedBox(height: screenheight / 5), - Center( - child: Container( - height: screenheight / 8, - width: screenwidth / 2, - decoration: BoxDecoration( - image: DecorationImage( - image: AssetImage( - "assets/splash_screen/logo.png"), // Background image asset - fit: BoxFit.fill, - ), - ), - )) - ], - ), - ) - : Padding( - padding: const EdgeInsets.all(20.0), - child: Form( - key: _formKey, - child: SingleChildScrollView( - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - SizedBox(height: screenheight / 6), - Text( - 'Register', - style: TextStyle( - fontSize: 32, fontWeight: FontWeight.w400), - ), - SizedBox(height: 10), - Text('Please enter your details'), - - SizedBox(height: 20), - // Display this if registration is pending approval - TextFormField( - controller: _usernameController, - focusNode: _focusNodes[0], - decoration: InputDecoration( - hintText: _showHints[0] ? 'Username' : null, - prefixIcon: Icon( - Icons.person, - color: Colors.blue, - ), - border: OutlineInputBorder(), - counterText: '', - ), - validator: _validateUsername, - maxLength: - 40, // Set the maximum length to 20 characters - maxLengthEnforcement: MaxLengthEnforcement.enforced, - ), - SizedBox(height: 15), - TextFormField( - controller: _emailController, - focusNode: _focusNodes[1], - decoration: InputDecoration( - // hintText: 'Enter your email', - hintText: - _showHints[1] ? 'Enter your email' : null, - prefixIcon: Icon( - Icons.email, - color: Colors.blue, - ), - border: OutlineInputBorder(), - counterText: '', - ), - validator: _validateEmail, - maxLength: 320, - maxLengthEnforcement: MaxLengthEnforcement.enforced, - inputFormatters: [ - LengthLimitingTextInputFormatter( - 320), // Limit to 320 characters - ], - ), - SizedBox(height: 15), - TextFormField( - controller: _passwordController, - focusNode: _focusNodes[2], - obscureText: _obscurePassword, - decoration: InputDecoration( - hintText: - _showHints[2] ? 'Enter your password' : null, - prefixIcon: Icon( - Icons.lock, - color: Colors.blue, - ), - suffixIcon: IconButton( - icon: Icon( - _obscurePassword - ? Icons.visibility - : Icons.visibility_off, - color: Colors.blue, - ), - onPressed: () { - setState(() { - _obscurePassword = !_obscurePassword; - }); - }, - ), - border: OutlineInputBorder(), - counterText: '', - ), - validator: _validatePassword, - maxLength: 40, - maxLengthEnforcement: MaxLengthEnforcement.enforced, - ), - SizedBox(height: 15), - TextFormField( - controller: _confirmpasswordController, - focusNode: _focusNodes[3], - obscureText: _obscureConfirmPassword, - decoration: InputDecoration( - hintText: - _showHints[3] ? 'Confirm password' : null, - prefixIcon: Icon( - Icons.lock, - color: Colors.blue, - ), - suffixIcon: IconButton( - icon: Icon( - _obscureConfirmPassword - ? Icons.visibility - : Icons.visibility_off, - color: Colors.blue, - ), - onPressed: () { - setState(() { - _obscureConfirmPassword = - !_obscureConfirmPassword; - }); - }, - ), - border: OutlineInputBorder(), - counterText: '', - ), - validator: _validateConfirmPassword, - maxLength: 40, - maxLengthEnforcement: MaxLengthEnforcement.enforced, - inputFormatters: [ - LengthLimitingTextInputFormatter( - 64), // Limit to 40 characters - ], - ), - SizedBox(height: 10), - Row( - children: [ - Checkbox( - value: isChecked, - onChanged: (value) { - setState(() { - isChecked = value ?? false; - showError = false; - }); - }, - side: BorderSide( - color: showError ? Colors.red : Colors.grey, - width: 1.5, - ), - ), - Expanded( - child: Text.rich( - TextSpan( - text: 'I agree to ', - children: [ - TextSpan( - text: 'Terms & Conditions', - style: TextStyle(color: Colors.blue), - ), - TextSpan(text: ' and '), - TextSpan( - text: 'Privacy Policy', - style: TextStyle(color: Colors.blue), - ), - ], - ), - ), - ), - ], - ), - if (showError) - Row( - mainAxisAlignment: MainAxisAlignment.start, - children: [ - Padding( - padding: const EdgeInsets.only(left: 10.0), - child: Text( - 'Please agree to terms and conditions.', - style: TextStyle( - color: Colors.red[700], - fontSize: 12, - ), - ), - ), - ], - ), - SizedBox(height: 20), - SizedBox( - width: screenwidth / 1.3, - child: ElevatedButton( - onPressed: _registerUser, - style: ElevatedButton.styleFrom( - backgroundColor: Color( - 0xFFA7887A), // Brownish color for Register - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(10), - ), - ), - child: Row( - mainAxisSize: MainAxisSize.min, - children: [ - Text( - "Register", - style: TextStyle( - fontSize: 16, color: Colors.white), - ), - SizedBox(width: 8), - Icon(Icons.arrow_forward, - color: Colors.white), - ], - ), - ), - ), - SizedBox(height: 10), - Text( - "Already have an account?", - style: TextStyle( - fontSize: 16, color: Colors.grey[600]), - ), - SizedBox(height: 10), - SizedBox( - width: screenwidth / 1.3, - child: ElevatedButton( - onPressed: () { - // Add your login logic here - }, - style: ElevatedButton.styleFrom( - backgroundColor: Color( - 0xFF82AFCB), // Blueish color for Login - 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, - // color: Colors.white), - // ], - // ), - - child: GestureDetector( - onTap: () { - // Navigate to LoginRoute - Navigator.push( - context, - MaterialPageRoute( - builder: (context) => LoginRoute()), - // MaterialPageRoute(builder: (context) => LoginRoute(userId: userID)), - ); - }, - child: Row( - mainAxisSize: MainAxisSize.min, - children: [ - Text( - "Login", - style: TextStyle( - fontSize: 16, - color: Colors.white, - ), - ), - SizedBox(width: 8), - Icon(Icons.arrow_forward, - color: Colors.white), - ], - ), - ), - ), - ), - SizedBox( - height: 10, - ), - Center( - child: Container( - height: screenheight / 8, - width: screenwidth / 2, - decoration: BoxDecoration( - image: DecorationImage( - image: AssetImage( - "assets/splash_screen/logo.png"), // Background image asset - fit: BoxFit.fill, - ), - ), - )) - ], - ), - ), - ), - ), + ), ); } } + diff --git a/lib/presentation/Screens/profilepage.dart b/lib/presentation/Screens/profilepage.dart index b5eae4ff..a2af1946 100644 --- a/lib/presentation/Screens/profilepage.dart +++ b/lib/presentation/Screens/profilepage.dart @@ -235,7 +235,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 ecbf1200..989e799d 100644 --- a/lib/presentation/routes/auth_routes/login_route.dart +++ b/lib/presentation/routes/auth_routes/login_route.dart @@ -1,5 +1,7 @@ +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'; @@ -21,482 +23,722 @@ 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}); +// 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 '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 - } - } +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', - 'إعادة تعيين كلمة المرور', - ), - ), - content: Form( - key: forgotPwFormKey, - child: TextFormField( - validator: FieldValidator.email(), - controller: emailCtl, - decoration: InputDecoration( - labelText: context.translate( - 'Email address', - 'عنوان البريد الإلكتروني', + 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, + ), + ], + ), ), ), - ), - ), - actions: [ - TextButton( - onPressed: Navigator.of(dialogCtx, rootNavigator: true).pop, - child: Text( - context.translate( - 'Return', - 'يعود', + 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,), + ], + ), ), ), - ), - 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', - 'إرسال إعادة تعيين البريد الإلكتروني', - ), + 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, + ), + ), + )) + ], + ), ), - ); - 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; } } 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: