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

@ -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(