TF-1579 Always put source language in addition to current language

This commit is contained in:
dab246
2023-03-10 14:37:23 +07:00
committed by Dat Vu
parent 266000da91
commit 42bde0e415
4 changed files with 46 additions and 16 deletions
@@ -4,7 +4,7 @@ import 'package:tmail_ui_user/main/localizations/app_localizations.dart';
extension LocaleExtension on Locale {
String getLanguageName(BuildContext context) {
String getLanguageNameByCurrentLocale(BuildContext context) {
switch(languageCode) {
case 'fr':
return AppLocalizations.of(context).languageFrench;
@@ -22,4 +22,23 @@ extension LocaleExtension on Locale {
return '';
}
}
String getSourceLanguageName() {
switch(languageCode) {
case 'fr':
return 'Français';
case 'en':
return 'English';
case 'vi':
return 'Tiếng Việt';
case 'ru':
return 'Русский';
case 'ar':
return 'اَلْعَرَبِيَّةُ';
case 'it':
return 'Italiano';
default:
return '';
}
}
}
@@ -112,7 +112,7 @@ class ChangeLanguageButtonWidget extends StatelessWidget {
padding: const EdgeInsets.only(left: 12, right: 10),
child: Row(children: [
Expanded(child: Text(
_controller.languageSelected.value.getLanguageName(context),
_controller.languageSelected.value.getLanguageNameByCurrentLocale(context),
style: const TextStyle(
fontSize: 16,
fontWeight: FontWeight.normal,
@@ -33,16 +33,31 @@ class LanguageItemWidget extends StatelessWidget {
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 16),
child: Row(children: [
Expanded(child: Text(
localeCurrent.getLanguageName(context),
style: const TextStyle(
fontSize: 17,
fontWeight: FontWeight.normal,
color: Colors.black
),
maxLines: 1,
softWrap: CommonTextStyle.defaultSoftWrap,
overflow: CommonTextStyle.defaultTextOverFlow,
Expanded(child: Row(
children: [
Text(
localeCurrent.getLanguageNameByCurrentLocale(context),
style: const TextStyle(
fontSize: 17,
fontWeight: FontWeight.normal,
color: Colors.black
),
maxLines: 1,
softWrap: CommonTextStyle.defaultSoftWrap,
overflow: CommonTextStyle.defaultTextOverFlow,
),
Text(
' - ${localeCurrent.getSourceLanguageName()}',
style: const TextStyle(
fontSize: 17,
fontWeight: FontWeight.w500,
color: Colors.black
),
maxLines: 1,
softWrap: CommonTextStyle.defaultSoftWrap,
overflow: CommonTextStyle.defaultTextOverFlow,
)
]
)),
if (localeCurrent == localeSelected)
SvgPicture.asset(