update on settings and customer background

This commit is contained in:
Patrick Alvin Alcala 2025-03-26 14:41:48 +08:00
parent 05c3208cad
commit 6424e82d54
18 changed files with 227 additions and 42 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 175 KiB

View file

@ -0,0 +1,14 @@
import 'package:flutter/widgets.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:pharmacy_mobile/blocs/language/language_bloc.dart';
import 'package:pharmacy_mobile/blocs/language/language_event.dart';
Future<String> blocGetLanguage(BuildContext context) async {
try {
final languageBloc = context.read<LanguageBloc>();
languageBloc.add(LanguageGetValue());
return languageBloc.state.value;
} catch (e) {
return '';
}
}

View file

@ -0,0 +1,14 @@
import 'package:flutter/widgets.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:pharmacy_mobile/blocs/language/language_bloc.dart';
import 'package:pharmacy_mobile/blocs/language/language_event.dart';
Future<bool> blocSetLanguage(BuildContext context, String value) async {
try {
final languageBloc = context.read<LanguageBloc>();
languageBloc.add(LanguageSetValue(value));
return true;
} catch (e) {
return false;
}
}

View file

@ -0,0 +1,14 @@
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:pharmacy_mobile/blocs/language/language_event.dart';
import 'package:pharmacy_mobile/blocs/language/language_state.dart';
class LanguageBloc extends Bloc<LanguageEvent, LanguageState> {
LanguageBloc() : super(LanguageState('')) {
on<LanguageSetValue>((event, emit) {
emit(LanguageState(event.value));
});
on<LanguageGetValue>((event, emit) {
emit(state);
});
}
}

View file

@ -0,0 +1,8 @@
abstract class LanguageEvent {}
class LanguageSetValue extends LanguageEvent {
final String value;
LanguageSetValue(this.value);
}
class LanguageGetValue extends LanguageEvent {}

View file

@ -0,0 +1,5 @@
class LanguageState {
final String value;
LanguageState(this.value);
}

View file

@ -0,0 +1,7 @@
import 'package:flutter/widgets.dart';
import 'package:pharmacy_mobile/blocs/language/functions/bloc_getlanguage.dart';
Future<String> getLanguage(BuildContext context) async {
final language = await blocGetLanguage(context);
return language;
}

View file

@ -8,6 +8,7 @@ import 'package:pharmacy_mobile/blocs/caches/medicinelist/medicinelist_cache_blo
import 'package:pharmacy_mobile/blocs/caches/stocklist/stocklist_cache_bloc.dart'; import 'package:pharmacy_mobile/blocs/caches/stocklist/stocklist_cache_bloc.dart';
import 'package:pharmacy_mobile/blocs/caches/typelist/typelist_cache_bloc.dart'; import 'package:pharmacy_mobile/blocs/caches/typelist/typelist_cache_bloc.dart';
import 'package:pharmacy_mobile/blocs/guest/guest_bloc.dart'; import 'package:pharmacy_mobile/blocs/guest/guest_bloc.dart';
import 'package:pharmacy_mobile/blocs/language/language_bloc.dart';
import 'package:pharmacy_mobile/blocs/user/user_bloc.dart'; import 'package:pharmacy_mobile/blocs/user/user_bloc.dart';
import 'package:pharmacy_mobile/pages/add_category_page.dart'; import 'package:pharmacy_mobile/pages/add_category_page.dart';
import 'package:pharmacy_mobile/pages/add_generics_page.dart'; import 'package:pharmacy_mobile/pages/add_generics_page.dart';
@ -163,6 +164,9 @@ class MyApp extends StatelessWidget {
BlocProvider( BlocProvider(
create: (context) => StockListBloc(), create: (context) => StockListBloc(),
), ),
BlocProvider(
create: (context) => LanguageBloc(),
),
], ],
child: MaterialApp.router( child: MaterialApp.router(
debugShowCheckedModeBanner: false, debugShowCheckedModeBanner: false,

View file

@ -1,5 +1,6 @@
import 'package:flutter/material.dart'; 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/blocs/language/functions/bloc_setlanguage.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_settings_page.dart'; import 'package:pharmacy_mobile/pages/customer_pages/customer_settings_page.dart';
@ -18,7 +19,23 @@ class _CustomerPageState extends State<CustomerPage> {
final _pageController = PageController(initialPage: 0); final _pageController = PageController(initialPage: 0);
final NotchBottomBarController _notchController = NotchBottomBarController(index: 0); final NotchBottomBarController _notchController = NotchBottomBarController(index: 0);
void sample() {} Future<void> _setDefault() async {
final language = await blocSetLanguage(context, 'English');
if (language) {
setState(() {});
}
}
void autoRun() async {
await _setDefault();
}
@override
void initState() {
autoRun();
super.initState();
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {

View file

@ -152,17 +152,16 @@ class _CustomerCartPageState extends State<CustomerCartPage> {
const Gap(16), const Gap(16),
const TextWidget( const TextWidget(
text: 'Cart is disabled for guests', text: 'Cart is disabled for guests',
size: 16, size: 12,
), ),
const Gap(8), const Gap(32),
const TextWidget( const TextWidget(
text: 'Please login', text: 'Please login',
size: 32, size: 20,
), ),
const Gap(8),
const TextWidget( const TextWidget(
text: 'to use your cart', text: 'to use your cart',
size: 24, size: 16,
), ),
const Gap(32), const Gap(32),
Padding( Padding(

View file

@ -18,6 +18,7 @@ class _CustomerMainPageState extends State<CustomerMainPage> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
body: CustomerPagebackgroundWidget( body: CustomerPagebackgroundWidget(
height: MediaQuery.of(context).size.height * 1.4,
child: Column( child: Column(
children: [ children: [
const Gap(68), const Gap(68),

View file

@ -3,6 +3,7 @@ import 'package:gap/gap.dart';
import 'package:go_router/go_router.dart'; import 'package:go_router/go_router.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/functions/getlanguage_function.dart';
import 'package:pharmacy_mobile/widgets/button_widget.dart'; import 'package:pharmacy_mobile/widgets/button_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';
@ -22,6 +23,7 @@ class _CustomerSettingsPageState extends State<CustomerSettingsPage> {
late String currentName = ''; late String currentName = '';
late bool _isGuest = false; late bool _isGuest = false;
late String currentLanguage = '';
void _signOut() async { void _signOut() async {
// ignore: use_build_context_synchronously // ignore: use_build_context_synchronously
@ -38,6 +40,13 @@ class _CustomerSettingsPageState extends State<CustomerSettingsPage> {
return username ?? ''; return username ?? '';
} }
void gotoSettings() async {
final changed = await context.push<bool>('/languagesetting');
if (changed == true) {
setState(() {});
}
}
void autoRun() async { void autoRun() async {
final guest = await _checkGuest(); final guest = await _checkGuest();
if (guest) { if (guest) {
@ -45,7 +54,8 @@ class _CustomerSettingsPageState extends State<CustomerSettingsPage> {
} else { } else {
currentName = await _getUsername(); currentName = await _getUsername();
} }
// ignore: use_build_context_synchronously
currentLanguage = await getLanguage(context);
setState(() {}); setState(() {});
} }
@ -69,10 +79,7 @@ class _CustomerSettingsPageState extends State<CustomerSettingsPage> {
const TextWidget(text: 'Settings'), const TextWidget(text: 'Settings'),
const Gap(16), const Gap(16),
SettingWidget( SettingWidget(
icon: Icons.language, icon: Icons.language, title: 'Language', value: currentLanguage, onPressed: () => gotoSettings()),
title: 'Language',
value: 'English',
onPressed: () => context.push('/languagesetting')),
const Gap(8), const Gap(8),
SettingWidget( SettingWidget(
icon: Icons.person, icon: Icons.person,

View file

@ -1,13 +1,33 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:gap/gap.dart'; import 'package:gap/gap.dart';
import 'package:pharmacy_mobile/functions/getlanguage_function.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';
import 'package:pharmacy_mobile/widgets/settings_menu_widget.dart'; import 'package:pharmacy_mobile/widgets/settings_menu_widget.dart';
import 'package:pharmacy_mobile/widgets/text_widget.dart'; import 'package:pharmacy_mobile/widgets/text_widget.dart';
class LanguageSettingPage extends StatelessWidget { class LanguageSettingPage extends StatefulWidget {
const LanguageSettingPage({super.key}); const LanguageSettingPage({super.key});
@override
State<LanguageSettingPage> createState() => _LanguageSettingPageState();
}
class _LanguageSettingPageState extends State<LanguageSettingPage> {
final languageList = ['English', 'Tagalog', 'Hilogaynon (Ilonggo)', 'Cebuano (Bisaya)'];
late String currentLanguage = '';
void autoRun() async {
currentLanguage = await getLanguage(context);
setState(() {});
}
@override
void initState() {
autoRun();
super.initState();
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
@ -19,7 +39,18 @@ class LanguageSettingPage extends StatelessWidget {
const Gap(32), const Gap(32),
const TextWidget(text: 'Language'), const TextWidget(text: 'Language'),
const Gap(16), const Gap(16),
SettingsMenuWidget() SettingsMenuWidget(
title: 'Current',
value: currentLanguage,
),
const Gap(16),
SettingsMenuWidget(
title: 'Other Options',
value: currentLanguage,
isSelection: true,
selectionList: languageList,
selectionFor: 'Language',
)
], ],
)), )),
); );

View file

@ -21,15 +21,16 @@ class CustomerPagebackgroundWidget extends StatelessWidget {
height: height ?? MediaQuery.of(context).size.height + 200, height: height ?? MediaQuery.of(context).size.height + 200,
decoration: BoxDecoration( decoration: BoxDecoration(
image: DecorationImage( image: DecorationImage(
image: AssetImage( // image: AssetImage(
page == 'login' // page == 'login'
? 'assets/login_background.webp' // ? 'assets/login_background.webp'
: page == 'register' // : page == 'register'
? 'assets/register_background.webp' // ? 'assets/register_background.webp'
: page == 'menu' // : page == 'menu'
? 'assets/menu_background.webp' // ? 'assets/menu_background.webp'
: 'assets/background.webp', // : 'assets/background.webp',
), // ),
image: AssetImage('assets/customer_background.webp'),
fit: BoxFit.cover, // Ensures the background covers the entire container fit: BoxFit.cover, // Ensures the background covers the entire container
alignment: Alignment.center, alignment: Alignment.center,
opacity: 0.1, // Adjusts the opacity as needed opacity: 0.1, // Adjusts the opacity as needed
@ -37,8 +38,8 @@ class CustomerPagebackgroundWidget extends StatelessWidget {
gradient: RadialGradient( gradient: RadialGradient(
tileMode: TileMode.clamp, tileMode: TileMode.clamp,
colors: [ colors: [
Color.fromRGBO(19, 8, 26, 1), Color.fromRGBO(15, 6, 20, 1),
Color.fromRGBO(43, 22, 60, 1), Color.fromRGBO(23, 12, 32, 1),
], ],
), ),
), ),

View file

@ -11,18 +11,31 @@ class IndicatorWidget extends StatelessWidget {
return Row( return Row(
mainAxisAlignment: MainAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start,
children: [ children: [
// Container(
// height: 24,
// padding: EdgeInsets.symmetric(horizontal: 16),
// decoration: BoxDecoration(
// border: Border.all(color: color ?? const Color.fromRGBO(249, 249, 249, 1), width: 1),
// borderRadius: BorderRadius.circular(20),
// color: color ?? const Color.fromRGBO(249, 249, 249, 1)),
// alignment: Alignment.center, // Center the text within the container
// child: TextWidget(
// text: text,
// size: 12,
// color: const Color.fromRGBO(0, 0, 0, 1),
// ),
// ),
Container( Container(
height: 24, padding: EdgeInsets.symmetric(horizontal: 16, vertical: 4),
padding: EdgeInsets.symmetric(horizontal: 16),
decoration: BoxDecoration( decoration: BoxDecoration(
border: Border.all(color: color ?? const Color.fromRGBO(249, 249, 249, 1), width: 1), // border: Border.all(color: color ?? const Color.fromRGBO(7, 5, 7, 0.783), width: 1),
borderRadius: BorderRadius.circular(20), borderRadius: BorderRadius.circular(20),
color: color ?? const Color.fromRGBO(249, 249, 249, 1)), color: color ?? const Color.fromRGBO(28, 10, 28, 0.894)),
alignment: Alignment.center, // Center the text within the container alignment: Alignment.center, // Center the text within the container
child: TextWidget( child: TextWidget(
text: text, text: text,
size: 12, size: 12,
color: const Color.fromRGBO(0, 0, 0, 1), color: const Color.fromARGB(255, 255, 255, 255),
), ),
), ),
], ],

View file

@ -15,7 +15,7 @@ class SettingWidget extends StatelessWidget {
return Container( return Container(
padding: EdgeInsets.symmetric(horizontal: 16, vertical: 16), padding: EdgeInsets.symmetric(horizontal: 16, vertical: 16),
decoration: BoxDecoration( decoration: BoxDecoration(
color: const Color.fromRGBO(39, 20, 36, 0.66), color: const Color.fromRGBO(28, 17, 32, 0.678),
border: Border.all(color: const Color.fromRGBO(74, 74, 74, 0.127)), border: Border.all(color: const Color.fromRGBO(74, 74, 74, 0.127)),
borderRadius: BorderRadius.circular(8.0)), borderRadius: BorderRadius.circular(8.0)),
child: SizedBox( child: SizedBox(

View file

@ -1,24 +1,73 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:gap/gap.dart';
import 'package:go_router/go_router.dart';
import 'package:pharmacy_mobile/blocs/language/functions/bloc_setlanguage.dart';
import 'package:pharmacy_mobile/widgets/text_widget.dart'; import 'package:pharmacy_mobile/widgets/text_widget.dart';
class SettingsMenuWidget extends StatefulWidget { class SettingsMenuWidget extends StatelessWidget {
const SettingsMenuWidget({super.key}); final String title;
final String value;
final bool? isSelection;
final List selectionList;
final String selectionFor;
@override const SettingsMenuWidget({
State<SettingsMenuWidget> createState() => _SettingsMenuWidgetState(); super.key,
} required this.title,
required this.value,
this.isSelection = false,
this.selectionList = const [],
this.selectionFor = '',
});
class _SettingsMenuWidgetState extends State<SettingsMenuWidget> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
void setNewValue(String newValue) async {
switch (selectionFor) {
case 'Language':
final language = await blocSetLanguage(context, newValue);
if (language) {
// ignore: use_build_context_synchronously
context.pop(true);
}
break;
default:
break;
}
}
return Container( return Container(
padding: const EdgeInsets.all(16), padding: const EdgeInsets.all(16),
width: MediaQuery.of(context).size.width * 0.9, width: MediaQuery.of(context).size.width,
decoration: BoxDecoration(color: const Color.fromRGBO(28, 17, 32, 0.678), borderRadius: BorderRadius.circular(8.0)), decoration:
child: Column( BoxDecoration(color: const Color.fromRGBO(28, 17, 32, 0.678), borderRadius: BorderRadius.circular(8.0)),
crossAxisAlignment: CrossAxisAlignment.start, child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
children: [TextWidget(text: 'Current', size: 8,), TextWidget(text: 'text')], TextWidget(
), text: title,
size: 8,
),
const Gap(8),
if (isSelection!)
Column(mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: [
const Gap(8),
for (var item in selectionList)
GestureDetector(
onTap: () => setNewValue(item),
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 8),
child: TextWidget(text: item, size: 12, color: const Color.fromRGBO(255, 255, 255, 1)),
),
),
const Gap(8),
])
else
TextWidget(
text: value,
size: 12,
bold: true,
),
]),
); );
} }
} }

View file

@ -52,6 +52,7 @@ flutter:
- assets/background.webp - assets/background.webp
- assets/login_background.webp - assets/login_background.webp
- assets/register_background.webp - assets/register_background.webp
- assets/customer_background.webp
- assets/menu_background.webp - assets/menu_background.webp
- assets/ofa_logo.webp - assets/ofa_logo.webp
- assets/php_logo.webp - assets/php_logo.webp