Updated .gitignore, constants.dart, theme.dart, signin_screen.dart, signup_screen.dart, and signup_verification.dart with various code changes
This commit is contained in:
parent
7df57cca15
commit
58739472b7
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -43,3 +43,4 @@ app.*.map.json
|
||||||
/android/app/debug
|
/android/app/debug
|
||||||
/android/app/profile
|
/android/app/profile
|
||||||
/android/app/release
|
/android/app/release
|
||||||
|
lib/core/services/constants.dart
|
||||||
|
|
|
||||||
|
|
@ -1,2 +1,2 @@
|
||||||
const String baseUrl =
|
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/';
|
||||||
|
|
|
||||||
|
|
@ -82,6 +82,11 @@ class AppTextStyles {
|
||||||
|
|
||||||
ThemeData appTheme() {
|
ThemeData appTheme() {
|
||||||
return ThemeData(
|
return ThemeData(
|
||||||
|
textSelectionTheme: const TextSelectionThemeData(
|
||||||
|
cursorColor: AppColors.primaryColor,
|
||||||
|
selectionColor: AppColors.primaryColor,
|
||||||
|
selectionHandleColor: AppColors.primaryColor,
|
||||||
|
),
|
||||||
textTheme: GoogleFonts.interTextTheme(),
|
textTheme: GoogleFonts.interTextTheme(),
|
||||||
fontFamily: GoogleFonts.inter().fontFamily,
|
fontFamily: GoogleFonts.inter().fontFamily,
|
||||||
scaffoldBackgroundColor: AppColors.whiteColor,
|
scaffoldBackgroundColor: AppColors.whiteColor,
|
||||||
|
|
|
||||||
|
|
@ -117,7 +117,7 @@ class SigninScreen extends StatelessWidget {
|
||||||
'Forgot Password?',
|
'Forgot Password?',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 13,
|
fontSize: 13,
|
||||||
fontWeight: FontWeight.w500,
|
fontWeight: FontWeight.bold,
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
|
||||||
|
|
@ -8,14 +8,23 @@ import 'package:english_learning/features/auth/widgets/dialog/signup_verificatio
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
class SignupScreen extends StatelessWidget {
|
class SignupScreen extends StatefulWidget {
|
||||||
final TextEditingController _emailController = TextEditingController();
|
|
||||||
final TextEditingController _passwordController = TextEditingController();
|
|
||||||
final TextEditingController _nisnController = TextEditingController();
|
|
||||||
final TextEditingController _nameController = TextEditingController();
|
|
||||||
|
|
||||||
SignupScreen({super.key});
|
SignupScreen({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<SignupScreen> createState() => _SignupScreenState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _SignupScreenState extends State<SignupScreen> {
|
||||||
|
final TextEditingController _emailController = TextEditingController();
|
||||||
|
|
||||||
|
final TextEditingController _passwordController = TextEditingController();
|
||||||
|
|
||||||
|
final TextEditingController _nisnController = TextEditingController();
|
||||||
|
|
||||||
|
final TextEditingController _nameController = TextEditingController();
|
||||||
|
bool isLoading = false;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final userProvider = Provider.of<UserProvider>(context, listen: false);
|
final userProvider = Provider.of<UserProvider>(context, listen: false);
|
||||||
|
|
@ -24,6 +33,58 @@ class SignupScreen extends StatelessWidget {
|
||||||
final mediaQuery = MediaQuery.of(context);
|
final mediaQuery = MediaQuery.of(context);
|
||||||
final screenHeight = mediaQuery.size.height;
|
final screenHeight = mediaQuery.size.height;
|
||||||
|
|
||||||
|
Future<void> 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(
|
return Scaffold(
|
||||||
backgroundColor: AppColors.whiteColor,
|
backgroundColor: AppColors.whiteColor,
|
||||||
body: Center(
|
body: Center(
|
||||||
|
|
@ -152,69 +213,41 @@ class SignupScreen extends StatelessWidget {
|
||||||
const SizedBox(height: 24),
|
const SizedBox(height: 24),
|
||||||
GlobalButton(
|
GlobalButton(
|
||||||
text: 'Sign Up',
|
text: 'Sign Up',
|
||||||
onPressed: () async {
|
isLoading: isLoading,
|
||||||
// Validate all fields
|
onPressed: isLoading
|
||||||
validatorProvider.validateField(
|
? null
|
||||||
'nisn', _nisnController.text,
|
: () {
|
||||||
validator: validatorProvider.nisnValidator);
|
validatorProvider.validateField(
|
||||||
validatorProvider.validateField(
|
'nisn', _nisnController.text,
|
||||||
'name', _nameController.text,
|
validator: validatorProvider.nisnValidator);
|
||||||
validator: validatorProvider.fullNameValidator);
|
validatorProvider.validateField(
|
||||||
validatorProvider.validateField(
|
'name', _nameController.text,
|
||||||
'email', _emailController.text,
|
validator:
|
||||||
validator: validatorProvider.emailValidator);
|
validatorProvider.fullNameValidator);
|
||||||
validatorProvider.validateField(
|
validatorProvider.validateField(
|
||||||
'password', _passwordController.text,
|
'email', _emailController.text,
|
||||||
validator: validatorProvider.passwordValidator);
|
validator: validatorProvider.emailValidator);
|
||||||
validatorProvider.validateField(
|
validatorProvider.validateField(
|
||||||
'confirmPassword', _passwordController.text,
|
'password', _passwordController.text,
|
||||||
validator:
|
validator:
|
||||||
validatorProvider.confirmPasswordValidator);
|
validatorProvider.passwordValidator);
|
||||||
|
validatorProvider.validateField(
|
||||||
|
'confirmPassword', _passwordController.text,
|
||||||
|
validator: validatorProvider
|
||||||
|
.confirmPasswordValidator);
|
||||||
|
|
||||||
// If no error, proceed with registration
|
// If no error, proceed with registration
|
||||||
if (validatorProvider.getError('nisn') == null &&
|
if (validatorProvider.getError('nisn') == null &&
|
||||||
validatorProvider.getError('name') == null &&
|
validatorProvider.getError('name') == null &&
|
||||||
validatorProvider.getError('email') == null &&
|
validatorProvider.getError('email') == null &&
|
||||||
validatorProvider.getError('password') == null &&
|
validatorProvider.getError('password') ==
|
||||||
validatorProvider.getError('confirmPassword') ==
|
null &&
|
||||||
null) {
|
validatorProvider
|
||||||
// Call the register method with required data
|
.getError('confirmPassword') ==
|
||||||
final isSuccess = await userProvider.register(
|
null) {
|
||||||
name: _nameController.text,
|
handleRegistration(context, validatorProvider);
|
||||||
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,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
),
|
),
|
||||||
const SizedBox(height: 8),
|
const SizedBox(height: 8),
|
||||||
Row(
|
Row(
|
||||||
|
|
@ -238,7 +271,7 @@ class SignupScreen extends StatelessWidget {
|
||||||
' Login Here',
|
' Login Here',
|
||||||
style: AppTextStyles.blueTextStyle.copyWith(
|
style: AppTextStyles.blueTextStyle.copyWith(
|
||||||
fontSize: 14,
|
fontSize: 14,
|
||||||
fontWeight: FontWeight.w900,
|
fontWeight: FontWeight.bold,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
|
||||||
|
|
@ -33,14 +33,14 @@ class SignupVerification extends StatelessWidget {
|
||||||
children: [
|
children: [
|
||||||
TextSpan(
|
TextSpan(
|
||||||
text: 'Account Verification',
|
text: 'Account Verification',
|
||||||
style: AppTextStyles.blueTextStyle.copyWith(
|
style: AppTextStyles.blackTextStyle.copyWith(
|
||||||
fontSize: 16,
|
fontSize: 16,
|
||||||
fontWeight: FontWeight.w900,
|
fontWeight: FontWeight.w900,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
TextSpan(
|
TextSpan(
|
||||||
text: ' in Progress',
|
text: ' in Progress',
|
||||||
style: AppTextStyles.blackTextStyle.copyWith(
|
style: AppTextStyles.blueTextStyle.copyWith(
|
||||||
fontSize: 16,
|
fontSize: 16,
|
||||||
fontWeight: FontWeight.w900,
|
fontWeight: FontWeight.w900,
|
||||||
),
|
),
|
||||||
|
|
@ -55,7 +55,7 @@ class SignupVerification extends StatelessWidget {
|
||||||
),
|
),
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
Text(
|
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,
|
textAlign: TextAlign.center,
|
||||||
style: AppTextStyles.disableTextStyle.copyWith(
|
style: AppTextStyles.disableTextStyle.copyWith(
|
||||||
fontSize: 12,
|
fontSize: 12,
|
||||||
|
|
@ -64,9 +64,9 @@ class SignupVerification extends StatelessWidget {
|
||||||
),
|
),
|
||||||
const SizedBox(height: 24),
|
const SizedBox(height: 24),
|
||||||
GlobalButton(
|
GlobalButton(
|
||||||
text: 'Okay',
|
text: 'Proceed to Login',
|
||||||
onPressed: onSubmit,
|
onPressed: onSubmit,
|
||||||
)
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user