This commit is contained in:
Patrick Alvin Alcala 2025-02-17 11:07:56 +08:00
parent 06531e3959
commit f0d6bca4f3
135 changed files with 19329 additions and 22 deletions

View file

@ -1,5 +1,3 @@
import 'dart:developer';
import 'package:flutter/material.dart';
import 'package:gap/gap.dart';
import 'package:pharmacy_mobile/functions/checkresult_function.dart';

View file

@ -27,6 +27,15 @@ class _LoginPageState extends State<LoginPage> {
bool _isLoading = false;
void checkLoggedIn() async {
final user = _authService.getCurrentUser();
if (user == null) {
context.push('/');
} else {
context.push('/main');
}
}
void _signIn() async {
// if (_isLoading) return;
@ -55,13 +64,16 @@ class _LoginPageState extends State<LoginPage> {
if (mounted) {
final user = _authService.getCurrentUser();
showNotification(context, 'Login Successful', true);
WidgetsBinding.instance.addPostFrameCallback((_) {
if (mounted) {
context.push('/main');
}
});
if (user != null) {
showNotification(context, 'Login Successful', true);
WidgetsBinding.instance.addPostFrameCallback((_) {
if (mounted) {
context.push('/main');
}
});
}
}
} else {
if (mounted) {
@ -90,6 +102,12 @@ class _LoginPageState extends State<LoginPage> {
// }
}
@override
void initState() {
checkLoggedIn();
super.initState();
}
@override
void dispose() {
_emailController.dispose();

View file

@ -10,18 +10,38 @@ import 'package:pharmacy_mobile/widgets/snackbar_widget.dart';
import 'package:pharmacy_mobile/widgets/text_widget.dart';
import 'package:pharmacy_mobile/widgets/title_widget.dart';
class MainPage extends StatelessWidget {
class MainPage extends StatefulWidget {
const MainPage({super.key});
@override
Widget build(BuildContext context) {
final authService = AuthService();
State<MainPage> createState() => _MainPageState();
}
void signOut() async {
// ignore: use_build_context_synchronously
await authService.signOut().then((_) => {context.go('/'), showNotification(context, 'Logged Out', true)});
class _MainPageState extends State<MainPage> {
final _authService = AuthService();
void signOut() async {
// ignore: use_build_context_synchronously
await _authService.signOut().then((_) => {context.go('/'), showNotification(context, 'Logged Out', true)});
}
void checkLoggedIn() async {
final user = _authService.getCurrentUser();
if (user == null) {
if (mounted) {
context.push('/');
}
}
}
@override
void initState() {
checkLoggedIn();
super.initState();
}
@override
Widget build(BuildContext context) {
return PopScope(
canPop: false,
child: Scaffold(