fix login on guest

This commit is contained in:
Patrick Alvin Alcala 2025-04-02 13:27:34 +08:00
parent 93c141a779
commit 2decbc43e5
4 changed files with 35 additions and 24 deletions

View file

@ -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/auth/auth_service.dart';
import 'package:pharmacy_mobile/blocs/guest/functions/bloc_getgueststatus.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_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/buttonwithprogress_widget.dart';
import 'package:pharmacy_mobile/widgets/customer_pagebackground_widget.dart'; import 'package:pharmacy_mobile/widgets/customer_pagebackground_widget.dart';
import 'package:pharmacy_mobile/widgets/customer_title_widget.dart'; import 'package:pharmacy_mobile/widgets/customer_title_widget.dart';
@ -41,6 +42,17 @@ class _CustomerCartPageState extends State<CustomerCartPage> {
}); });
} }
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 { void _signIn() async {
final email = _emailController.text; final email = _emailController.text;
final password = _passwordController.text; final password = _passwordController.text;
@ -80,9 +92,9 @@ class _CustomerCartPageState extends State<CustomerCartPage> {
WidgetsBinding.instance.addPostFrameCallback((_) { WidgetsBinding.instance.addPostFrameCallback((_) {
if (user.contains('admin')) { if (user.contains('admin')) {
if (mounted) context.push('/main'); if (mounted) context.go('/main');
} else { } else {
if (mounted) context.push('/customer'); setGuest(false);
} }
}); });
} else { } else {

View file

@ -31,7 +31,7 @@ class _CustomerSearchPageState extends State<CustomerSearchPage> {
// late final List _medicinesList = []; // late final List _medicinesList = [];
Future<void> _getURL() async { Future<void> _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(() { setState(() {
imageUrl = image; imageUrl = image;
}); });

View file

@ -156,25 +156,23 @@ class _CustomerSettingsPageState extends State<CustomerSettingsPage> {
], ],
) )
else else
Column( Column(children: [
children: [ const Gap(68),
const Gap(68), const CustomerTitleWidget(),
const CustomerTitleWidget(), const Gap(32),
const Gap(32), const TextWidget(text: 'Mga Setting'),
const TextWidget(text: 'Mga Setting'), const Gap(16),
const Gap(16), SettingWidget(
SettingWidget( icon: Icons.language, title: 'Pinulongan', value: currentLanguage, onPressed: () => gotoSettings()),
icon: Icons.language, title: 'Pinulongan', value: currentLanguage, onPressed: () => gotoSettings()), const Gap(8),
const Gap(8), SettingWidget(
SettingWidget( icon: Icons.person,
icon: Icons.person, title: 'Ngalan',
title: 'Ngalan', value: _isGuest ? 'Guest' : currentName,
value: _isGuest ? 'Guest' : currentName, ),
), const Gap(32),
const Gap(32), ButtonWidget(text: 'Log Outss', onPressed: _signOut),
ButtonWidget(text: 'Log Out', onPressed: _signOut) ])
],
)
], ],
))); )));
} }

View file

@ -44,7 +44,7 @@ class IndexPage extends StatelessWidget {
const Gap(32), const Gap(32),
Padding( Padding(
padding: const EdgeInsets.fromLTRB(0, 0, 38, 0), 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), const Gap(64),
ButtonWidget(text: 'Login', onPressed: gotoLogin), ButtonWidget(text: 'Login', onPressed: gotoLogin),
@ -55,9 +55,10 @@ class IndexPage extends StatelessWidget {
onTap: loginAsGuest, onTap: loginAsGuest,
child: const TextWidget( child: const TextWidget(
text: "Login as Guest", text: "Login as Guest",
size: 16, size: 12,
underlined: true, underlined: true,
color: Color.fromRGBO(198, 133, 232, 1), color: Color.fromRGBO(198, 133, 232, 1),
bold: true,
), ),
), ),
const Gap(32), const Gap(32),