Merge branch 'signup-verification' into 'master'
Updated .gitignore, constants.dart, theme.dart, signin_screen.dart,... See merge request profile-image/kedaireka/polinema-adapative-learning/mobile-adaptive-learning!9
This commit is contained in:
commit
632d5de0c8
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -43,3 +43,4 @@ app.*.map.json
|
|||
/android/app/debug
|
||||
/android/app/profile
|
||||
/android/app/release
|
||||
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/';
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -117,7 +117,7 @@ class SigninScreen extends StatelessWidget {
|
|||
'Forgot Password?',
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
fontWeight: FontWeight.w500,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
|
|
|
|||
|
|
@ -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<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
|
||||
Widget build(BuildContext context) {
|
||||
final userProvider = Provider.of<UserProvider>(context, listen: false);
|
||||
|
|
@ -24,6 +33,58 @@ class SignupScreen extends StatelessWidget {
|
|||
final mediaQuery = MediaQuery.of(context);
|
||||
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(
|
||||
backgroundColor: AppColors.whiteColor,
|
||||
body: Center(
|
||||
|
|
@ -152,67 +213,39 @@ class SignupScreen extends StatelessWidget {
|
|||
const SizedBox(height: 24),
|
||||
GlobalButton(
|
||||
text: 'Sign Up',
|
||||
onPressed: () async {
|
||||
// Validate all fields
|
||||
isLoading: isLoading,
|
||||
onPressed: isLoading
|
||||
? null
|
||||
: () {
|
||||
validatorProvider.validateField(
|
||||
'nisn', _nisnController.text,
|
||||
validator: validatorProvider.nisnValidator);
|
||||
validatorProvider.validateField(
|
||||
'name', _nameController.text,
|
||||
validator: validatorProvider.fullNameValidator);
|
||||
validator:
|
||||
validatorProvider.fullNameValidator);
|
||||
validatorProvider.validateField(
|
||||
'email', _emailController.text,
|
||||
validator: validatorProvider.emailValidator);
|
||||
validatorProvider.validateField(
|
||||
'password', _passwordController.text,
|
||||
validator: validatorProvider.passwordValidator);
|
||||
validator:
|
||||
validatorProvider.passwordValidator);
|
||||
validatorProvider.validateField(
|
||||
'confirmPassword', _passwordController.text,
|
||||
validator:
|
||||
validatorProvider.confirmPasswordValidator);
|
||||
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') ==
|
||||
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,
|
||||
),
|
||||
);
|
||||
}
|
||||
handleRegistration(context, validatorProvider);
|
||||
}
|
||||
},
|
||||
),
|
||||
|
|
@ -238,7 +271,7 @@ class SignupScreen extends StatelessWidget {
|
|||
' Login Here',
|
||||
style: AppTextStyles.blueTextStyle.copyWith(
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w900,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
)
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user