fix languages in settings

This commit is contained in:
Patrick Alvin Alcala 2025-03-26 15:46:09 +08:00
parent 6424e82d54
commit 023db31270
4 changed files with 159 additions and 41 deletions

View file

@ -77,7 +77,7 @@ class _CustomerMainPageState extends State<CustomerMainPage> {
title: 'Toothache', description: "a.k.a tooth pain, is pain in the teeth or their...", margin: 16), title: 'Toothache', description: "a.k.a tooth pain, is pain in the teeth or their...", margin: 16),
const Gap(8), const Gap(8),
const DescriptionMenuWidget( const DescriptionMenuWidget(
title: 'Stomach Ache', description: " is a symptom associated with both non-serious and...", margin: 16), title: 'Stomach Ache', description: " is a symptom associated with both non-serious...", margin: 16),
], ],
))); )));
} }

View file

@ -19,6 +19,7 @@ class CustomerSettingsPage extends StatefulWidget {
} }
class _CustomerSettingsPageState extends State<CustomerSettingsPage> { class _CustomerSettingsPageState extends State<CustomerSettingsPage> {
static const List<String> languageList = ['English', 'Tagalog', 'Hilogaynon (Ilonggo)', 'Cebuano (Bisaya)'];
final _authService = AuthService(); final _authService = AuthService();
late String currentName = ''; late String currentName = '';
@ -41,11 +42,11 @@ class _CustomerSettingsPageState extends State<CustomerSettingsPage> {
} }
void gotoSettings() async { void gotoSettings() async {
final changed = await context.push<bool>('/languagesetting'); await context.push('/languagesetting');
if (changed == true) { // ignore: use_build_context_synchronously
currentLanguage = await getLanguage(context);
setState(() {}); setState(() {});
} }
}
void autoRun() async { void autoRun() async {
final guest = await _checkGuest(); final guest = await _checkGuest();
@ -71,6 +72,7 @@ class _CustomerSettingsPageState extends State<CustomerSettingsPage> {
body: CustomerPagebackgroundWidget( body: CustomerPagebackgroundWidget(
child: Column( child: Column(
children: [ children: [
if (currentLanguage == languageList[0])
Column( Column(
children: [ children: [
const Gap(68), const Gap(68),
@ -83,7 +85,67 @@ class _CustomerSettingsPageState extends State<CustomerSettingsPage> {
const Gap(8), const Gap(8),
SettingWidget( SettingWidget(
icon: Icons.person, icon: Icons.person,
title: 'Display Name', title: 'Name',
value: _isGuest ? 'Guest' : currentName,
),
const Gap(32),
ButtonWidget(text: 'Log Out', onPressed: _signOut)
],
)
else if (currentLanguage == languageList[1])
Column(
children: [
const Gap(68),
const CustomerTitleWidget(),
const Gap(32),
const TextWidget(text: 'Mga Setting'),
const Gap(16),
SettingWidget(
icon: Icons.language, title: 'Wika', value: currentLanguage, onPressed: () => gotoSettings()),
const Gap(8),
SettingWidget(
icon: Icons.person,
title: 'Pangalan',
value: _isGuest ? 'Guest' : currentName,
),
const Gap(32),
ButtonWidget(text: 'Log Out', onPressed: _signOut)
],
)
else if (currentLanguage == languageList[2])
Column(
children: [
const Gap(68),
const CustomerTitleWidget(),
const Gap(32),
const TextWidget(text: 'Mga Setting'),
const Gap(16),
SettingWidget(
icon: Icons.language, title: 'Lenggwahe', 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)
],
)
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, value: _isGuest ? 'Guest' : currentName,
), ),
const Gap(32), const Gap(32),

View file

@ -14,7 +14,7 @@ class LanguageSettingPage extends StatefulWidget {
} }
class _LanguageSettingPageState extends State<LanguageSettingPage> { class _LanguageSettingPageState extends State<LanguageSettingPage> {
final languageList = ['English', 'Tagalog', 'Hilogaynon (Ilonggo)', 'Cebuano (Bisaya)']; static const List<String> languageList = ['English', 'Tagalog', 'Hilogaynon (Ilonggo)', 'Cebuano (Bisaya)'];
late String currentLanguage = ''; late String currentLanguage = '';
void autoRun() async { void autoRun() async {
@ -37,6 +37,9 @@ class _LanguageSettingPageState extends State<LanguageSettingPage> {
const Gap(68), const Gap(68),
const CustomerTitleWidget(), const CustomerTitleWidget(),
const Gap(32), const Gap(32),
if (currentLanguage == languageList[0])
Column(
children: [
const TextWidget(text: 'Language'), const TextWidget(text: 'Language'),
const Gap(16), const Gap(16),
SettingsMenuWidget( SettingsMenuWidget(
@ -52,6 +55,59 @@ class _LanguageSettingPageState extends State<LanguageSettingPage> {
selectionFor: 'Language', selectionFor: 'Language',
) )
], ],
)
else if (currentLanguage == languageList[1])
Column(children: [
const TextWidget(text: 'Wika'),
const Gap(16),
SettingsMenuWidget(
title: 'Kasalukuyan',
value: currentLanguage,
),
const Gap(16),
SettingsMenuWidget(
title: 'Iba pang mga Opsyon',
value: currentLanguage,
isSelection: true,
selectionList: languageList,
selectionFor: 'Language',
)
])
else if (currentLanguage == languageList[2])
Column(children: [
const TextWidget(text: 'Lenggwahe'),
const Gap(16),
SettingsMenuWidget(
title: 'Ang Subong',
value: currentLanguage,
),
const Gap(16),
SettingsMenuWidget(
title: 'Iban pa nga mga Opsyon',
value: currentLanguage,
isSelection: true,
selectionList: languageList,
selectionFor: 'Language',
)
])
else if (currentLanguage == languageList[3])
Column(children: [
const TextWidget(text: 'Pinulongan'),
const Gap(16),
SettingsMenuWidget(
title: 'Ang Karon',
value: currentLanguage,
),
const Gap(16),
SettingsMenuWidget(
title: 'Uban pa na mga Opsyon',
value: currentLanguage,
isSelection: true,
selectionList: languageList,
selectionFor: 'Language',
)
])
],
)), )),
); );
} }

View file

@ -28,7 +28,7 @@ class SettingsMenuWidget extends StatelessWidget {
final language = await blocSetLanguage(context, newValue); final language = await blocSetLanguage(context, newValue);
if (language) { if (language) {
// ignore: use_build_context_synchronously // ignore: use_build_context_synchronously
context.pop(true); context.pop();
} }
break; break;
@ -55,7 +55,7 @@ class SettingsMenuWidget extends StatelessWidget {
GestureDetector( GestureDetector(
onTap: () => setNewValue(item), onTap: () => setNewValue(item),
child: Padding( child: Padding(
padding: const EdgeInsets.symmetric(vertical: 8), padding: const EdgeInsets.symmetric(vertical: 16),
child: TextWidget(text: item, size: 12, color: const Color.fromRGBO(255, 255, 255, 1)), child: TextWidget(text: item, size: 12, color: const Color.fromRGBO(255, 255, 255, 1)),
), ),
), ),