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),
const Gap(8),
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> {
static const List<String> languageList = ['English', 'Tagalog', 'Hilogaynon (Ilonggo)', 'Cebuano (Bisaya)'];
final _authService = AuthService();
late String currentName = '';
@ -41,10 +42,10 @@ class _CustomerSettingsPageState extends State<CustomerSettingsPage> {
}
void gotoSettings() async {
final changed = await context.push<bool>('/languagesetting');
if (changed == true) {
setState(() {});
}
await context.push('/languagesetting');
// ignore: use_build_context_synchronously
currentLanguage = await getLanguage(context);
setState(() {});
}
void autoRun() async {
@ -71,25 +72,86 @@ class _CustomerSettingsPageState extends State<CustomerSettingsPage> {
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: currentLanguage, onPressed: () => gotoSettings()),
const Gap(8),
SettingWidget(
icon: Icons.person,
title: 'Display Name',
value: _isGuest ? 'Guest' : currentName,
),
const Gap(32),
ButtonWidget(text: 'Log Out', onPressed: _signOut)
],
)
if (currentLanguage == languageList[0])
Column(
children: [
const Gap(68),
const CustomerTitleWidget(),
const Gap(32),
const TextWidget(text: 'Settings'),
const Gap(16),
SettingWidget(
icon: Icons.language, title: 'Language', value: currentLanguage, onPressed: () => gotoSettings()),
const Gap(8),
SettingWidget(
icon: Icons.person,
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,
),
const Gap(32),
ButtonWidget(text: 'Log Out', onPressed: _signOut)
],
)
],
)));
}

View file

@ -14,7 +14,7 @@ class LanguageSettingPage extends StatefulWidget {
}
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 = '';
void autoRun() async {
@ -37,20 +37,76 @@ class _LanguageSettingPageState extends State<LanguageSettingPage> {
const Gap(68),
const CustomerTitleWidget(),
const Gap(32),
const TextWidget(text: 'Language'),
const Gap(16),
SettingsMenuWidget(
title: 'Current',
value: currentLanguage,
),
const Gap(16),
SettingsMenuWidget(
title: 'Other Options',
value: currentLanguage,
isSelection: true,
selectionList: languageList,
selectionFor: 'Language',
)
if (currentLanguage == languageList[0])
Column(
children: [
const TextWidget(text: 'Language'),
const Gap(16),
SettingsMenuWidget(
title: 'Current',
value: currentLanguage,
),
const Gap(16),
SettingsMenuWidget(
title: 'Other Options',
value: currentLanguage,
isSelection: true,
selectionList: languageList,
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);
if (language) {
// ignore: use_build_context_synchronously
context.pop(true);
context.pop();
}
break;
@ -55,7 +55,7 @@ class SettingsMenuWidget extends StatelessWidget {
GestureDetector(
onTap: () => setNewValue(item),
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)),
),
),