mirror of
https://github.com/revanced/revanced-manager
synced 2024-05-14 13:56:57 +02:00
feat: Display current app language at the top of the list
This commit is contained in:
parent
4ca7b8a7c1
commit
aa0575a637
@ -37,6 +37,14 @@ class SUpdateLanguage extends BaseViewModel {
|
|||||||
final ValueNotifier<String> selectedLanguageCode = ValueNotifier(
|
final ValueNotifier<String> selectedLanguageCode = ValueNotifier(
|
||||||
'${LocaleSettings.currentLocale.languageCode}-${LocaleSettings.currentLocale.countryCode}',
|
'${LocaleSettings.currentLocale.languageCode}-${LocaleSettings.currentLocale.countryCode}',
|
||||||
);
|
);
|
||||||
|
LanguageCodes getLanguageCode(locale) {
|
||||||
|
return LanguageCodes.fromCode(
|
||||||
|
'${locale.languageCode}_${locale.countryCode}',
|
||||||
|
orElse: () => LanguageCodes.fromCode(locale.languageCode),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
final currentlyUsedLanguage = getLanguageCode(LocaleSettings.currentLocale);
|
||||||
// initLang();
|
// initLang();
|
||||||
|
|
||||||
// Return a dialog with list for each language supported by the application.
|
// Return a dialog with list for each language supported by the application.
|
||||||
@ -53,17 +61,29 @@ class SUpdateLanguage extends BaseViewModel {
|
|||||||
builder: (context, value, child) {
|
builder: (context, value, child) {
|
||||||
return SingleChildScrollView(
|
return SingleChildScrollView(
|
||||||
child: ListBody(
|
child: ListBody(
|
||||||
children: AppLocale.values.map(
|
children: [
|
||||||
(locale) {
|
RadioListTile(
|
||||||
final LanguageCodes languageCode = LanguageCodes.fromCode(
|
title: Text(currentlyUsedLanguage.englishName),
|
||||||
'${locale.languageCode}_${locale.countryCode}',
|
subtitle: Text(
|
||||||
orElse: () => LanguageCodes.fromCode(locale.languageCode),
|
'${currentlyUsedLanguage.nativeName} (${LocaleSettings.currentLocale.languageCode}${LocaleSettings.currentLocale.countryCode != null ? '-${LocaleSettings.currentLocale.countryCode}' : ''})'),
|
||||||
);
|
value:
|
||||||
|
'${LocaleSettings.currentLocale.languageCode}-${LocaleSettings.currentLocale.countryCode}' ==
|
||||||
|
selectedLanguageCode.value,
|
||||||
|
groupValue: true,
|
||||||
|
onChanged: (value) {
|
||||||
|
selectedLanguageCode.value =
|
||||||
|
'${LocaleSettings.currentLocale.languageCode}-${LocaleSettings.currentLocale.countryCode}';
|
||||||
|
},
|
||||||
|
),
|
||||||
|
...AppLocale.values
|
||||||
|
.where(
|
||||||
|
(locale) =>
|
||||||
|
locale.languageCode != currentlyUsedLanguage.code,
|
||||||
|
)
|
||||||
|
.map((locale) {
|
||||||
|
final languageCode = getLanguageCode(locale);
|
||||||
return RadioListTile(
|
return RadioListTile(
|
||||||
title: Text(
|
title: Text(languageCode.englishName),
|
||||||
languageCode.englishName,
|
|
||||||
),
|
|
||||||
subtitle: Text(
|
subtitle: Text(
|
||||||
'${languageCode.nativeName} (${locale.languageCode}${locale.countryCode != null ? '-${locale.countryCode}' : ''})',
|
'${languageCode.nativeName} (${locale.languageCode}${locale.countryCode != null ? '-${locale.countryCode}' : ''})',
|
||||||
),
|
),
|
||||||
@ -75,8 +95,8 @@ class SUpdateLanguage extends BaseViewModel {
|
|||||||
'${locale.languageCode}-${locale.countryCode}';
|
'${locale.languageCode}-${locale.countryCode}';
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
},
|
}),
|
||||||
).toList(),
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user