This commit is contained in:
Patrick Alvin Alcala 2025-03-06 12:17:14 +08:00
parent 7749f1100d
commit 1b0241037d
7 changed files with 74 additions and 56 deletions

View file

@ -35,7 +35,7 @@ class IndexPage extends StatelessWidget {
const Gap(32),
Padding(
padding: const EdgeInsets.fromLTRB(0, 0, 38, 0),
child: const ImageWidget(imagePath: 'assets/ph_logo.webp', size: 192, measureByHeight: false),
child: const ImageWidget(imagePath: 'assets/ph_logo.webp', size: 184, measureByHeight: false),
),
const Gap(64),
ButtonWidget(text: 'Login', onPressed: gotoLogin),

View file

@ -126,7 +126,6 @@ class _LoginPageState extends State<LoginPage> {
Padding(
padding: const EdgeInsets.only(left: 32, right: 32),
child: GlossyContainerWidget(
// height: containerHeight,
child: Form(
child: Column(
children: [

View file

@ -4,11 +4,13 @@ import 'package:gap/gap.dart';
import 'package:go_router/go_router.dart';
import 'package:pharmacy_mobile/auth/auth_service.dart';
import 'package:pharmacy_mobile/widgets/button_widget.dart';
import 'package:pharmacy_mobile/widgets/buttonwithprogress_widget.dart';
import 'package:pharmacy_mobile/widgets/menu_widget.dart';
import 'package:pharmacy_mobile/widgets/page_background_widget.dart';
import 'package:pharmacy_mobile/widgets/snackbar_widget.dart';
import 'package:pharmacy_mobile/widgets/text_widget.dart';
import 'package:pharmacy_mobile/widgets/title_widget.dart';
import 'package:supabase_flutter/supabase_flutter.dart';
class MainPage extends StatefulWidget {
const MainPage({super.key});
@ -20,9 +22,28 @@ class MainPage extends StatefulWidget {
class _MainPageState extends State<MainPage> {
final _authService = AuthService();
late bool _isLoading = false;
void signOut() async {
// ignore: use_build_context_synchronously
await _authService.signOut().then((_) => {context.go('/'), showNotification(context, 'Logged Out', true)});
try {
setState(() {
_isLoading = true;
});
// ignore: use_build_context_synchronously
await _authService.signOut().then((_) => {context.go('/'), showNotification(context, 'Logged Out', true)});
} catch (e) {
if (e is AuthException) {
final errorMessage = e.message;
if (mounted) {
showNotification(context, 'Error: $errorMessage', false);
}
}
} finally {
setState(() {
_isLoading = false;
});
}
}
@override
@ -109,10 +130,8 @@ class _MainPageState extends State<MainPage> {
onPressed: () => {context.push('/liststocks')},
color: 'yellow'),
const Gap(40),
ButtonWidget(
text: 'Logout',
onPressed: signOut,
)
ButtonWithProgressWidget(
trigger: _isLoading, progressText: 'Logging Out', buttonText: 'Logout', onPressed: signOut)
],
),
),