update on settings and customer background
This commit is contained in:
parent
05c3208cad
commit
6424e82d54
18 changed files with 227 additions and 42 deletions
BIN
assets/customer_background.webp
Normal file
BIN
assets/customer_background.webp
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 175 KiB |
14
lib/blocs/language/functions/bloc_getlanguage.dart
Normal file
14
lib/blocs/language/functions/bloc_getlanguage.dart
Normal 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 '';
|
||||
}
|
||||
}
|
||||
14
lib/blocs/language/functions/bloc_setlanguage.dart
Normal file
14
lib/blocs/language/functions/bloc_setlanguage.dart
Normal 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;
|
||||
}
|
||||
}
|
||||
14
lib/blocs/language/language_bloc.dart
Normal file
14
lib/blocs/language/language_bloc.dart
Normal 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);
|
||||
});
|
||||
}
|
||||
}
|
||||
8
lib/blocs/language/language_event.dart
Normal file
8
lib/blocs/language/language_event.dart
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
abstract class LanguageEvent {}
|
||||
|
||||
class LanguageSetValue extends LanguageEvent {
|
||||
final String value;
|
||||
LanguageSetValue(this.value);
|
||||
}
|
||||
|
||||
class LanguageGetValue extends LanguageEvent {}
|
||||
5
lib/blocs/language/language_state.dart
Normal file
5
lib/blocs/language/language_state.dart
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
class LanguageState {
|
||||
final String value;
|
||||
|
||||
LanguageState(this.value);
|
||||
}
|
||||
7
lib/functions/getlanguage_function.dart
Normal file
7
lib/functions/getlanguage_function.dart
Normal 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;
|
||||
}
|
||||
|
|
@ -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/typelist/typelist_cache_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/pages/add_category_page.dart';
|
||||
import 'package:pharmacy_mobile/pages/add_generics_page.dart';
|
||||
|
|
@ -163,6 +164,9 @@ class MyApp extends StatelessWidget {
|
|||
BlocProvider(
|
||||
create: (context) => StockListBloc(),
|
||||
),
|
||||
BlocProvider(
|
||||
create: (context) => LanguageBloc(),
|
||||
),
|
||||
],
|
||||
child: MaterialApp.router(
|
||||
debugShowCheckedModeBanner: false,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import 'package:flutter/material.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_main_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 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
|
||||
Widget build(BuildContext context) {
|
||||
|
|
|
|||
|
|
@ -152,17 +152,16 @@ class _CustomerCartPageState extends State<CustomerCartPage> {
|
|||
const Gap(16),
|
||||
const TextWidget(
|
||||
text: 'Cart is disabled for guests',
|
||||
size: 16,
|
||||
size: 12,
|
||||
),
|
||||
const Gap(8),
|
||||
const Gap(32),
|
||||
const TextWidget(
|
||||
text: 'Please login',
|
||||
size: 32,
|
||||
size: 20,
|
||||
),
|
||||
const Gap(8),
|
||||
const TextWidget(
|
||||
text: 'to use your cart',
|
||||
size: 24,
|
||||
size: 16,
|
||||
),
|
||||
const Gap(32),
|
||||
Padding(
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ class _CustomerMainPageState extends State<CustomerMainPage> {
|
|||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
body: CustomerPagebackgroundWidget(
|
||||
height: MediaQuery.of(context).size.height * 1.4,
|
||||
child: Column(
|
||||
children: [
|
||||
const Gap(68),
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ 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/functions/getlanguage_function.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';
|
||||
|
|
@ -22,6 +23,7 @@ class _CustomerSettingsPageState extends State<CustomerSettingsPage> {
|
|||
|
||||
late String currentName = '';
|
||||
late bool _isGuest = false;
|
||||
late String currentLanguage = '';
|
||||
|
||||
void _signOut() async {
|
||||
// ignore: use_build_context_synchronously
|
||||
|
|
@ -38,6 +40,13 @@ class _CustomerSettingsPageState extends State<CustomerSettingsPage> {
|
|||
return username ?? '';
|
||||
}
|
||||
|
||||
void gotoSettings() async {
|
||||
final changed = await context.push<bool>('/languagesetting');
|
||||
if (changed == true) {
|
||||
setState(() {});
|
||||
}
|
||||
}
|
||||
|
||||
void autoRun() async {
|
||||
final guest = await _checkGuest();
|
||||
if (guest) {
|
||||
|
|
@ -45,7 +54,8 @@ class _CustomerSettingsPageState extends State<CustomerSettingsPage> {
|
|||
} else {
|
||||
currentName = await _getUsername();
|
||||
}
|
||||
|
||||
// ignore: use_build_context_synchronously
|
||||
currentLanguage = await getLanguage(context);
|
||||
setState(() {});
|
||||
}
|
||||
|
||||
|
|
@ -69,10 +79,7 @@ class _CustomerSettingsPageState extends State<CustomerSettingsPage> {
|
|||
const TextWidget(text: 'Settings'),
|
||||
const Gap(16),
|
||||
SettingWidget(
|
||||
icon: Icons.language,
|
||||
title: 'Language',
|
||||
value: 'English',
|
||||
onPressed: () => context.push('/languagesetting')),
|
||||
icon: Icons.language, title: 'Language', value: currentLanguage, onPressed: () => gotoSettings()),
|
||||
const Gap(8),
|
||||
SettingWidget(
|
||||
icon: Icons.person,
|
||||
|
|
|
|||
|
|
@ -1,13 +1,33 @@
|
|||
import 'package:flutter/material.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_title_widget.dart';
|
||||
import 'package:pharmacy_mobile/widgets/settings_menu_widget.dart';
|
||||
import 'package:pharmacy_mobile/widgets/text_widget.dart';
|
||||
|
||||
class LanguageSettingPage extends StatelessWidget {
|
||||
class LanguageSettingPage extends StatefulWidget {
|
||||
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
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
|
|
@ -19,7 +39,18 @@ class LanguageSettingPage extends StatelessWidget {
|
|||
const Gap(32),
|
||||
const TextWidget(text: 'Language'),
|
||||
const Gap(16),
|
||||
SettingsMenuWidget()
|
||||
SettingsMenuWidget(
|
||||
title: 'Current',
|
||||
value: currentLanguage,
|
||||
),
|
||||
const Gap(16),
|
||||
SettingsMenuWidget(
|
||||
title: 'Other Options',
|
||||
value: currentLanguage,
|
||||
isSelection: true,
|
||||
selectionList: languageList,
|
||||
selectionFor: 'Language',
|
||||
)
|
||||
],
|
||||
)),
|
||||
);
|
||||
|
|
|
|||
|
|
@ -21,15 +21,16 @@ class CustomerPagebackgroundWidget extends StatelessWidget {
|
|||
height: height ?? MediaQuery.of(context).size.height + 200,
|
||||
decoration: BoxDecoration(
|
||||
image: DecorationImage(
|
||||
image: AssetImage(
|
||||
page == 'login'
|
||||
? 'assets/login_background.webp'
|
||||
: page == 'register'
|
||||
? 'assets/register_background.webp'
|
||||
: page == 'menu'
|
||||
? 'assets/menu_background.webp'
|
||||
: 'assets/background.webp',
|
||||
),
|
||||
// image: AssetImage(
|
||||
// page == 'login'
|
||||
// ? 'assets/login_background.webp'
|
||||
// : page == 'register'
|
||||
// ? 'assets/register_background.webp'
|
||||
// : page == 'menu'
|
||||
// ? 'assets/menu_background.webp'
|
||||
// : 'assets/background.webp',
|
||||
// ),
|
||||
image: AssetImage('assets/customer_background.webp'),
|
||||
fit: BoxFit.cover, // Ensures the background covers the entire container
|
||||
alignment: Alignment.center,
|
||||
opacity: 0.1, // Adjusts the opacity as needed
|
||||
|
|
@ -37,8 +38,8 @@ class CustomerPagebackgroundWidget extends StatelessWidget {
|
|||
gradient: RadialGradient(
|
||||
tileMode: TileMode.clamp,
|
||||
colors: [
|
||||
Color.fromRGBO(19, 8, 26, 1),
|
||||
Color.fromRGBO(43, 22, 60, 1),
|
||||
Color.fromRGBO(15, 6, 20, 1),
|
||||
Color.fromRGBO(23, 12, 32, 1),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
|
|
|||
|
|
@ -11,18 +11,31 @@ class IndicatorWidget extends StatelessWidget {
|
|||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
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(
|
||||
height: 24,
|
||||
padding: EdgeInsets.symmetric(horizontal: 16),
|
||||
padding: EdgeInsets.symmetric(horizontal: 16, vertical: 4),
|
||||
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),
|
||||
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
|
||||
child: TextWidget(
|
||||
text: text,
|
||||
size: 12,
|
||||
color: const Color.fromRGBO(0, 0, 0, 1),
|
||||
color: const Color.fromARGB(255, 255, 255, 255),
|
||||
),
|
||||
),
|
||||
],
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ class SettingWidget extends StatelessWidget {
|
|||
return Container(
|
||||
padding: EdgeInsets.symmetric(horizontal: 16, vertical: 16),
|
||||
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)),
|
||||
borderRadius: BorderRadius.circular(8.0)),
|
||||
child: SizedBox(
|
||||
|
|
|
|||
|
|
@ -1,24 +1,73 @@
|
|||
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';
|
||||
|
||||
class SettingsMenuWidget extends StatefulWidget {
|
||||
const SettingsMenuWidget({super.key});
|
||||
class SettingsMenuWidget extends StatelessWidget {
|
||||
final String title;
|
||||
final String value;
|
||||
final bool? isSelection;
|
||||
final List selectionList;
|
||||
final String selectionFor;
|
||||
|
||||
@override
|
||||
State<SettingsMenuWidget> createState() => _SettingsMenuWidgetState();
|
||||
}
|
||||
const SettingsMenuWidget({
|
||||
super.key,
|
||||
required this.title,
|
||||
required this.value,
|
||||
this.isSelection = false,
|
||||
this.selectionList = const [],
|
||||
this.selectionFor = '',
|
||||
});
|
||||
|
||||
class _SettingsMenuWidgetState extends State<SettingsMenuWidget> {
|
||||
@override
|
||||
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(
|
||||
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')],
|
||||
),
|
||||
width: MediaQuery.of(context).size.width,
|
||||
decoration:
|
||||
BoxDecoration(color: const Color.fromRGBO(28, 17, 32, 0.678), borderRadius: BorderRadius.circular(8.0)),
|
||||
child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
|
||||
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,
|
||||
),
|
||||
]),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -52,6 +52,7 @@ flutter:
|
|||
- assets/background.webp
|
||||
- assets/login_background.webp
|
||||
- assets/register_background.webp
|
||||
- assets/customer_background.webp
|
||||
- assets/menu_background.webp
|
||||
- assets/ofa_logo.webp
|
||||
- assets/php_logo.webp
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue