diff --git a/.gitignore b/.gitignore index 79c113f..e80ce2f 100644 --- a/.gitignore +++ b/.gitignore @@ -43,3 +43,4 @@ app.*.map.json /android/app/debug /android/app/profile /android/app/release +lib/core/services/constants.dart diff --git a/lib/core/services/constants.dart b/lib/core/services/constants.dart index 9866315..faf2881 100644 --- a/lib/core/services/constants.dart +++ b/lib/core/services/constants.dart @@ -1,2 +1,2 @@ const String baseUrl = - 'https://f7fe-2001-448a-50a0-3463-a4de-673f-afb-724b.ngrok-free.app/'; + 'https://4317-2001-448a-50a0-3463-1809-e54b-6523-d37.ngrok-free.app/'; diff --git a/lib/core/utils/styles/theme.dart b/lib/core/utils/styles/theme.dart index bde2dc5..48ffd70 100644 --- a/lib/core/utils/styles/theme.dart +++ b/lib/core/utils/styles/theme.dart @@ -82,6 +82,11 @@ class AppTextStyles { ThemeData appTheme() { return ThemeData( + textSelectionTheme: const TextSelectionThemeData( + cursorColor: AppColors.primaryColor, + selectionColor: AppColors.primaryColor, + selectionHandleColor: AppColors.primaryColor, + ), textTheme: GoogleFonts.interTextTheme(), fontFamily: GoogleFonts.inter().fontFamily, scaffoldBackgroundColor: AppColors.whiteColor, diff --git a/lib/features/auth/screens/signin/signin_screen.dart b/lib/features/auth/screens/signin/signin_screen.dart index bc8ef41..dbe51b0 100644 --- a/lib/features/auth/screens/signin/signin_screen.dart +++ b/lib/features/auth/screens/signin/signin_screen.dart @@ -117,7 +117,7 @@ class SigninScreen extends StatelessWidget { 'Forgot Password?', style: TextStyle( fontSize: 13, - fontWeight: FontWeight.w500, + fontWeight: FontWeight.bold, color: Colors.white, ), ), diff --git a/lib/features/auth/screens/signup/signup_screen.dart b/lib/features/auth/screens/signup/signup_screen.dart index 748c8ff..ae8b0d3 100644 --- a/lib/features/auth/screens/signup/signup_screen.dart +++ b/lib/features/auth/screens/signup/signup_screen.dart @@ -8,14 +8,23 @@ import 'package:english_learning/features/auth/widgets/dialog/signup_verificatio import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; -class SignupScreen extends StatelessWidget { - final TextEditingController _emailController = TextEditingController(); - final TextEditingController _passwordController = TextEditingController(); - final TextEditingController _nisnController = TextEditingController(); - final TextEditingController _nameController = TextEditingController(); - +class SignupScreen extends StatefulWidget { SignupScreen({super.key}); + @override + State createState() => _SignupScreenState(); +} + +class _SignupScreenState extends State { + final TextEditingController _emailController = TextEditingController(); + + final TextEditingController _passwordController = TextEditingController(); + + final TextEditingController _nisnController = TextEditingController(); + + final TextEditingController _nameController = TextEditingController(); + bool isLoading = false; + @override Widget build(BuildContext context) { final userProvider = Provider.of(context, listen: false); @@ -24,6 +33,58 @@ class SignupScreen extends StatelessWidget { final mediaQuery = MediaQuery.of(context); final screenHeight = mediaQuery.size.height; + Future handleRegistration( + BuildContext context, + ValidatorProvider validatorProvider, + ) async { + setState(() { + isLoading = true; + }); + try { + // Attempt registration first + final isSuccess = await userProvider.register( + name: _nameController.text, + email: _emailController.text, + nisn: _nisnController.text, + password: _passwordController.text, + confirmPassword: _passwordController.text, + ); + + if (isSuccess) { + // Show verification dialog + showDialog( + context: context, + barrierDismissible: false, + builder: (BuildContext context) { + return SignupVerification( + onSubmit: () { + // Navigate to sign in screen + Navigator.pushReplacement( + context, + MaterialPageRoute( + builder: (context) => SigninScreen(), + ), + ); + }, + ); + }, + ); + } else { + // Show error message + ScaffoldMessenger.of(context).showSnackBar( + const SnackBar( + content: Text('Registration failed'), + backgroundColor: Colors.red, + ), + ); + } + } finally { + setState(() { + isLoading = false; + }); + } + } + return Scaffold( backgroundColor: AppColors.whiteColor, body: Center( @@ -152,69 +213,41 @@ class SignupScreen extends StatelessWidget { const SizedBox(height: 24), GlobalButton( text: 'Sign Up', - onPressed: () async { - // Validate all fields - validatorProvider.validateField( - 'nisn', _nisnController.text, - validator: validatorProvider.nisnValidator); - validatorProvider.validateField( - 'name', _nameController.text, - validator: validatorProvider.fullNameValidator); - validatorProvider.validateField( - 'email', _emailController.text, - validator: validatorProvider.emailValidator); - validatorProvider.validateField( - 'password', _passwordController.text, - validator: validatorProvider.passwordValidator); - validatorProvider.validateField( - 'confirmPassword', _passwordController.text, - validator: - validatorProvider.confirmPasswordValidator); + isLoading: isLoading, + onPressed: isLoading + ? null + : () { + validatorProvider.validateField( + 'nisn', _nisnController.text, + validator: validatorProvider.nisnValidator); + validatorProvider.validateField( + 'name', _nameController.text, + validator: + validatorProvider.fullNameValidator); + validatorProvider.validateField( + 'email', _emailController.text, + validator: validatorProvider.emailValidator); + validatorProvider.validateField( + 'password', _passwordController.text, + validator: + validatorProvider.passwordValidator); + validatorProvider.validateField( + 'confirmPassword', _passwordController.text, + validator: validatorProvider + .confirmPasswordValidator); - // If no error, proceed with registration - if (validatorProvider.getError('nisn') == null && - validatorProvider.getError('name') == null && - validatorProvider.getError('email') == null && - validatorProvider.getError('password') == null && - validatorProvider.getError('confirmPassword') == - null) { - // Call the register method with required data - final isSuccess = await userProvider.register( - name: _nameController.text, - email: _emailController.text, - nisn: _nisnController.text, - password: _passwordController.text, - confirmPassword: _passwordController.text, - ); - - if (isSuccess) { - // Show success dialog - showDialog( - context: context, - builder: (BuildContext context) { - return SignupVerification( - onSubmit: () { - Navigator.push( - context, - MaterialPageRoute( - builder: (context) => SigninScreen(), - ), - ); - }, - ); - }, - ); - } else { - // Show error message - ScaffoldMessenger.of(context).showSnackBar( - const SnackBar( - content: Text('Registration failed'), - backgroundColor: Colors.red, - ), - ); - } - } - }, + // If no error, proceed with registration + if (validatorProvider.getError('nisn') == null && + validatorProvider.getError('name') == null && + validatorProvider.getError('email') == null && + validatorProvider.getError('password') == + null && + validatorProvider + .getError('confirmPassword') == + null) { + handleRegistration(context, validatorProvider); + } + }, ), const SizedBox(height: 8), Row( @@ -238,7 +271,7 @@ class SignupScreen extends StatelessWidget { ' Login Here', style: AppTextStyles.blueTextStyle.copyWith( fontSize: 14, - fontWeight: FontWeight.w900, + fontWeight: FontWeight.bold, ), ), ), diff --git a/lib/features/auth/widgets/dialog/signup_verification.dart b/lib/features/auth/widgets/dialog/signup_verification.dart index be01540..2306262 100644 --- a/lib/features/auth/widgets/dialog/signup_verification.dart +++ b/lib/features/auth/widgets/dialog/signup_verification.dart @@ -33,14 +33,14 @@ class SignupVerification extends StatelessWidget { children: [ TextSpan( text: 'Account Verification', - style: AppTextStyles.blueTextStyle.copyWith( + style: AppTextStyles.blackTextStyle.copyWith( fontSize: 16, fontWeight: FontWeight.w900, ), ), TextSpan( text: ' in Progress', - style: AppTextStyles.blackTextStyle.copyWith( + style: AppTextStyles.blueTextStyle.copyWith( fontSize: 16, fontWeight: FontWeight.w900, ), @@ -55,7 +55,7 @@ class SignupVerification extends StatelessWidget { ), const SizedBox(height: 16), Text( - 'Your Registration is complete, but we need to verify your details. We\'ll notify you once your account is ready.', + 'Your account has been registered successfully! Please check your email inbox to verify your account.', textAlign: TextAlign.center, style: AppTextStyles.disableTextStyle.copyWith( fontSize: 12, @@ -64,9 +64,9 @@ class SignupVerification extends StatelessWidget { ), const SizedBox(height: 24), GlobalButton( - text: 'Okay', + text: 'Proceed to Login', onPressed: onSubmit, - ) + ), ], ), ),