From 2decbc43e56765fbcdb7bfd6a27355be9c4e4b2c Mon Sep 17 00:00:00 2001 From: Patrick Alvin Alcala Date: Wed, 2 Apr 2025 13:27:34 +0800 Subject: [PATCH] fix login on guest --- .../customer_pages/customer_cart_page.dart | 16 +++++++-- .../customer_pages/customer_search_page.dart | 2 +- .../customer_settings_page.dart | 36 +++++++++---------- lib/pages/index_page.dart | 5 +-- 4 files changed, 35 insertions(+), 24 deletions(-) diff --git a/lib/pages/customer_pages/customer_cart_page.dart b/lib/pages/customer_pages/customer_cart_page.dart index 9aecf80..683d8ee 100644 --- a/lib/pages/customer_pages/customer_cart_page.dart +++ b/lib/pages/customer_pages/customer_cart_page.dart @@ -6,6 +6,7 @@ import 'package:internet_connection_checker/internet_connection_checker.dart'; import 'package:pharmacy_mobile/auth/auth_service.dart'; import 'package:pharmacy_mobile/blocs/guest/functions/bloc_getgueststatus.dart'; import 'package:pharmacy_mobile/blocs/guest/functions/bloc_setguestoff.dart'; +import 'package:pharmacy_mobile/blocs/guest/functions/bloc_setgueston.dart'; import 'package:pharmacy_mobile/widgets/buttonwithprogress_widget.dart'; import 'package:pharmacy_mobile/widgets/customer_pagebackground_widget.dart'; import 'package:pharmacy_mobile/widgets/customer_title_widget.dart'; @@ -41,6 +42,17 @@ class _CustomerCartPageState extends State { }); } + void setGuest(bool value) async { + // ignore: use_build_context_synchronously + final success = value ? await blocSetGuestOn(context) : await blocSetGuestOff(context); + + if (success) { + setState(() { + _isGuest = value; + }); + } + } + void _signIn() async { final email = _emailController.text; final password = _passwordController.text; @@ -80,9 +92,9 @@ class _CustomerCartPageState extends State { WidgetsBinding.instance.addPostFrameCallback((_) { if (user.contains('admin')) { - if (mounted) context.push('/main'); + if (mounted) context.go('/main'); } else { - if (mounted) context.push('/customer'); + setGuest(false); } }); } else { diff --git a/lib/pages/customer_pages/customer_search_page.dart b/lib/pages/customer_pages/customer_search_page.dart index f77cec7..93bb18f 100644 --- a/lib/pages/customer_pages/customer_search_page.dart +++ b/lib/pages/customer_pages/customer_search_page.dart @@ -31,7 +31,7 @@ class _CustomerSearchPageState extends State { // late final List _medicinesList = []; Future _getURL() async { - final image = await _storage.getImageURL('ref_medicines_images', 'a3e430fe-86c1-4d46-9c6a-aed2dae57fef.webp'); + final image = await _storage.getImageURL('ref_medicines_images', '91ba5229-244b-4377-ba4e-9de57b9ba4df.webp'); setState(() { imageUrl = image; }); diff --git a/lib/pages/customer_pages/customer_settings_page.dart b/lib/pages/customer_pages/customer_settings_page.dart index 582c9f9..4d3034a 100644 --- a/lib/pages/customer_pages/customer_settings_page.dart +++ b/lib/pages/customer_pages/customer_settings_page.dart @@ -156,25 +156,23 @@ class _CustomerSettingsPageState extends State { ], ) else - Column( - children: [ - const Gap(68), - const CustomerTitleWidget(), - const Gap(32), - const TextWidget(text: 'Mga Setting'), - const Gap(16), - SettingWidget( - icon: Icons.language, title: 'Pinulongan', value: currentLanguage, onPressed: () => gotoSettings()), - const Gap(8), - SettingWidget( - icon: Icons.person, - title: 'Ngalan', - value: _isGuest ? 'Guest' : currentName, - ), - const Gap(32), - ButtonWidget(text: 'Log Out', onPressed: _signOut) - ], - ) + Column(children: [ + const Gap(68), + const CustomerTitleWidget(), + const Gap(32), + const TextWidget(text: 'Mga Setting'), + const Gap(16), + SettingWidget( + icon: Icons.language, title: 'Pinulongan', value: currentLanguage, onPressed: () => gotoSettings()), + const Gap(8), + SettingWidget( + icon: Icons.person, + title: 'Ngalan', + value: _isGuest ? 'Guest' : currentName, + ), + const Gap(32), + ButtonWidget(text: 'Log Outss', onPressed: _signOut), + ]) ], ))); } diff --git a/lib/pages/index_page.dart b/lib/pages/index_page.dart index 932c7d7..4a80bc3 100644 --- a/lib/pages/index_page.dart +++ b/lib/pages/index_page.dart @@ -44,7 +44,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: 184, measureByHeight: false), + child: const ImageWidget(imagePath: 'assets/ph_logo.webp', size: 168, measureByHeight: false), ), const Gap(64), ButtonWidget(text: 'Login', onPressed: gotoLogin), @@ -55,9 +55,10 @@ class IndexPage extends StatelessWidget { onTap: loginAsGuest, child: const TextWidget( text: "Login as Guest", - size: 16, + size: 12, underlined: true, color: Color.fromRGBO(198, 133, 232, 1), + bold: true, ), ), const Gap(32),