mirror of
https://github.com/ReVanced/revanced-manager.git
synced 2026-01-27 13:01:02 +00:00
feat: Allow changing languages (#1488)
Co-authored-by: validcube <pun.butrach@gmail.com>
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
// ignore_for_file: use_build_context_synchronously
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_i18n/flutter_i18n.dart';
|
||||
import 'package:revanced_manager/app/app.locator.dart';
|
||||
import 'package:revanced_manager/gen/strings.g.dart';
|
||||
import 'package:revanced_manager/services/manager_api.dart';
|
||||
import 'package:revanced_manager/ui/widgets/settingsView/settings_tile_dialog.dart';
|
||||
import 'package:stacked/stacked.dart';
|
||||
@@ -20,7 +20,7 @@ class SManageApiUrl extends BaseViewModel {
|
||||
builder: (context) => AlertDialog(
|
||||
title: Row(
|
||||
children: <Widget>[
|
||||
I18nText('settingsView.apiURLLabel'),
|
||||
Text(t.settingsView.apiURLLabel),
|
||||
const Spacer(),
|
||||
IconButton(
|
||||
icon: const Icon(Icons.manage_history_outlined),
|
||||
@@ -42,10 +42,7 @@ class SManageApiUrl extends BaseViewModel {
|
||||
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||
),
|
||||
border: const OutlineInputBorder(),
|
||||
labelText: FlutterI18n.translate(
|
||||
context,
|
||||
'settingsView.selectApiURL',
|
||||
),
|
||||
labelText: t.settingsView.selectApiURL,
|
||||
hintText: apiUrl,
|
||||
),
|
||||
),
|
||||
@@ -58,7 +55,7 @@ class SManageApiUrl extends BaseViewModel {
|
||||
_apiUrlController.clear();
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
child: I18nText('cancelButton'),
|
||||
child: Text(t.cancelButton),
|
||||
),
|
||||
FilledButton(
|
||||
onPressed: () {
|
||||
@@ -69,7 +66,7 @@ class SManageApiUrl extends BaseViewModel {
|
||||
_managerAPI.setApiUrl(apiUrl);
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
child: I18nText('okButton'),
|
||||
child: Text(t.okButton),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -80,12 +77,12 @@ class SManageApiUrl extends BaseViewModel {
|
||||
return showDialog(
|
||||
context: context,
|
||||
builder: (context) => AlertDialog(
|
||||
title: I18nText('settingsView.sourcesResetDialogTitle'),
|
||||
content: I18nText('settingsView.apiURLResetDialogText'),
|
||||
title: Text(t.settingsView.sourcesResetDialogTitle),
|
||||
content: Text(t.settingsView.apiURLResetDialogText),
|
||||
actions: <Widget>[
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
child: I18nText('noButton'),
|
||||
child: Text(t.noButton),
|
||||
),
|
||||
FilledButton(
|
||||
onPressed: () {
|
||||
@@ -94,7 +91,7 @@ class SManageApiUrl extends BaseViewModel {
|
||||
..pop()
|
||||
..pop();
|
||||
},
|
||||
child: I18nText('yesButton'),
|
||||
child: Text(t.yesButton),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -111,8 +108,8 @@ class SManageApiUrlUI extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
return SettingsTileDialog(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 20.0),
|
||||
title: 'settingsView.apiURLLabel',
|
||||
subtitle: 'settingsView.apiURLHint',
|
||||
title: t.settingsView.apiURLLabel,
|
||||
subtitle: t.settingsView.apiURLHint,
|
||||
onTap: () => sManageApiUrl.showApiUrlDialog(context),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
// ignore_for_file: use_build_context_synchronously
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_i18n/flutter_i18n.dart';
|
||||
import 'package:revanced_manager/app/app.locator.dart';
|
||||
import 'package:revanced_manager/gen/strings.g.dart';
|
||||
import 'package:revanced_manager/services/manager_api.dart';
|
||||
import 'package:revanced_manager/ui/widgets/settingsView/settings_tile_dialog.dart';
|
||||
import 'package:stacked/stacked.dart';
|
||||
@@ -21,7 +21,7 @@ class SManageKeystorePassword extends BaseViewModel {
|
||||
builder: (context) => AlertDialog(
|
||||
title: Row(
|
||||
children: <Widget>[
|
||||
I18nText('settingsView.selectKeystorePassword'),
|
||||
Text(t.settingsView.selectKeystorePassword),
|
||||
const Spacer(),
|
||||
IconButton(
|
||||
icon: const Icon(Icons.manage_history_outlined),
|
||||
@@ -41,10 +41,7 @@ class SManageKeystorePassword extends BaseViewModel {
|
||||
onChanged: (value) => notifyListeners(),
|
||||
decoration: InputDecoration(
|
||||
border: const OutlineInputBorder(),
|
||||
labelText: FlutterI18n.translate(
|
||||
context,
|
||||
'settingsView.selectKeystorePassword',
|
||||
),
|
||||
labelText: t.settingsView.selectKeystorePassword,
|
||||
),
|
||||
),
|
||||
],
|
||||
@@ -56,7 +53,7 @@ class SManageKeystorePassword extends BaseViewModel {
|
||||
_keystorePasswordController.clear();
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
child: I18nText('cancelButton'),
|
||||
child: Text(t.cancelButton),
|
||||
),
|
||||
FilledButton(
|
||||
onPressed: () {
|
||||
@@ -64,7 +61,7 @@ class SManageKeystorePassword extends BaseViewModel {
|
||||
_managerAPI.setKeystorePassword(passwd);
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
child: I18nText('okButton'),
|
||||
child: Text(t.okButton),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -81,8 +78,8 @@ class SManageKeystorePasswordUI extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
return SettingsTileDialog(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 20.0),
|
||||
title: 'settingsView.selectKeystorePassword',
|
||||
subtitle: 'settingsView.selectKeystorePasswordHint',
|
||||
title: t.settingsView.selectKeystorePassword,
|
||||
subtitle: t.settingsView.selectKeystorePasswordHint,
|
||||
onTap: () => sManageKeystorePassword.showKeystoreDialog(context),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
// ignore_for_file: use_build_context_synchronously
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_i18n/flutter_i18n.dart';
|
||||
import 'package:revanced_manager/app/app.locator.dart';
|
||||
import 'package:revanced_manager/gen/strings.g.dart';
|
||||
import 'package:revanced_manager/services/manager_api.dart';
|
||||
import 'package:revanced_manager/services/toast.dart';
|
||||
import 'package:revanced_manager/ui/widgets/settingsView/settings_tile_dialog.dart';
|
||||
@@ -32,7 +32,7 @@ class SManageSources extends BaseViewModel {
|
||||
builder: (context) => AlertDialog(
|
||||
title: Row(
|
||||
children: <Widget>[
|
||||
I18nText('settingsView.sourcesLabel'),
|
||||
Text(t.settingsView.sourcesLabel),
|
||||
const Spacer(),
|
||||
IconButton(
|
||||
icon: const Icon(Icons.manage_history_outlined),
|
||||
@@ -58,10 +58,7 @@ class SManageSources extends BaseViewModel {
|
||||
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||
),
|
||||
border: const OutlineInputBorder(),
|
||||
labelText: FlutterI18n.translate(
|
||||
context,
|
||||
'settingsView.hostRepositoryLabel',
|
||||
),
|
||||
labelText: t.settingsView.hostRepositoryLabel,
|
||||
hintText: hostRepository,
|
||||
),
|
||||
),
|
||||
@@ -77,10 +74,7 @@ class SManageSources extends BaseViewModel {
|
||||
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||
),
|
||||
border: const OutlineInputBorder(),
|
||||
labelText: FlutterI18n.translate(
|
||||
context,
|
||||
'settingsView.orgPatchesLabel',
|
||||
),
|
||||
labelText: t.settingsView.orgPatchesLabel,
|
||||
hintText: patchesRepo.split('/')[0],
|
||||
),
|
||||
),
|
||||
@@ -96,10 +90,7 @@ class SManageSources extends BaseViewModel {
|
||||
color: Colors.transparent,
|
||||
),
|
||||
border: const OutlineInputBorder(),
|
||||
labelText: FlutterI18n.translate(
|
||||
context,
|
||||
'settingsView.sourcesPatchesLabel',
|
||||
),
|
||||
labelText: t.settingsView.sourcesPatchesLabel,
|
||||
hintText: patchesRepo.split('/')[1],
|
||||
),
|
||||
),
|
||||
@@ -115,10 +106,7 @@ class SManageSources extends BaseViewModel {
|
||||
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||
),
|
||||
border: const OutlineInputBorder(),
|
||||
labelText: FlutterI18n.translate(
|
||||
context,
|
||||
'settingsView.orgIntegrationsLabel',
|
||||
),
|
||||
labelText: t.settingsView.orgIntegrationsLabel,
|
||||
hintText: integrationsRepo.split('/')[0],
|
||||
),
|
||||
),
|
||||
@@ -134,15 +122,12 @@ class SManageSources extends BaseViewModel {
|
||||
color: Colors.transparent,
|
||||
),
|
||||
border: const OutlineInputBorder(),
|
||||
labelText: FlutterI18n.translate(
|
||||
context,
|
||||
'settingsView.sourcesIntegrationsLabel',
|
||||
),
|
||||
labelText: t.settingsView.sourcesIntegrationsLabel,
|
||||
hintText: integrationsRepo.split('/')[1],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
I18nText('settingsView.sourcesUpdateNote'),
|
||||
Text(t.settingsView.sourcesUpdateNote),
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -155,7 +140,7 @@ class SManageSources extends BaseViewModel {
|
||||
_intSourceController.clear();
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
child: I18nText('cancelButton'),
|
||||
child: Text(t.cancelButton),
|
||||
),
|
||||
FilledButton(
|
||||
onPressed: () {
|
||||
@@ -168,10 +153,10 @@ class SManageSources extends BaseViewModel {
|
||||
);
|
||||
_managerAPI.setCurrentPatchesVersion('0.0.0');
|
||||
_managerAPI.setCurrentIntegrationsVersion('0.0.0');
|
||||
_toast.showBottom('settingsView.restartAppForChanges');
|
||||
_toast.showBottom(t.settingsView.restartAppForChanges);
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
child: I18nText('okButton'),
|
||||
child: Text(t.okButton),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -182,12 +167,12 @@ class SManageSources extends BaseViewModel {
|
||||
return showDialog(
|
||||
context: context,
|
||||
builder: (context) => AlertDialog(
|
||||
title: I18nText('settingsView.sourcesResetDialogTitle'),
|
||||
content: I18nText('settingsView.sourcesResetDialogText'),
|
||||
title: Text(t.settingsView.sourcesResetDialogTitle),
|
||||
content: Text(t.settingsView.sourcesResetDialogText),
|
||||
actions: <Widget>[
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
child: I18nText('noButton'),
|
||||
child: Text(t.noButton),
|
||||
),
|
||||
FilledButton(
|
||||
onPressed: () {
|
||||
@@ -196,12 +181,12 @@ class SManageSources extends BaseViewModel {
|
||||
_managerAPI.setIntegrationsRepo('');
|
||||
_managerAPI.setCurrentPatchesVersion('0.0.0');
|
||||
_managerAPI.setCurrentIntegrationsVersion('0.0.0');
|
||||
_toast.showBottom('settingsView.restartAppForChanges');
|
||||
_toast.showBottom(t.settingsView.restartAppForChanges);
|
||||
Navigator.of(context)
|
||||
..pop()
|
||||
..pop();
|
||||
},
|
||||
child: I18nText('yesButton'),
|
||||
child: Text(t.yesButton),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -218,8 +203,8 @@ class SManageSourcesUI extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
return SettingsTileDialog(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 20.0),
|
||||
title: 'settingsView.sourcesLabel',
|
||||
subtitle: 'settingsView.sourcesLabelHint',
|
||||
title: t.settingsView.sourcesLabel,
|
||||
subtitle: t.settingsView.sourcesLabelHint,
|
||||
onTap: () => sManageSources.showSourcesDialog(context),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,76 +1,101 @@
|
||||
// ignore_for_file: use_build_context_synchronously
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_i18n/flutter_i18n.dart';
|
||||
import 'package:language_code/language_code.dart';
|
||||
import 'package:revanced_manager/app/app.locator.dart';
|
||||
import 'package:revanced_manager/main.dart';
|
||||
import 'package:revanced_manager/gen/strings.g.dart';
|
||||
import 'package:revanced_manager/services/manager_api.dart';
|
||||
import 'package:revanced_manager/services/toast.dart';
|
||||
import 'package:revanced_manager/ui/views/navigation/navigation_viewmodel.dart';
|
||||
import 'package:revanced_manager/ui/views/settings/settings_viewmodel.dart';
|
||||
import 'package:revanced_manager/ui/widgets/settingsView/settings_tile_dialog.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:stacked/stacked.dart';
|
||||
import 'package:timeago/timeago.dart' as timeago;
|
||||
|
||||
final _settingViewModel = SettingsViewModel();
|
||||
|
||||
class SUpdateLanguage extends BaseViewModel {
|
||||
final Toast _toast = locator<Toast>();
|
||||
late SharedPreferences _prefs;
|
||||
String selectedLanguage = 'English';
|
||||
String selectedLanguageLocale = prefs.getString('language') ?? 'en_US';
|
||||
List languages = [];
|
||||
final ManagerAPI _managerAPI = locator<ManagerAPI>();
|
||||
|
||||
Future<void> initialize() async {
|
||||
_prefs = await SharedPreferences.getInstance();
|
||||
selectedLanguageLocale =
|
||||
_prefs.getString('language') ?? selectedLanguageLocale;
|
||||
_prefs.getString('language');
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
Future<void> updateLanguage(BuildContext context, String? value) async {
|
||||
if (value != null) {
|
||||
selectedLanguageLocale = value;
|
||||
_prefs = await SharedPreferences.getInstance();
|
||||
await _prefs.setString('language', value);
|
||||
await FlutterI18n.refresh(context, Locale(value));
|
||||
timeago.setLocaleMessages(value, timeago.EnMessages());
|
||||
locator<NavigationViewModel>().notifyListeners();
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> initLang() async {
|
||||
languages.sort((a, b) => a['name'].compareTo(b['name']));
|
||||
notifyListeners();
|
||||
Future<void> updateLocale(String locale) async {
|
||||
LocaleSettings.setLocaleRaw(locale);
|
||||
_managerAPI.setLocale(locale);
|
||||
Future.delayed(
|
||||
const Duration(milliseconds: 120),
|
||||
() => _toast.showBottom(t.settingsView.languageUpdated),
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> showLanguagesDialog(BuildContext parentContext) {
|
||||
initLang();
|
||||
final ValueNotifier<String> selectedLanguageCode =
|
||||
ValueNotifier(LocaleSettings.currentLocale.languageCode);
|
||||
// initLang();
|
||||
|
||||
// Return a dialog with list for each language supported by the application.
|
||||
// the dialog will display the english and native name of each languages,
|
||||
// the current language will be highlighted by selected radio button.
|
||||
return showDialog(
|
||||
context: parentContext,
|
||||
builder: (context) => SimpleDialog(
|
||||
title: I18nText('settingsView.languageLabel'),
|
||||
children: [
|
||||
SizedBox(
|
||||
height: 500,
|
||||
child: ListView.builder(
|
||||
itemCount: languages.length,
|
||||
itemBuilder: (context, index) {
|
||||
return RadioListTile<String>(
|
||||
title: Text(languages[index]['name']),
|
||||
subtitle: Text(languages[index]['locale']),
|
||||
value: languages[index]['locale'],
|
||||
groupValue: selectedLanguageLocale,
|
||||
onChanged: (value) {
|
||||
selectedLanguage = languages[index]['name'];
|
||||
_toast.showBottom('settingsView.restartAppForChanges');
|
||||
updateLanguage(context, value);
|
||||
Navigator.pop(context);
|
||||
builder: (context) => AlertDialog(
|
||||
title: Text(t.settingsView.languageLabel),
|
||||
icon: const Icon(Icons.language),
|
||||
backgroundColor: Theme.of(context).colorScheme.secondaryContainer,
|
||||
contentPadding: EdgeInsets.zero,
|
||||
content: ValueListenableBuilder(
|
||||
valueListenable: selectedLanguageCode,
|
||||
builder: (context, value, child) {
|
||||
return SingleChildScrollView(
|
||||
child: ListBody(
|
||||
children: AppLocale.values.map(
|
||||
(locale) {
|
||||
LanguageCodes? languageCode;
|
||||
Text? languageNativeName;
|
||||
|
||||
try {
|
||||
languageCode =
|
||||
LanguageCodes.fromCode(locale.languageCode);
|
||||
} catch (e) {}
|
||||
if (languageCode != null) {
|
||||
languageNativeName = Text(languageCode.nativeName);
|
||||
}
|
||||
|
||||
return RadioListTile(
|
||||
title: Text(
|
||||
languageCode?.englishName ?? locale.languageCode,
|
||||
),
|
||||
subtitle: languageNativeName,
|
||||
value: locale.languageCode == selectedLanguageCode.value,
|
||||
groupValue: true,
|
||||
onChanged: (value) {
|
||||
selectedLanguageCode.value = locale.languageCode;
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
).toList(),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
actions: <Widget>[
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
child: Text(t.cancelButton),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
updateLocale(selectedLanguageCode.value);
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
child: Text(t.okButton),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -85,8 +110,10 @@ class SUpdateLanguageUI extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
return SettingsTileDialog(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 20.0),
|
||||
title: 'settingsView.languageLabel',
|
||||
subtitle: _settingViewModel.sUpdateLanguage.selectedLanguage,
|
||||
title: t.settingsView.languageLabel,
|
||||
subtitle:
|
||||
LanguageCodes.fromCode(LocaleSettings.currentLocale.languageCode)
|
||||
.nativeName,
|
||||
onTap: () =>
|
||||
_settingViewModel.sUpdateLanguage.showLanguagesDialog(context),
|
||||
);
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
import 'package:dynamic_themes/dynamic_themes.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_i18n/widgets/I18nText.dart';
|
||||
import 'package:revanced_manager/app/app.locator.dart';
|
||||
import 'package:revanced_manager/gen/strings.g.dart';
|
||||
import 'package:revanced_manager/services/manager_api.dart';
|
||||
import 'package:revanced_manager/ui/widgets/settingsView/settings_section.dart';
|
||||
import 'package:revanced_manager/ui/widgets/shared/haptics/haptic_radio_list_tile.dart';
|
||||
@@ -23,18 +23,15 @@ class _SUpdateThemeUIState extends State<SUpdateThemeUI> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SettingsSection(
|
||||
title: 'settingsView.appearanceSectionTitle',
|
||||
title: t.settingsView.appearanceSectionTitle,
|
||||
children: <Widget>[
|
||||
ListTile(
|
||||
contentPadding: const EdgeInsets.symmetric(horizontal: 20.0),
|
||||
title: I18nText(
|
||||
'settingsView.themeModeLabel',
|
||||
child: const Text(
|
||||
'',
|
||||
style: TextStyle(
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
title: Text(
|
||||
t.settingsView.themeModeLabel,
|
||||
style: const TextStyle(
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
trailing: FilledButton(
|
||||
@@ -46,17 +43,14 @@ class _SUpdateThemeUIState extends State<SUpdateThemeUI> {
|
||||
if (managerAPI.isDynamicThemeAvailable)
|
||||
HapticSwitchListTile(
|
||||
contentPadding: const EdgeInsets.symmetric(horizontal: 20.0),
|
||||
title: I18nText(
|
||||
'settingsView.dynamicThemeLabel',
|
||||
child: const Text(
|
||||
'',
|
||||
style: TextStyle(
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
title: Text(
|
||||
t.settingsView.dynamicThemeLabel,
|
||||
style: const TextStyle(
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
subtitle: I18nText('settingsView.dynamicThemeHint'),
|
||||
subtitle: Text(t.settingsView.dynamicThemeHint),
|
||||
value: getDynamicThemeStatus(),
|
||||
onChanged: (value) => {
|
||||
setUseDynamicTheme(
|
||||
@@ -101,16 +95,16 @@ class _SUpdateThemeUIState extends State<SUpdateThemeUI> {
|
||||
setState(() {});
|
||||
}
|
||||
|
||||
I18nText getThemeModeName() {
|
||||
Text getThemeModeName() {
|
||||
switch (getThemeMode()) {
|
||||
case 0:
|
||||
return I18nText('settingsView.systemThemeLabel');
|
||||
return Text(t.settingsView.systemThemeLabel);
|
||||
case 1:
|
||||
return I18nText('settingsView.lightThemeLabel');
|
||||
return Text(t.settingsView.lightThemeLabel);
|
||||
case 2:
|
||||
return I18nText('settingsView.darkThemeLabel');
|
||||
return Text(t.settingsView.darkThemeLabel);
|
||||
default:
|
||||
return I18nText('settingsView.systemThemeLabel');
|
||||
return Text(t.settingsView.systemThemeLabel);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,7 +114,7 @@ class _SUpdateThemeUIState extends State<SUpdateThemeUI> {
|
||||
return showDialog(
|
||||
context: context,
|
||||
builder: (context) => AlertDialog(
|
||||
title: I18nText('settingsView.themeModeLabel'),
|
||||
title: Text(t.settingsView.themeModeLabel),
|
||||
icon: const Icon(Icons.palette),
|
||||
contentPadding: const EdgeInsets.symmetric(vertical: 16),
|
||||
content: SingleChildScrollView(
|
||||
@@ -132,7 +126,7 @@ class _SUpdateThemeUIState extends State<SUpdateThemeUI> {
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
HapticRadioListTile(
|
||||
title: I18nText('settingsView.systemThemeLabel'),
|
||||
title: Text(t.settingsView.systemThemeLabel),
|
||||
contentPadding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
value: 0,
|
||||
groupValue: value,
|
||||
@@ -141,7 +135,7 @@ class _SUpdateThemeUIState extends State<SUpdateThemeUI> {
|
||||
},
|
||||
),
|
||||
HapticRadioListTile(
|
||||
title: I18nText('settingsView.lightThemeLabel'),
|
||||
title: Text(t.settingsView.lightThemeLabel),
|
||||
contentPadding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
value: 1,
|
||||
groupValue: value,
|
||||
@@ -150,7 +144,7 @@ class _SUpdateThemeUIState extends State<SUpdateThemeUI> {
|
||||
},
|
||||
),
|
||||
HapticRadioListTile(
|
||||
title: I18nText('settingsView.darkThemeLabel'),
|
||||
title: Text(t.settingsView.darkThemeLabel),
|
||||
contentPadding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
value: 2,
|
||||
groupValue: value,
|
||||
@@ -168,14 +162,14 @@ class _SUpdateThemeUIState extends State<SUpdateThemeUI> {
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
child: I18nText('cancelButton'),
|
||||
child: Text(t.cancelButton),
|
||||
),
|
||||
FilledButton(
|
||||
onPressed: () {
|
||||
setThemeMode(context, newTheme.value);
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
child: I18nText('okButton'),
|
||||
child: Text(t.okButton),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
// ignore_for_file: prefer_const_constructors
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_i18n/flutter_i18n.dart';
|
||||
import 'package:google_fonts/google_fonts.dart';
|
||||
import 'package:revanced_manager/gen/strings.g.dart';
|
||||
import 'package:revanced_manager/ui/views/settings/settingsFragment/settings_update_language.dart';
|
||||
import 'package:revanced_manager/ui/views/settings/settingsFragment/settings_update_theme.dart';
|
||||
import 'package:revanced_manager/ui/views/settings/settings_viewmodel.dart';
|
||||
import 'package:revanced_manager/ui/widgets/settingsView/settings_advanced_section.dart';
|
||||
@@ -27,13 +28,10 @@ class SettingsView extends StatelessWidget {
|
||||
slivers: <Widget>[
|
||||
CustomSliverAppBar(
|
||||
isMainView: true,
|
||||
title: I18nText(
|
||||
'settingsView.widgetTitle',
|
||||
child: Text(
|
||||
'',
|
||||
style: GoogleFonts.inter(
|
||||
color: Theme.of(context).textTheme.titleLarge!.color,
|
||||
),
|
||||
title: Text(
|
||||
t.settingsView.widgetTitle,
|
||||
style: GoogleFonts.inter(
|
||||
color: Theme.of(context).textTheme.titleLarge!.color,
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -47,7 +45,7 @@ class SettingsView extends StatelessWidget {
|
||||
children: const [
|
||||
SUpdateThemeUI(),
|
||||
// _settingsDivider,
|
||||
// SUpdateLanguageUI(),
|
||||
SUpdateLanguageUI(),
|
||||
_settingsDivider,
|
||||
SAdvancedSection(),
|
||||
_settingsDivider,
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_file_dialog/flutter_file_dialog.dart';
|
||||
import 'package:flutter_i18n/flutter_i18n.dart';
|
||||
import 'package:logcat/logcat.dart';
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
import 'package:revanced_manager/app/app.locator.dart';
|
||||
import 'package:revanced_manager/app/app.router.dart';
|
||||
import 'package:revanced_manager/gen/strings.g.dart';
|
||||
import 'package:revanced_manager/services/manager_api.dart';
|
||||
import 'package:revanced_manager/services/toast.dart';
|
||||
import 'package:revanced_manager/ui/views/patcher/patcher_viewmodel.dart';
|
||||
@@ -60,15 +61,12 @@ class SettingsViewModel extends BaseViewModel {
|
||||
return showDialog(
|
||||
context: context,
|
||||
builder: (context) => AlertDialog(
|
||||
title: I18nText('warning'),
|
||||
content: I18nText(
|
||||
'settingsView.enablePatchesSelectionWarningText',
|
||||
child: const Text(
|
||||
'',
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
title: Text(t.warning),
|
||||
content: Text(
|
||||
t.settingsView.enablePatchesSelectionWarningText,
|
||||
style: const TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
actions: [
|
||||
@@ -78,13 +76,13 @@ class SettingsViewModel extends BaseViewModel {
|
||||
_managerAPI.setPatchesChangeEnabled(true);
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
child: I18nText('yesButton'),
|
||||
child: Text(t.yesButton),
|
||||
),
|
||||
FilledButton(
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
child: I18nText('noButton'),
|
||||
child: Text(t.noButton),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -93,15 +91,12 @@ class SettingsViewModel extends BaseViewModel {
|
||||
return showDialog(
|
||||
context: context,
|
||||
builder: (context) => AlertDialog(
|
||||
title: I18nText('warning'),
|
||||
content: I18nText(
|
||||
'settingsView.disablePatchesSelectionWarningText',
|
||||
child: const Text(
|
||||
'',
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
title: Text(t.warning),
|
||||
content: Text(
|
||||
t.settingsView.disablePatchesSelectionWarningText,
|
||||
style: const TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
actions: [
|
||||
@@ -109,7 +104,7 @@ class SettingsViewModel extends BaseViewModel {
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
child: I18nText('noButton'),
|
||||
child: Text(t.noButton),
|
||||
),
|
||||
FilledButton(
|
||||
onPressed: () {
|
||||
@@ -118,7 +113,7 @@ class SettingsViewModel extends BaseViewModel {
|
||||
_managerAPI.setPatchesChangeEnabled(false);
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
child: I18nText('yesButton'),
|
||||
child: Text(t.yesButton),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -156,15 +151,12 @@ class SettingsViewModel extends BaseViewModel {
|
||||
return showDialog(
|
||||
context: context,
|
||||
builder: (context) => AlertDialog(
|
||||
title: I18nText('warning'),
|
||||
content: I18nText(
|
||||
'settingsView.requireSuggestedAppVersionDialogText',
|
||||
child: const Text(
|
||||
'',
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
title: Text(t.warning),
|
||||
content: Text(
|
||||
t.settingsView.requireSuggestedAppVersionDialogText,
|
||||
style: const TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
actions: [
|
||||
@@ -173,13 +165,13 @@ class SettingsViewModel extends BaseViewModel {
|
||||
_managerAPI.enableRequireSuggestedAppVersionStatus(false);
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
child: I18nText('yesButton'),
|
||||
child: Text(t.yesButton),
|
||||
),
|
||||
FilledButton(
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
child: I18nText('noButton'),
|
||||
child: Text(t.noButton),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -197,13 +189,13 @@ class SettingsViewModel extends BaseViewModel {
|
||||
|
||||
void deleteKeystore() {
|
||||
_managerAPI.deleteKeystore();
|
||||
_toast.showBottom('settingsView.regeneratedKeystore');
|
||||
_toast.showBottom(t.settingsView.regeneratedKeystore);
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void deleteTempDir() {
|
||||
_managerAPI.deleteTempFolder();
|
||||
_toast.showBottom('settingsView.deletedTempDir');
|
||||
_toast.showBottom(t.settingsView.deletedTempDir);
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
@@ -219,9 +211,9 @@ class SettingsViewModel extends BaseViewModel {
|
||||
fileName: 'selected_patches_$dateTime.json',
|
||||
),
|
||||
);
|
||||
_toast.showBottom('settingsView.exportedPatches');
|
||||
_toast.showBottom(t.settingsView.exportedPatches);
|
||||
} else {
|
||||
_toast.showBottom('settingsView.noExportFileFound');
|
||||
_toast.showBottom(t.settingsView.noExportFileFound);
|
||||
}
|
||||
} on Exception catch (e) {
|
||||
if (kDebugMode) {
|
||||
@@ -245,13 +237,13 @@ class SettingsViewModel extends BaseViewModel {
|
||||
if (_patcherViewModel.selectedApp != null) {
|
||||
_patcherViewModel.loadLastSelectedPatches();
|
||||
}
|
||||
_toast.showBottom('settingsView.importedPatches');
|
||||
_toast.showBottom(t.settingsView.importedPatches);
|
||||
}
|
||||
} on Exception catch (e) {
|
||||
if (kDebugMode) {
|
||||
print(e);
|
||||
}
|
||||
_toast.showBottom('settingsView.jsonSelectorErrorMessage');
|
||||
_toast.showBottom(t.settingsView.jsonSelectorErrorMessage);
|
||||
}
|
||||
} else {
|
||||
_managerAPI.showPatchesChangeWarningDialog(context);
|
||||
@@ -270,9 +262,9 @@ class SettingsViewModel extends BaseViewModel {
|
||||
fileName: 'keystore_$dateTime.keystore',
|
||||
),
|
||||
);
|
||||
_toast.showBottom('settingsView.exportedKeystore');
|
||||
_toast.showBottom(t.settingsView.exportedKeystore);
|
||||
} else {
|
||||
_toast.showBottom('settingsView.noKeystoreExportFileFound');
|
||||
_toast.showBottom(t.settingsView.noKeystoreExportFileFound);
|
||||
}
|
||||
} on Exception catch (e) {
|
||||
if (kDebugMode) {
|
||||
@@ -288,24 +280,24 @@ class SettingsViewModel extends BaseViewModel {
|
||||
final File inFile = File(result);
|
||||
inFile.copySync(_managerAPI.keystoreFile);
|
||||
|
||||
_toast.showBottom('settingsView.importedKeystore');
|
||||
_toast.showBottom(t.settingsView.importedKeystore);
|
||||
}
|
||||
} on Exception catch (e) {
|
||||
if (kDebugMode) {
|
||||
print(e);
|
||||
}
|
||||
_toast.showBottom('settingsView.keystoreSelectorErrorMessage');
|
||||
_toast.showBottom(t.settingsView.keystoreSelectorErrorMessage);
|
||||
}
|
||||
}
|
||||
|
||||
void resetAllOptions() {
|
||||
_managerAPI.resetAllOptions();
|
||||
_toast.showBottom('settingsView.resetStoredOptions');
|
||||
_toast.showBottom(t.settingsView.resetStoredOptions);
|
||||
}
|
||||
|
||||
void resetSelectedPatches() {
|
||||
_managerAPI.resetLastSelectedPatches();
|
||||
_toast.showBottom('settingsView.resetStoredPatches');
|
||||
_toast.showBottom(t.settingsView.resetStoredPatches);
|
||||
}
|
||||
|
||||
Future<void> deleteLogs() async {
|
||||
@@ -314,7 +306,7 @@ class SettingsViewModel extends BaseViewModel {
|
||||
if (logsDir.existsSync()) {
|
||||
logsDir.deleteSync(recursive: true);
|
||||
}
|
||||
_toast.showBottom('settingsView.deletedLogs');
|
||||
_toast.showBottom(t.settingsView.deletedLogs);
|
||||
}
|
||||
|
||||
Future<void> exportLogcatLogs() async {
|
||||
|
||||
Reference in New Issue
Block a user