update on settings
This commit is contained in:
parent
5bffc744e3
commit
05c3208cad
9 changed files with 205 additions and 117 deletions
|
|
@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
|
|||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||
import 'package:pharmacy_mobile/pages/customer_pages/customer_cart_page.dart';
|
||||
import 'package:pharmacy_mobile/pages/customer_pages/customer_main_page.dart';
|
||||
import 'package:pharmacy_mobile/pages/customer_pages/customer_profile_page.dart';
|
||||
import 'package:pharmacy_mobile/pages/customer_pages/customer_settings_page.dart';
|
||||
import 'package:pharmacy_mobile/pages/customer_pages/customer_search_page.dart';
|
||||
import 'package:pharmacy_mobile/widgets/text_widget.dart';
|
||||
import 'package:animated_notch_bottom_bar/animated_notch_bottom_bar/animated_notch_bottom_bar.dart';
|
||||
|
|
@ -26,7 +26,7 @@ class _CustomerPageState extends State<CustomerPage> {
|
|||
const CustomerMainPage(),
|
||||
const CustomerSearchPage(),
|
||||
const CustomerCartPage(),
|
||||
const CustomerProfilePage()
|
||||
const CustomerSettingsPage()
|
||||
];
|
||||
|
||||
final Color selectedBarColor = const Color.fromRGBO(241, 255, 255, 0.83);
|
||||
|
|
|
|||
|
|
@ -1,104 +0,0 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:gap/gap.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:pharmacy_mobile/auth/auth_service.dart';
|
||||
import 'package:pharmacy_mobile/blocs/guest/functions/bloc_getgueststatus.dart';
|
||||
import 'package:pharmacy_mobile/widgets/button_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/snackbar_widget.dart';
|
||||
import 'package:pharmacy_mobile/widgets/text_widget.dart';
|
||||
// import 'package:flutter_settings_screens/flutter_settings_screens.dart';
|
||||
|
||||
class CustomerProfilePage extends StatefulWidget {
|
||||
const CustomerProfilePage({super.key});
|
||||
|
||||
@override
|
||||
State<CustomerProfilePage> createState() => _CustomerProfilePageState();
|
||||
}
|
||||
|
||||
class _CustomerProfilePageState extends State<CustomerProfilePage> {
|
||||
final _authService = AuthService();
|
||||
late bool _isGuest = false;
|
||||
|
||||
void _signOut() async {
|
||||
// ignore: use_build_context_synchronously
|
||||
await _authService.signOut().then((_) => {context.go('/'), showNotification(context, 'Logged Out', true)});
|
||||
}
|
||||
|
||||
void checkGuest() async {
|
||||
final guest = await blocGetGuestStatus(context);
|
||||
setState(() {
|
||||
_isGuest = guest;
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
checkGuest();
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
body: CustomerPagebackgroundWidget(
|
||||
child: Column(
|
||||
children: [
|
||||
Column(
|
||||
children: [
|
||||
const Gap(68),
|
||||
const CustomerTitleWidget(),
|
||||
const Gap(32),
|
||||
_isGuest ? const TextWidget(text: 'Guest Profile') : const TextWidget(text: 'My Profile'),
|
||||
const Gap(16),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
const TextWidget(
|
||||
text: 'Name:',
|
||||
size: 12,
|
||||
),
|
||||
const Gap(8),
|
||||
const TextWidget(
|
||||
text: 'Guest',
|
||||
size: 12,
|
||||
),
|
||||
],
|
||||
),
|
||||
const Gap(16),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
const TextWidget(
|
||||
text: 'Name:',
|
||||
size: 12,
|
||||
),
|
||||
const Gap(8),
|
||||
const TextWidget(
|
||||
text: 'Guest',
|
||||
size: 12,
|
||||
),
|
||||
],
|
||||
),
|
||||
// SimpleSettingsTile(
|
||||
// title: 'Advanced',
|
||||
// subtitle: 'More, advanced settings.',
|
||||
// // screen: SettingsScreen(
|
||||
// // title: 'Sub menu',
|
||||
// // children: <Widget>[
|
||||
// // CheckboxSettingsTile(
|
||||
// // settingsKey: 'key-of-your-setting',
|
||||
// // title: 'This is a simple Checkbox',
|
||||
// // ),
|
||||
// // ],
|
||||
// // ),
|
||||
// ),
|
||||
const Gap(32),
|
||||
ButtonWidget(text: 'Log Out', onPressed: _signOut)
|
||||
],
|
||||
)
|
||||
],
|
||||
)));
|
||||
}
|
||||
}
|
||||
89
lib/pages/customer_pages/customer_settings_page.dart
Normal file
89
lib/pages/customer_pages/customer_settings_page.dart
Normal file
|
|
@ -0,0 +1,89 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:gap/gap.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:pharmacy_mobile/auth/auth_service.dart';
|
||||
import 'package:pharmacy_mobile/blocs/guest/functions/bloc_getgueststatus.dart';
|
||||
import 'package:pharmacy_mobile/widgets/button_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/setting_widget.dart';
|
||||
import 'package:pharmacy_mobile/widgets/snackbar_widget.dart';
|
||||
import 'package:pharmacy_mobile/widgets/text_widget.dart';
|
||||
|
||||
class CustomerSettingsPage extends StatefulWidget {
|
||||
const CustomerSettingsPage({super.key});
|
||||
|
||||
@override
|
||||
State<CustomerSettingsPage> createState() => _CustomerSettingsPageState();
|
||||
}
|
||||
|
||||
class _CustomerSettingsPageState extends State<CustomerSettingsPage> {
|
||||
final _authService = AuthService();
|
||||
|
||||
late String currentName = '';
|
||||
late bool _isGuest = false;
|
||||
|
||||
void _signOut() async {
|
||||
// ignore: use_build_context_synchronously
|
||||
await _authService.signOut().then((_) => {context.go('/'), showNotification(context, 'Logged Out', true)});
|
||||
}
|
||||
|
||||
Future<bool> _checkGuest() async {
|
||||
final guest = await blocGetGuestStatus(context);
|
||||
return guest;
|
||||
}
|
||||
|
||||
Future<String> _getUsername() async {
|
||||
final username = _authService.getCurrentUser();
|
||||
return username ?? '';
|
||||
}
|
||||
|
||||
void autoRun() async {
|
||||
final guest = await _checkGuest();
|
||||
if (guest) {
|
||||
_isGuest = guest;
|
||||
} else {
|
||||
currentName = await _getUsername();
|
||||
}
|
||||
|
||||
setState(() {});
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
autoRun();
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
body: CustomerPagebackgroundWidget(
|
||||
child: Column(
|
||||
children: [
|
||||
Column(
|
||||
children: [
|
||||
const Gap(68),
|
||||
const CustomerTitleWidget(),
|
||||
const Gap(32),
|
||||
const TextWidget(text: 'Settings'),
|
||||
const Gap(16),
|
||||
SettingWidget(
|
||||
icon: Icons.language,
|
||||
title: 'Language',
|
||||
value: 'English',
|
||||
onPressed: () => context.push('/languagesetting')),
|
||||
const Gap(8),
|
||||
SettingWidget(
|
||||
icon: Icons.person,
|
||||
title: 'Display Name',
|
||||
value: _isGuest ? 'Guest' : currentName,
|
||||
),
|
||||
const Gap(32),
|
||||
ButtonWidget(text: 'Log Out', onPressed: _signOut)
|
||||
],
|
||||
)
|
||||
],
|
||||
)));
|
||||
}
|
||||
}
|
||||
27
lib/pages/settings_pages/language_setting_page.dart
Normal file
27
lib/pages/settings_pages/language_setting_page.dart
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:gap/gap.dart';
|
||||
import 'package:pharmacy_mobile/widgets/customer_pagebackground_widget.dart';
|
||||
import 'package:pharmacy_mobile/widgets/customer_title_widget.dart';
|
||||
import 'package:pharmacy_mobile/widgets/settings_menu_widget.dart';
|
||||
import 'package:pharmacy_mobile/widgets/text_widget.dart';
|
||||
|
||||
class LanguageSettingPage extends StatelessWidget {
|
||||
const LanguageSettingPage({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
body: CustomerPagebackgroundWidget(
|
||||
child: Column(
|
||||
children: [
|
||||
const Gap(68),
|
||||
const CustomerTitleWidget(),
|
||||
const Gap(32),
|
||||
const TextWidget(text: 'Language'),
|
||||
const Gap(16),
|
||||
SettingsMenuWidget()
|
||||
],
|
||||
)),
|
||||
);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue