update
This commit is contained in:
parent
b2aeb642cc
commit
b6b7ab6e84
8 changed files with 155 additions and 61 deletions
|
|
@ -1,9 +1,11 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:google_fonts/google_fonts.dart';
|
||||
import 'package:gap/gap.dart';
|
||||
import 'package:pharmacy_mobile/auth/auth_service.dart';
|
||||
import 'package:pharmacy_mobile/main.dart';
|
||||
import 'dart:developer';
|
||||
import 'package:quickalert/quickalert.dart';
|
||||
|
||||
class LoginPage extends StatefulWidget {
|
||||
const LoginPage({super.key});
|
||||
|
|
@ -17,16 +19,30 @@ class _LoginPageState extends State<LoginPage> {
|
|||
final _emailController = TextEditingController();
|
||||
final _passwordController = TextEditingController();
|
||||
|
||||
Future<void> _signIn() async {
|
||||
void _signIn() async {
|
||||
final email = _emailController.text;
|
||||
final password = _passwordController.text;
|
||||
|
||||
try {
|
||||
await _authService.signIn(email, password);
|
||||
log('message');
|
||||
// QuickAlert.show(
|
||||
// context: context,
|
||||
// type: QuickAlertType.success,
|
||||
// text: 'Login Successful',
|
||||
// autoCloseDuration: const Duration(seconds: 1),
|
||||
// showConfirmBtn: false,
|
||||
// );
|
||||
context.push('/main');
|
||||
} catch (e) {
|
||||
if (mounted) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text('Error: $e')));
|
||||
QuickAlert.show(
|
||||
context: context,
|
||||
type: QuickAlertType.error,
|
||||
text: 'Error: $e',
|
||||
autoCloseDuration: const Duration(seconds: 2),
|
||||
showConfirmBtn: false,
|
||||
);
|
||||
// ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text('Error: $e')));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -87,76 +103,28 @@ class _LoginPageState extends State<LoginPage> {
|
|||
children: [
|
||||
TextFormField(
|
||||
controller: _emailController,
|
||||
decoration: InputDecoration(
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Email',
|
||||
border: OutlineInputBorder(),
|
||||
),
|
||||
style: TextStyle(color: Colors.white),
|
||||
style: const TextStyle(color: Colors.white),
|
||||
),
|
||||
const Gap(8),
|
||||
TextFormField(
|
||||
obscureText: true,
|
||||
controller: _passwordController,
|
||||
decoration: InputDecoration(
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Password',
|
||||
border: OutlineInputBorder(),
|
||||
),
|
||||
style: TextStyle(color: Colors.white),
|
||||
style: const TextStyle(color: Colors.white),
|
||||
),
|
||||
const Gap(16),
|
||||
TextButton(onPressed: () => {_signIn()}, child: Text('Login'))
|
||||
TextButton(onPressed: () => {_signIn()}, child: const Text('Login'))
|
||||
],
|
||||
)),
|
||||
),
|
||||
),
|
||||
|
||||
// Form(
|
||||
|
||||
// child: Column(
|
||||
// children: [
|
||||
// TextFormField(
|
||||
// decoration: InputDecoration(
|
||||
// labelText: 'Email',
|
||||
// border: OutlineInputBorder(),
|
||||
// ),
|
||||
// validator: (value) {
|
||||
// if (value.isEmpty) {
|
||||
// return 'Please enter an email';
|
||||
// }
|
||||
// return null;
|
||||
// },
|
||||
// onSaved: (value) => _email = value,
|
||||
// ),
|
||||
// SizedBox(height: 20),
|
||||
// TextFormField(
|
||||
// decoration: InputDecoration(
|
||||
// labelText: 'Password',
|
||||
// border: OutlineInputBorder(),
|
||||
// ),
|
||||
// obscureText: true,
|
||||
// validator: (value) {
|
||||
// if (value.isEmpty) {
|
||||
// return 'Please enter a password';
|
||||
// }
|
||||
// return null;
|
||||
// },
|
||||
// onSaved: (value) => _password = value,
|
||||
// ),
|
||||
// SizedBox(height: 20),
|
||||
// ElevatedButton(
|
||||
// onPressed: () {
|
||||
// if (_formKey.currentState.validate()) {
|
||||
// _formKey.currentState.save();
|
||||
// // Login logic here
|
||||
// print('Email: $_email, Password: $_password');
|
||||
// }
|
||||
// },
|
||||
// child: Text('Login'),
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
// )
|
||||
// )
|
||||
],
|
||||
),
|
||||
),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue