fix: v2.0.4+24 — login fixes, signup toggle, forgot-password, guest SnackBar, Google OAuth
- Google Sign-In: wire serverClientId (639347358523-mtkm...apps.googleusercontent.com) so idToken is returned on Android - Email login: raise timeout 10s→25s, add single retry on SocketException/TimeoutException - Forgot Password: real glassmorphism bottom sheet with safe-degrade SnackBar (endpoint missing on backend) - Create Account: same-page AnimatedSwitcher toggle with glassmorphism signup form; delete old RegisterScreen - Desktop parity: DesktopLoginScreen same-page toggle; delete DesktopRegisterScreen - Guest mode: remove ScaffoldMessenger SnackBar from HomeScreen outer catch (inner _safe wrappers already return []) - LoginScreen: clearSnackBars() on postFrameCallback to prevent carried-over SnackBars from prior screens - ProGuard: add Google Sign-In + OkHttp keep rules - Version bump: 2.0.0+20 → 2.0.4+24; settings _appVersion → 2.0.4 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -2,7 +2,6 @@
|
||||
|
||||
import 'dart:ui';
|
||||
import '../core/utils/error_utils.dart';
|
||||
import 'package:flutter/foundation.dart' show kIsWeb;
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:video_player/video_player.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
@@ -22,12 +21,30 @@ class LoginScreen extends StatefulWidget {
|
||||
|
||||
class _LoginScreenState extends State<LoginScreen> {
|
||||
final _formKey = GlobalKey<FormState>();
|
||||
final _signupFormKey = GlobalKey<FormState>();
|
||||
|
||||
final TextEditingController _emailCtrl = TextEditingController();
|
||||
final TextEditingController _passCtrl = TextEditingController();
|
||||
final FocusNode _emailFocus = FocusNode();
|
||||
final FocusNode _passFocus = FocusNode();
|
||||
|
||||
// Signup-specific controllers
|
||||
final TextEditingController _signupEmailCtrl = TextEditingController();
|
||||
final TextEditingController _signupPhoneCtrl = TextEditingController();
|
||||
final TextEditingController _signupPassCtrl = TextEditingController();
|
||||
final TextEditingController _signupConfirmCtrl = TextEditingController();
|
||||
String? _signupDistrict;
|
||||
bool _signupObscurePass = true;
|
||||
bool _signupObscureConfirm = true;
|
||||
|
||||
static const _districts = [
|
||||
'Thiruvananthapuram', 'Kollam', 'Pathanamthitta', 'Alappuzha',
|
||||
'Kottayam', 'Idukki', 'Ernakulam', 'Thrissur', 'Palakkad',
|
||||
'Malappuram', 'Kozhikode', 'Wayanad', 'Kannur', 'Kasaragod',
|
||||
];
|
||||
|
||||
bool _isSignupMode = false;
|
||||
|
||||
final AuthService _auth = AuthService();
|
||||
bool _loading = false;
|
||||
bool _obscurePassword = true;
|
||||
@@ -50,6 +67,9 @@ class _LoginScreenState extends State<LoginScreen> {
|
||||
void initState() {
|
||||
super.initState();
|
||||
_initVideo();
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
if (mounted) ScaffoldMessenger.of(context).clearSnackBars();
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> _initVideo() async {
|
||||
@@ -72,6 +92,10 @@ class _LoginScreenState extends State<LoginScreen> {
|
||||
_passCtrl.dispose();
|
||||
_emailFocus.dispose();
|
||||
_passFocus.dispose();
|
||||
_signupEmailCtrl.dispose();
|
||||
_signupPhoneCtrl.dispose();
|
||||
_signupPassCtrl.dispose();
|
||||
_signupConfirmCtrl.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@@ -123,7 +147,11 @@ class _LoginScreenState extends State<LoginScreen> {
|
||||
}
|
||||
|
||||
void _openRegister() {
|
||||
Navigator.of(context).push(MaterialPageRoute(builder: (_) => const RegisterScreen(isDesktop: false)));
|
||||
setState(() => _isSignupMode = true);
|
||||
}
|
||||
|
||||
void _openLogin() {
|
||||
setState(() => _isSignupMode = false);
|
||||
}
|
||||
|
||||
void _showComingSoon() {
|
||||
@@ -132,6 +160,182 @@ class _LoginScreenState extends State<LoginScreen> {
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _performSignup() async {
|
||||
if (!(_signupFormKey.currentState?.validate() ?? false)) return;
|
||||
|
||||
final email = _signupEmailCtrl.text.trim();
|
||||
final phone = _signupPhoneCtrl.text.trim();
|
||||
final pass = _signupPassCtrl.text;
|
||||
final confirm = _signupConfirmCtrl.text;
|
||||
|
||||
if (pass != confirm) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(const SnackBar(content: Text('Passwords do not match')));
|
||||
return;
|
||||
}
|
||||
|
||||
setState(() => _loading = true);
|
||||
|
||||
try {
|
||||
await _auth.register(
|
||||
email: email,
|
||||
phoneNumber: phone,
|
||||
password: pass,
|
||||
district: _signupDistrict,
|
||||
);
|
||||
|
||||
if (!mounted) return;
|
||||
|
||||
Navigator.of(context).pushReplacement(PageRouteBuilder(
|
||||
pageBuilder: (context, a1, a2) => const HomeScreen(),
|
||||
transitionDuration: const Duration(milliseconds: 650),
|
||||
transitionsBuilder: (context, animation, _, child) => FadeTransition(opacity: animation, child: child),
|
||||
));
|
||||
} catch (e) {
|
||||
if (!mounted) return;
|
||||
ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text(userFriendlyError(e))));
|
||||
} finally {
|
||||
if (mounted) setState(() => _loading = false);
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _openForgotPasswordSheet() async {
|
||||
final emailCtrl = TextEditingController(text: _emailCtrl.text.trim());
|
||||
final sheetFormKey = GlobalKey<FormState>();
|
||||
bool submitting = false;
|
||||
|
||||
await showModalBottomSheet<void>(
|
||||
context: context,
|
||||
isScrollControlled: true,
|
||||
backgroundColor: Colors.transparent,
|
||||
builder: (ctx) {
|
||||
return StatefulBuilder(
|
||||
builder: (ctx, setSheetState) {
|
||||
return Padding(
|
||||
padding: EdgeInsets.only(bottom: MediaQuery.of(ctx).viewInsets.bottom),
|
||||
child: ClipRRect(
|
||||
borderRadius: const BorderRadius.vertical(top: Radius.circular(28)),
|
||||
child: BackdropFilter(
|
||||
filter: ImageFilter.blur(sigmaX: 20, sigmaY: 20),
|
||||
child: Container(
|
||||
padding: const EdgeInsets.fromLTRB(24, 20, 24, 28),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.black.withOpacity(0.75),
|
||||
border: Border.all(color: _glassBorder, width: 0.8),
|
||||
),
|
||||
child: Form(
|
||||
key: sheetFormKey,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
Center(
|
||||
child: Container(
|
||||
width: 40,
|
||||
height: 4,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white24,
|
||||
borderRadius: BorderRadius.circular(2),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 18),
|
||||
const Text(
|
||||
'Forgot Password',
|
||||
style: TextStyle(color: _textWhite, fontSize: 20, fontWeight: FontWeight.w600),
|
||||
),
|
||||
const SizedBox(height: 6),
|
||||
const Text(
|
||||
"Enter your email and we'll send you reset instructions.",
|
||||
style: TextStyle(color: _textMuted, fontSize: 13),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
TextFormField(
|
||||
controller: emailCtrl,
|
||||
keyboardType: TextInputType.emailAddress,
|
||||
autofillHints: const [AutofillHints.email],
|
||||
style: const TextStyle(color: _textWhite, fontSize: 14),
|
||||
cursorColor: Colors.white54,
|
||||
decoration: _glassInputDecoration(
|
||||
hint: 'Enter your email',
|
||||
prefixIcon: Icons.mail_outline_rounded,
|
||||
),
|
||||
validator: _emailValidator,
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(28),
|
||||
gradient: const LinearGradient(
|
||||
colors: [Color(0xFF2A2A2A), Color(0xFF1A1A1A)],
|
||||
),
|
||||
border: Border.all(color: const Color(0x33FFFFFF)),
|
||||
),
|
||||
child: Material(
|
||||
color: Colors.transparent,
|
||||
child: InkWell(
|
||||
borderRadius: BorderRadius.circular(28),
|
||||
onTap: submitting
|
||||
? null
|
||||
: () async {
|
||||
if (!(sheetFormKey.currentState?.validate() ?? false)) return;
|
||||
setSheetState(() => submitting = true);
|
||||
final email = emailCtrl.text.trim();
|
||||
try {
|
||||
await _auth.forgotPassword(email);
|
||||
} catch (_) {
|
||||
// safe-degrade: don't leak whether email exists or backend status
|
||||
}
|
||||
if (!ctx.mounted) return;
|
||||
Navigator.of(ctx).pop();
|
||||
if (!mounted) return;
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(
|
||||
content: Text("If that email is registered, we've sent reset instructions."),
|
||||
duration: Duration(seconds: 4),
|
||||
),
|
||||
);
|
||||
},
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 16),
|
||||
child: Center(
|
||||
child: submitting
|
||||
? const SizedBox(
|
||||
height: 20,
|
||||
width: 20,
|
||||
child: CircularProgressIndicator(strokeWidth: 2, color: _textWhite),
|
||||
)
|
||||
: const Text(
|
||||
'Send reset link',
|
||||
style: TextStyle(color: _textWhite, fontSize: 16, fontWeight: FontWeight.w600),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(ctx).pop(),
|
||||
child: const Text('Cancel', style: TextStyle(color: _textMuted)),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
emailCtrl.dispose();
|
||||
}
|
||||
|
||||
Future<void> _performGoogleLogin() async {
|
||||
try {
|
||||
setState(() => _loading = true);
|
||||
@@ -281,15 +485,23 @@ class _LoginScreenState extends State<LoginScreen> {
|
||||
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 20),
|
||||
child: ConstrainedBox(
|
||||
constraints: const BoxConstraints(maxWidth: 400),
|
||||
child: Form(
|
||||
key: _formKey,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// Brand name
|
||||
Center(
|
||||
child: Text(
|
||||
'Eventify',
|
||||
child: AnimatedSwitcher(
|
||||
duration: const Duration(milliseconds: 280),
|
||||
switchInCurve: Curves.easeOut,
|
||||
switchOutCurve: Curves.easeIn,
|
||||
child: _isSignupMode
|
||||
? KeyedSubtree(key: const ValueKey('signup'), child: _buildSignupForm(context))
|
||||
: KeyedSubtree(
|
||||
key: const ValueKey('login'),
|
||||
child: Form(
|
||||
key: _formKey,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// Brand name
|
||||
Center(
|
||||
child: Text(
|
||||
'Eventify',
|
||||
style: TextStyle(
|
||||
color: _textWhite.withOpacity(0.7),
|
||||
fontSize: 16,
|
||||
@@ -410,7 +622,7 @@ class _LoginScreenState extends State<LoginScreen> {
|
||||
),
|
||||
// Forgot Password
|
||||
GestureDetector(
|
||||
onTap: _showComingSoon,
|
||||
onTap: _openForgotPasswordSheet,
|
||||
child: const Text(
|
||||
'Forgot Password?',
|
||||
style: TextStyle(color: _textMuted, fontSize: 12),
|
||||
@@ -568,8 +780,10 @@ class _LoginScreenState extends State<LoginScreen> {
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -579,144 +793,233 @@ class _LoginScreenState extends State<LoginScreen> {
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// Register screen calls backend register endpoint via AuthService.register
|
||||
class RegisterScreen extends StatefulWidget {
|
||||
final bool isDesktop;
|
||||
const RegisterScreen({Key? key, this.isDesktop = false}) : super(key: key);
|
||||
Widget _buildSignupForm(BuildContext context) {
|
||||
return Form(
|
||||
key: _signupFormKey,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Center(
|
||||
child: Text(
|
||||
'Eventify',
|
||||
style: TextStyle(
|
||||
color: _textWhite.withOpacity(0.7),
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w500,
|
||||
fontStyle: FontStyle.italic,
|
||||
letterSpacing: 1.5,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
const Center(
|
||||
child: Text(
|
||||
'Create Your\nAccount',
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
color: _textWhite,
|
||||
fontSize: 28,
|
||||
fontWeight: FontWeight.bold,
|
||||
fontStyle: FontStyle.italic,
|
||||
height: 1.2,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 28),
|
||||
|
||||
@override
|
||||
State<RegisterScreen> createState() => _RegisterScreenState();
|
||||
}
|
||||
// Email
|
||||
const Padding(
|
||||
padding: EdgeInsets.only(left: 4, bottom: 8),
|
||||
child: Text('Email', style: TextStyle(color: _textMuted, fontSize: 13)),
|
||||
),
|
||||
TextFormField(
|
||||
controller: _signupEmailCtrl,
|
||||
keyboardType: TextInputType.emailAddress,
|
||||
autofillHints: const [AutofillHints.email],
|
||||
style: const TextStyle(color: _textWhite, fontSize: 14),
|
||||
cursorColor: Colors.white54,
|
||||
decoration: _glassInputDecoration(
|
||||
hint: 'Enter your email',
|
||||
prefixIcon: Icons.mail_outline_rounded,
|
||||
),
|
||||
validator: _emailValidator,
|
||||
textInputAction: TextInputAction.next,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
|
||||
class _RegisterScreenState extends State<RegisterScreen> {
|
||||
final _formKey = GlobalKey<FormState>();
|
||||
final TextEditingController _emailCtrl = TextEditingController();
|
||||
final TextEditingController _phoneCtrl = TextEditingController();
|
||||
final TextEditingController _passCtrl = TextEditingController();
|
||||
final TextEditingController _confirmCtrl = TextEditingController();
|
||||
final AuthService _auth = AuthService();
|
||||
// Phone
|
||||
const Padding(
|
||||
padding: EdgeInsets.only(left: 4, bottom: 8),
|
||||
child: Text('Phone', style: TextStyle(color: _textMuted, fontSize: 13)),
|
||||
),
|
||||
TextFormField(
|
||||
controller: _signupPhoneCtrl,
|
||||
keyboardType: TextInputType.phone,
|
||||
style: const TextStyle(color: _textWhite, fontSize: 14),
|
||||
cursorColor: Colors.white54,
|
||||
decoration: _glassInputDecoration(
|
||||
hint: 'Enter your phone number',
|
||||
prefixIcon: Icons.phone_outlined,
|
||||
),
|
||||
validator: (v) {
|
||||
if (v == null || v.trim().isEmpty) return 'Enter phone number';
|
||||
if (v.trim().length < 7) return 'Enter a valid phone number';
|
||||
return null;
|
||||
},
|
||||
textInputAction: TextInputAction.next,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
|
||||
bool _loading = false;
|
||||
String? _selectedDistrict;
|
||||
// District
|
||||
const Padding(
|
||||
padding: EdgeInsets.only(left: 4, bottom: 8),
|
||||
child: Text('District (optional)', style: TextStyle(color: _textMuted, fontSize: 13)),
|
||||
),
|
||||
DropdownButtonFormField<String>(
|
||||
value: _signupDistrict,
|
||||
dropdownColor: const Color(0xFF1A1A1A),
|
||||
iconEnabledColor: _textMuted,
|
||||
style: const TextStyle(color: _textWhite, fontSize: 14),
|
||||
decoration: _glassInputDecoration(
|
||||
hint: 'Select your district',
|
||||
prefixIcon: Icons.location_on_outlined,
|
||||
),
|
||||
items: _districts
|
||||
.map((d) => DropdownMenuItem(
|
||||
value: d,
|
||||
child: Text(d, style: const TextStyle(color: _textWhite)),
|
||||
))
|
||||
.toList(),
|
||||
onChanged: (v) => setState(() => _signupDistrict = v),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
|
||||
static const _districts = [
|
||||
'Thiruvananthapuram', 'Kollam', 'Pathanamthitta', 'Alappuzha',
|
||||
'Kottayam', 'Idukki', 'Ernakulam', 'Thrissur', 'Palakkad',
|
||||
'Malappuram', 'Kozhikode', 'Wayanad', 'Kannur', 'Kasaragod',
|
||||
];
|
||||
// Password
|
||||
const Padding(
|
||||
padding: EdgeInsets.only(left: 4, bottom: 8),
|
||||
child: Text('Password', style: TextStyle(color: _textMuted, fontSize: 13)),
|
||||
),
|
||||
TextFormField(
|
||||
controller: _signupPassCtrl,
|
||||
obscureText: _signupObscurePass,
|
||||
style: const TextStyle(color: _textWhite, fontSize: 14),
|
||||
cursorColor: Colors.white54,
|
||||
decoration: _glassInputDecoration(
|
||||
hint: 'Create a password',
|
||||
prefixIcon: Icons.lock_outline_rounded,
|
||||
suffixIcon: IconButton(
|
||||
icon: Icon(
|
||||
_signupObscurePass ? Icons.visibility_off_outlined : Icons.visibility_outlined,
|
||||
color: _textMuted,
|
||||
size: 20,
|
||||
),
|
||||
onPressed: () => setState(() => _signupObscurePass = !_signupObscurePass),
|
||||
),
|
||||
),
|
||||
validator: _passwordValidator,
|
||||
textInputAction: TextInputAction.next,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_emailCtrl.dispose();
|
||||
_phoneCtrl.dispose();
|
||||
_passCtrl.dispose();
|
||||
_confirmCtrl.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
// Confirm password
|
||||
const Padding(
|
||||
padding: EdgeInsets.only(left: 4, bottom: 8),
|
||||
child: Text('Confirm password', style: TextStyle(color: _textMuted, fontSize: 13)),
|
||||
),
|
||||
TextFormField(
|
||||
controller: _signupConfirmCtrl,
|
||||
obscureText: _signupObscureConfirm,
|
||||
style: const TextStyle(color: _textWhite, fontSize: 14),
|
||||
cursorColor: Colors.white54,
|
||||
decoration: _glassInputDecoration(
|
||||
hint: 'Re-enter your password',
|
||||
prefixIcon: Icons.lock_outline_rounded,
|
||||
suffixIcon: IconButton(
|
||||
icon: Icon(
|
||||
_signupObscureConfirm ? Icons.visibility_off_outlined : Icons.visibility_outlined,
|
||||
color: _textMuted,
|
||||
size: 20,
|
||||
),
|
||||
onPressed: () => setState(() => _signupObscureConfirm = !_signupObscureConfirm),
|
||||
),
|
||||
),
|
||||
validator: _passwordValidator,
|
||||
textInputAction: TextInputAction.done,
|
||||
onFieldSubmitted: (_) => _performSignup(),
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
|
||||
Future<void> _performRegister() async {
|
||||
if (!(_formKey.currentState?.validate() ?? false)) return;
|
||||
|
||||
final email = _emailCtrl.text.trim();
|
||||
final phone = _phoneCtrl.text.trim();
|
||||
final pass = _passCtrl.text;
|
||||
final confirm = _confirmCtrl.text;
|
||||
|
||||
if (pass != confirm) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(const SnackBar(content: Text('Passwords do not match')));
|
||||
return;
|
||||
}
|
||||
|
||||
setState(() => _loading = true);
|
||||
|
||||
try {
|
||||
await _auth.register(
|
||||
email: email,
|
||||
phoneNumber: phone,
|
||||
password: pass,
|
||||
district: _selectedDistrict,
|
||||
);
|
||||
|
||||
if (!mounted) return;
|
||||
|
||||
Navigator.of(context).pushReplacement(MaterialPageRoute(builder: (_) => const HomeScreen()));
|
||||
} catch (e) {
|
||||
if (!mounted) return;
|
||||
final message = userFriendlyError(e);
|
||||
ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text(message)));
|
||||
} finally {
|
||||
if (mounted) setState(() => _loading = false);
|
||||
}
|
||||
}
|
||||
|
||||
String? _emailValidator(String? v) {
|
||||
if (v == null || v.trim().isEmpty) return 'Enter email';
|
||||
final emailRegex = RegExp(r"^[^@]+@[^@]+\.[^@]+");
|
||||
if (!emailRegex.hasMatch(v.trim())) return 'Enter a valid email';
|
||||
return null;
|
||||
}
|
||||
|
||||
String? _phoneValidator(String? v) {
|
||||
if (v == null || v.trim().isEmpty) return 'Enter phone number';
|
||||
if (v.trim().length < 7) return 'Enter a valid phone number';
|
||||
return null;
|
||||
}
|
||||
|
||||
String? _passwordValidator(String? v) {
|
||||
if (v == null || v.isEmpty) return 'Enter password';
|
||||
if (v.length < 6) return 'Password must be at least 6 characters';
|
||||
return null;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(title: const Text('Register')),
|
||||
body: SafeArea(
|
||||
child: Center(
|
||||
child: SingleChildScrollView(
|
||||
padding: const EdgeInsets.all(20),
|
||||
child: ConstrainedBox(
|
||||
constraints: const BoxConstraints(maxWidth: 520),
|
||||
child: Card(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(18.0),
|
||||
child: Form(
|
||||
key: _formKey,
|
||||
child: Column(
|
||||
children: [
|
||||
TextFormField(controller: _emailCtrl, decoration: const InputDecoration(labelText: 'Email'), validator: _emailValidator, keyboardType: TextInputType.emailAddress),
|
||||
const SizedBox(height: 8),
|
||||
TextFormField(controller: _phoneCtrl, decoration: const InputDecoration(labelText: 'Phone'), validator: _phoneValidator, keyboardType: TextInputType.phone),
|
||||
const SizedBox(height: 8),
|
||||
DropdownButtonFormField<String>(
|
||||
value: _selectedDistrict,
|
||||
decoration: const InputDecoration(labelText: 'District (optional)'),
|
||||
items: _districts.map((d) => DropdownMenuItem(value: d, child: Text(d))).toList(),
|
||||
onChanged: (v) => setState(() => _selectedDistrict = v),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
TextFormField(controller: _passCtrl, obscureText: true, decoration: const InputDecoration(labelText: 'Password'), validator: _passwordValidator),
|
||||
const SizedBox(height: 8),
|
||||
TextFormField(controller: _confirmCtrl, obscureText: true, decoration: const InputDecoration(labelText: 'Confirm password'), validator: _passwordValidator),
|
||||
const SizedBox(height: 16),
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
child: ElevatedButton(
|
||||
onPressed: _loading ? null : _performRegister,
|
||||
child: _loading ? const SizedBox(width: 20, height: 20, child: CircularProgressIndicator(color: Colors.white, strokeWidth: 2)) : const Text('Register'),
|
||||
),
|
||||
),
|
||||
],
|
||||
// Create Account button
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(28),
|
||||
gradient: const LinearGradient(
|
||||
colors: [Color(0xFF2A2A2A), Color(0xFF1A1A1A)],
|
||||
),
|
||||
border: Border.all(color: const Color(0x33FFFFFF)),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.black.withOpacity(0.4),
|
||||
blurRadius: 16,
|
||||
offset: const Offset(0, 6),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Material(
|
||||
color: Colors.transparent,
|
||||
child: InkWell(
|
||||
borderRadius: BorderRadius.circular(28),
|
||||
onTap: _loading ? null : _performSignup,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 16),
|
||||
child: Center(
|
||||
child: _loading
|
||||
? const SizedBox(
|
||||
height: 20,
|
||||
width: 20,
|
||||
child: CircularProgressIndicator(strokeWidth: 2, color: _textWhite),
|
||||
)
|
||||
: const Text(
|
||||
'Create Account',
|
||||
style: TextStyle(color: _textWhite, fontSize: 16, fontWeight: FontWeight.w600),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
|
||||
// Back to Sign in
|
||||
Center(
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
const Text(
|
||||
'Already have an account? ',
|
||||
style: TextStyle(color: _textMuted, fontSize: 13),
|
||||
),
|
||||
GestureDetector(
|
||||
onTap: _openLogin,
|
||||
child: const Text(
|
||||
'Sign in',
|
||||
style: TextStyle(
|
||||
color: _textWhite,
|
||||
fontSize: 13,
|
||||
fontWeight: FontWeight.w600,
|
||||
decoration: TextDecoration.underline,
|
||||
decorationColor: _textWhite,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user