fix login on guest
This commit is contained in:
parent
93c141a779
commit
2decbc43e5
4 changed files with 35 additions and 24 deletions
|
|
@ -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<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 {
|
||||
final email = _emailController.text;
|
||||
final password = _passwordController.text;
|
||||
|
|
@ -80,9 +92,9 @@ class _CustomerCartPageState extends State<CustomerCartPage> {
|
|||
|
||||
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 {
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ class _CustomerSearchPageState extends State<CustomerSearchPage> {
|
|||
// late final List _medicinesList = [];
|
||||
|
||||
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(() {
|
||||
imageUrl = image;
|
||||
});
|
||||
|
|
|
|||
|
|
@ -156,25 +156,23 @@ class _CustomerSettingsPageState extends State<CustomerSettingsPage> {
|
|||
],
|
||||
)
|
||||
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),
|
||||
])
|
||||
],
|
||||
)));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue