update on settings

This commit is contained in:
Patrick Alvin Alcala 2025-03-26 11:46:06 +08:00
parent 5bffc744e3
commit 05c3208cad
9 changed files with 205 additions and 117 deletions

View file

@ -23,6 +23,7 @@ import 'package:pharmacy_mobile/pages/login_page.dart';
import 'package:go_router/go_router.dart'; import 'package:go_router/go_router.dart';
import 'package:pharmacy_mobile/pages/main_page.dart'; import 'package:pharmacy_mobile/pages/main_page.dart';
import 'package:pharmacy_mobile/pages/register_page.dart'; import 'package:pharmacy_mobile/pages/register_page.dart';
import 'package:pharmacy_mobile/pages/settings_pages/language_setting_page.dart';
import 'package:supabase_flutter/supabase_flutter.dart'; import 'package:supabase_flutter/supabase_flutter.dart';
import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_bloc/flutter_bloc.dart';
@ -114,6 +115,20 @@ final _router = GoRouter(
path: '/itemview', path: '/itemview',
builder: (context, state) => const CustomerItemviewPage(), builder: (context, state) => const CustomerItemviewPage(),
), ),
GoRoute(
path: '/languagesetting',
pageBuilder: (BuildContext context, GoRouterState state) => CustomTransitionPage<void>(
key: state.pageKey,
child: const LanguageSettingPage(),
transitionsBuilder: (BuildContext context, Animation<double> animation, Animation<double> secondaryAnimation,
Widget child) =>
SlideTransition(
position: animation.drive(
Tween<Offset>(begin: Offset(0.95, 0), end: Offset.zero).chain(CurveTween(curve: Curves.easeIn))),
child: child),
),
// builder: (context, state) => const LanguageSettingPage(),
),
], ],
); );

View file

@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.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_cart_page.dart';
import 'package:pharmacy_mobile/pages/customer_pages/customer_main_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/pages/customer_pages/customer_search_page.dart';
import 'package:pharmacy_mobile/widgets/text_widget.dart'; import 'package:pharmacy_mobile/widgets/text_widget.dart';
import 'package:animated_notch_bottom_bar/animated_notch_bottom_bar/animated_notch_bottom_bar.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 CustomerMainPage(),
const CustomerSearchPage(), const CustomerSearchPage(),
const CustomerCartPage(), const CustomerCartPage(),
const CustomerProfilePage() const CustomerSettingsPage()
]; ];
final Color selectedBarColor = const Color.fromRGBO(241, 255, 255, 0.83); final Color selectedBarColor = const Color.fromRGBO(241, 255, 255, 0.83);

View file

@ -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)
],
)
],
)));
}
}

View 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)
],
)
],
)));
}
}

View 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()
],
)),
);
}
}

View file

@ -0,0 +1,47 @@
import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:gap/gap.dart';
import 'package:pharmacy_mobile/widgets/text_widget.dart';
class SettingWidget extends StatelessWidget {
final String title;
final String value;
final IconData icon;
final VoidCallback? onPressed;
const SettingWidget({super.key, required this.title, required this.value, required this.icon, this.onPressed});
@override
Widget build(BuildContext context) {
return Container(
padding: EdgeInsets.symmetric(horizontal: 16, vertical: 16),
decoration: BoxDecoration(
color: const Color.fromRGBO(39, 20, 36, 0.66),
border: Border.all(color: const Color.fromRGBO(74, 74, 74, 0.127)),
borderRadius: BorderRadius.circular(8.0)),
child: SizedBox(
width: MediaQuery.of(context).size.width,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Row(
children: [
FaIcon(icon, color: const Color.fromRGBO(255, 255, 255, 1), size: 20),
const Gap(16),
TextWidget(text: title, size: 12, color: const Color.fromRGBO(255, 255, 255, 1)),
],
),
GestureDetector(
onTap: onPressed,
child: Row(
children: [
TextWidget(text: value, size: 12, color: const Color.fromRGBO(255, 255, 255, 1)),
const Gap(16),
FaIcon(Icons.arrow_forward_ios, color: const Color.fromRGBO(255, 255, 255, 1), size: 12),
],
),
)
],
),
));
}
}

View file

@ -0,0 +1,24 @@
import 'package:flutter/material.dart';
import 'package:pharmacy_mobile/widgets/text_widget.dart';
class SettingsMenuWidget extends StatefulWidget {
const SettingsMenuWidget({super.key});
@override
State<SettingsMenuWidget> createState() => _SettingsMenuWidgetState();
}
class _SettingsMenuWidgetState extends State<SettingsMenuWidget> {
@override
Widget build(BuildContext context) {
return Container(
padding: const EdgeInsets.all(16),
width: MediaQuery.of(context).size.width * 0.9,
decoration: BoxDecoration(color: const Color.fromRGBO(28, 17, 32, 0.678), borderRadius: BorderRadius.circular(8.0)),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [TextWidget(text: 'Current', size: 8,), TextWidget(text: 'text')],
),
);
}
}

View file

@ -342,14 +342,6 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "2.0.27" version: "2.0.27"
flutter_settings_screens:
dependency: "direct main"
description:
name: flutter_settings_screens
sha256: b9e5ff87537fceeb67012560db6ef4bb0ff7d7a031e8184e1689538756ca99a0
url: "https://pub.dev"
source: hosted
version: "0.3.4"
flutter_svg: flutter_svg:
dependency: transitive dependency: transitive
description: description:
@ -673,7 +665,7 @@ packages:
source: hosted source: hosted
version: "1.1.0" version: "1.1.0"
path_provider: path_provider:
dependency: "direct main" dependency: transitive
description: description:
name: path_provider name: path_provider
sha256: "50c5dd5b6e1aaf6fb3a78b33f6aa3afca52bf903a8a5298f53101fdaee55bbcd" sha256: "50c5dd5b6e1aaf6fb3a78b33f6aa3afca52bf903a8a5298f53101fdaee55bbcd"

View file

@ -28,8 +28,6 @@ dependencies:
redacted: ^1.0.13 redacted: ^1.0.13
flutter_bloc: ^9.1.0 flutter_bloc: ^9.1.0
flutter_dotenv: ^5.2.1 flutter_dotenv: ^5.2.1
path_provider: ^2.1.5
flutter_settings_screens: ^0.3.4
dev_dependencies: dev_dependencies:
flutter_test: flutter_test: