This commit is contained in:
Patrick Alvin Alcala 2025-01-22 13:14:06 +08:00
parent f1db550ee7
commit b2aeb642cc
11 changed files with 209 additions and 60 deletions

View file

@ -1,10 +1,49 @@
import 'package:flutter/material.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';
class LoginPage extends StatelessWidget {
class LoginPage extends StatefulWidget {
const LoginPage({super.key});
@override
State<LoginPage> createState() => _LoginPageState();
}
class _LoginPageState extends State<LoginPage> {
final _authService = AuthService();
final _emailController = TextEditingController();
final _passwordController = TextEditingController();
Future<void> _signIn() async {
final email = _emailController.text;
final password = _passwordController.text;
try {
await _authService.signIn(email, password);
log('message');
} catch (e) {
if (mounted) {
ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text('Error: $e')));
}
}
// if (mounted) {
// context.showSnackBar('Check your email for a login link!');
// _emailController.clear();
// }
}
@override
void dispose() {
_emailController.dispose();
_passwordController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return Scaffold(
@ -47,18 +86,24 @@ class LoginPage extends StatelessWidget {
child: Column(
children: [
TextFormField(
decoration: InputDecoration(
labelText: 'Email',
border: OutlineInputBorder(),
)),
controller: _emailController,
decoration: InputDecoration(
labelText: 'Email',
border: OutlineInputBorder(),
),
style: TextStyle(color: Colors.white),
),
const Gap(8),
TextFormField(
decoration: InputDecoration(
labelText: 'Password',
border: OutlineInputBorder(),
)),
controller: _passwordController,
decoration: InputDecoration(
labelText: 'Password',
border: OutlineInputBorder(),
),
style: TextStyle(color: Colors.white),
),
const Gap(16),
TextButton(onPressed: () => {}, child: Text('Login'))
TextButton(onPressed: () => {_signIn()}, child: Text('Login'))
],
)),
),