232 lines
8.0 KiB
Dart
232 lines
8.0 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:go_router/go_router.dart';
|
|
import 'package:qpay/screens/onboarding/login/login_controller.dart';
|
|
|
|
class LoginScreen extends StatefulWidget {
|
|
const LoginScreen({super.key});
|
|
|
|
@override
|
|
State<LoginScreen> createState() => _LoginScreenState();
|
|
}
|
|
|
|
class _LoginScreenState extends State<LoginScreen> {
|
|
final _formKey = GlobalKey<FormState>();
|
|
final _usernameController = TextEditingController();
|
|
final _passwordController = TextEditingController();
|
|
|
|
late LoginController _loginController;
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
_loginController = LoginController(context);
|
|
}
|
|
|
|
@override
|
|
void dispose() {
|
|
_loginController.dispose();
|
|
super.dispose();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
body: SingleChildScrollView(
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(25),
|
|
child: Form(
|
|
key: _formKey,
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
children: [
|
|
SizedBox(height: 75),
|
|
Text(
|
|
'Login',
|
|
style: TextStyle(
|
|
fontSize: 30,
|
|
fontWeight: FontWeight.bold,
|
|
color: Theme.of(context).colorScheme.primary,
|
|
),
|
|
),
|
|
SizedBox(height: 5),
|
|
Text(
|
|
'Welcome back to Peak',
|
|
style: TextStyle(fontSize: 18),
|
|
textAlign: TextAlign.center,
|
|
),
|
|
SizedBox(height: 40),
|
|
// Username Field
|
|
TextFormField(
|
|
controller: _usernameController,
|
|
decoration: InputDecoration(
|
|
labelText: 'Phone Number',
|
|
prefixIcon: Icon(Icons.person_outline),
|
|
),
|
|
validator: (value) {
|
|
if (value == null || value.isEmpty) {
|
|
return 'Please enter a phone number';
|
|
}
|
|
return null;
|
|
},
|
|
),
|
|
SizedBox(height: 20),
|
|
// Password Field
|
|
TextFormField(
|
|
controller: _passwordController,
|
|
decoration: InputDecoration(
|
|
labelText: 'Password',
|
|
prefixIcon: Icon(Icons.lock_outline),
|
|
suffixIcon: Icon(Icons.visibility_outlined),
|
|
),
|
|
obscureText: true,
|
|
validator: (value) {
|
|
if (value == null || value.isEmpty) {
|
|
return 'Please enter a password';
|
|
}
|
|
return null;
|
|
},
|
|
),
|
|
SizedBox(height: 20),
|
|
// Forgot Password Link
|
|
Align(
|
|
alignment: Alignment.centerRight,
|
|
child: TextButton(
|
|
onPressed: () {
|
|
// TODO: Add forgot password logic
|
|
},
|
|
child: Text(
|
|
'Forgot Password?',
|
|
style: TextStyle(
|
|
color: Theme.of(context).colorScheme.primary,
|
|
fontSize: 14,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
SizedBox(height: 40),
|
|
// Divider with "or" text
|
|
Row(
|
|
children: [
|
|
Expanded(child: Divider(color: Colors.grey.shade300)),
|
|
Padding(
|
|
padding: EdgeInsets.symmetric(horizontal: 16),
|
|
child: Text(
|
|
'or continue with',
|
|
style: TextStyle(
|
|
color: Colors.grey.shade600,
|
|
fontSize: 14,
|
|
),
|
|
),
|
|
),
|
|
Expanded(child: Divider(color: Colors.grey.shade300)),
|
|
],
|
|
),
|
|
SizedBox(height: 30),
|
|
// Social Login Buttons
|
|
Row(
|
|
children: [
|
|
Expanded(
|
|
child: OutlinedButton.icon(
|
|
onPressed: () {
|
|
// TODO: Add Google login logic
|
|
},
|
|
icon: Image.asset(
|
|
'assets/google.png',
|
|
width: 20,
|
|
height: 20,
|
|
),
|
|
label: Text('Google', style: TextStyle(fontSize: 16)),
|
|
style: OutlinedButton.styleFrom(
|
|
padding: EdgeInsets.symmetric(vertical: 16),
|
|
side: BorderSide(color: Colors.grey.shade300),
|
|
shape: RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.circular(12),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
SizedBox(width: 16),
|
|
Expanded(
|
|
child: OutlinedButton.icon(
|
|
onPressed: () {
|
|
// TODO: Add Apple login logic
|
|
},
|
|
icon: Image.asset(
|
|
'assets/apple.png',
|
|
width: 20,
|
|
height: 20,
|
|
),
|
|
label: Text('Apple', style: TextStyle(fontSize: 16)),
|
|
style: OutlinedButton.styleFrom(
|
|
padding: EdgeInsets.symmetric(vertical: 16),
|
|
side: BorderSide(color: Colors.grey.shade300),
|
|
shape: RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.circular(12),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
SizedBox(height: 40),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
bottomNavigationBar: SizedBox(
|
|
height: 130,
|
|
child: Column(
|
|
children: [
|
|
Padding(
|
|
padding: const EdgeInsets.symmetric(horizontal: 25),
|
|
child: Row(
|
|
children: [
|
|
Expanded(
|
|
child: ElevatedButton(
|
|
onPressed: () async {
|
|
// TODO: Add login logic
|
|
if (_formKey.currentState!.validate()) {
|
|
LoginScreenModel model = await _loginController.login(
|
|
_usernameController.text,
|
|
_passwordController.text,
|
|
);
|
|
|
|
if (model.status == 'SUCCESS') {
|
|
context.go('/');
|
|
}
|
|
}
|
|
},
|
|
child: Text('Login', style: TextStyle(fontSize: 16)),
|
|
),
|
|
),
|
|
SizedBox(width: 16),
|
|
Expanded(
|
|
child: TextButton(
|
|
onPressed: () {
|
|
context.go('/onboarding/register');
|
|
},
|
|
child: Text(
|
|
'Create Account',
|
|
style: TextStyle(fontSize: 16),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
SizedBox(height: 5),
|
|
TextButton(
|
|
onPressed: () {
|
|
context.go('/');
|
|
},
|
|
child: Text('Continue as guest?', style: TextStyle(fontSize: 14)),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|