mirror of
https://github.com/revanced/revanced-manager.git
synced 2025-06-12 20:57:36 +02:00
feat: Allow changing languages (#1488)
Co-authored-by: validcube <pun.butrach@gmail.com>
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
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/installer/installer_viewmodel.dart';
|
||||
import 'package:revanced_manager/ui/widgets/installerView/gradient_progress_indicator.dart';
|
||||
import 'package:revanced_manager/ui/widgets/shared/custom_card.dart';
|
||||
@ -26,10 +26,10 @@ class InstallerView extends StatelessWidget {
|
||||
floatingActionButton: Visibility(
|
||||
visible: !model.isPatching && !model.hasErrors,
|
||||
child: HapticFloatingActionButtonExtended(
|
||||
label: I18nText(
|
||||
label: Text(
|
||||
model.isInstalled
|
||||
? 'installerView.openButton'
|
||||
: 'installerView.installButton',
|
||||
? t.installerView.openButton
|
||||
: t.installerView.installButton,
|
||||
),
|
||||
icon: model.isInstalled
|
||||
? const Icon(Icons.open_in_new)
|
||||
@ -54,19 +54,13 @@ class InstallerView extends StatelessWidget {
|
||||
Visibility(
|
||||
visible: !model.hasErrors,
|
||||
child: IconButton.filledTonal(
|
||||
tooltip: FlutterI18n.translate(
|
||||
context,
|
||||
'installerView.exportApkButtonTooltip',
|
||||
),
|
||||
tooltip: t.installerView.exportApkButtonTooltip,
|
||||
icon: const Icon(Icons.save),
|
||||
onPressed: () => model.onButtonPressed(0),
|
||||
),
|
||||
),
|
||||
IconButton.filledTonal(
|
||||
tooltip: FlutterI18n.translate(
|
||||
context,
|
||||
'installerView.exportLogButtonTooltip',
|
||||
),
|
||||
tooltip: t.installerView.exportLogButtonTooltip,
|
||||
icon: const Icon(Icons.post_add),
|
||||
onPressed: () => model.onButtonPressed(1),
|
||||
),
|
||||
|
@ -4,9 +4,9 @@ import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_background/flutter_background.dart';
|
||||
import 'package:flutter_i18n/flutter_i18n.dart';
|
||||
import 'package:permission_handler/permission_handler.dart';
|
||||
import 'package:revanced_manager/app/app.locator.dart';
|
||||
import 'package:revanced_manager/gen/strings.g.dart';
|
||||
import 'package:revanced_manager/models/patch.dart';
|
||||
import 'package:revanced_manager/models/patched_application.dart';
|
||||
import 'package:revanced_manager/services/manager_api.dart';
|
||||
@ -49,14 +49,8 @@ class InstallerViewModel extends BaseViewModel {
|
||||
try {
|
||||
FlutterBackground.initialize(
|
||||
androidConfig: FlutterBackgroundAndroidConfig(
|
||||
notificationTitle: FlutterI18n.translate(
|
||||
context,
|
||||
'installerView.notificationTitle',
|
||||
),
|
||||
notificationText: FlutterI18n.translate(
|
||||
context,
|
||||
'installerView.notificationText',
|
||||
),
|
||||
notificationTitle: t.installerView.notificationTitle,
|
||||
notificationText: t.installerView.notificationText,
|
||||
notificationIcon: const AndroidResource(
|
||||
name: 'ic_notification',
|
||||
),
|
||||
@ -280,26 +274,26 @@ class InstallerViewModel extends BaseViewModel {
|
||||
];
|
||||
|
||||
Clipboard.setData(ClipboardData(text: formattedLogs.join('\n')));
|
||||
_toast.showBottom('installerView.copiedToClipboard');
|
||||
_toast.showBottom(t.installerView.copiedToClipboard);
|
||||
}
|
||||
|
||||
Future<void> screenshotDetected(BuildContext context) async {
|
||||
await showDialog(
|
||||
context: context,
|
||||
builder: (context) => AlertDialog(
|
||||
title: I18nText(
|
||||
'warning',
|
||||
title: Text(
|
||||
t.warning,
|
||||
),
|
||||
icon: const Icon(Icons.warning),
|
||||
content: SingleChildScrollView(
|
||||
child: I18nText('installerView.screenshotDetected'),
|
||||
child: Text(t.installerView.screenshotDetected),
|
||||
),
|
||||
actions: <Widget>[
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
child: I18nText('noButton'),
|
||||
child: Text(t.noButton),
|
||||
),
|
||||
FilledButton(
|
||||
onPressed: () {
|
||||
@ -307,7 +301,7 @@ class InstallerViewModel extends BaseViewModel {
|
||||
showPopupScreenshotWarning = true;
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
child: I18nText('yesButton'),
|
||||
child: Text(t.yesButton),
|
||||
),
|
||||
],
|
||||
),
|
||||
@ -321,8 +315,8 @@ class InstallerViewModel extends BaseViewModel {
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
builder: (innerContext) => AlertDialog(
|
||||
title: I18nText(
|
||||
'installerView.installType',
|
||||
title: Text(
|
||||
t.installerView.installType,
|
||||
),
|
||||
icon: const Icon(Icons.file_download_outlined),
|
||||
contentPadding: const EdgeInsets.symmetric(vertical: 16),
|
||||
@ -339,20 +333,17 @@ class InstallerViewModel extends BaseViewModel {
|
||||
horizontal: 20,
|
||||
vertical: 10,
|
||||
),
|
||||
child: I18nText(
|
||||
'installerView.installTypeDescription',
|
||||
child: Text(
|
||||
'',
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: Theme.of(context).colorScheme.secondary,
|
||||
),
|
||||
child: Text(
|
||||
t.installerView.installTypeDescription,
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: Theme.of(context).colorScheme.secondary,
|
||||
),
|
||||
),
|
||||
),
|
||||
RadioListTile(
|
||||
title: I18nText('installerView.installNonRootType'),
|
||||
title: Text(t.installerView.installNonRootType),
|
||||
contentPadding:
|
||||
const EdgeInsets.symmetric(horizontal: 16),
|
||||
value: 0,
|
||||
@ -362,7 +353,7 @@ class InstallerViewModel extends BaseViewModel {
|
||||
},
|
||||
),
|
||||
RadioListTile(
|
||||
title: I18nText('installerView.installRootType'),
|
||||
title: Text(t.installerView.installRootType),
|
||||
contentPadding:
|
||||
const EdgeInsets.symmetric(horizontal: 16),
|
||||
value: 1,
|
||||
@ -373,14 +364,11 @@ class InstallerViewModel extends BaseViewModel {
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
child: I18nText(
|
||||
'installerView.warning',
|
||||
child: Text(
|
||||
'',
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w500,
|
||||
color: Theme.of(context).colorScheme.error,
|
||||
),
|
||||
child: Text(
|
||||
t.installerView.warning,
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w500,
|
||||
color: Theme.of(context).colorScheme.error,
|
||||
),
|
||||
),
|
||||
),
|
||||
@ -394,14 +382,14 @@ class InstallerViewModel extends BaseViewModel {
|
||||
onPressed: () {
|
||||
Navigator.of(innerContext).pop();
|
||||
},
|
||||
child: I18nText('cancelButton'),
|
||||
child: Text(t.cancelButton),
|
||||
),
|
||||
FilledButton(
|
||||
onPressed: () {
|
||||
Navigator.of(innerContext).pop();
|
||||
installResult(context, installType.value == 1);
|
||||
},
|
||||
child: I18nText('installerView.installButton'),
|
||||
child: Text(t.installerView.installButton),
|
||||
),
|
||||
],
|
||||
),
|
||||
@ -411,24 +399,22 @@ class InstallerViewModel extends BaseViewModel {
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
builder: (innerContext) => AlertDialog(
|
||||
title: I18nText(
|
||||
'warning',
|
||||
),
|
||||
title: Text(t.warning),
|
||||
contentPadding: const EdgeInsets.all(16),
|
||||
content: I18nText('installerView.warning'),
|
||||
content: Text(t.installerView.warning),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Navigator.of(innerContext).pop();
|
||||
},
|
||||
child: I18nText('cancelButton'),
|
||||
child: Text(t.cancelButton),
|
||||
),
|
||||
FilledButton(
|
||||
onPressed: () {
|
||||
Navigator.of(innerContext).pop();
|
||||
installResult(context, false);
|
||||
},
|
||||
child: I18nText('installerView.installButton'),
|
||||
child: Text(t.installerView.installButton),
|
||||
),
|
||||
],
|
||||
),
|
||||
@ -544,11 +530,11 @@ class InstallerViewModel extends BaseViewModel {
|
||||
if (isPatching) {
|
||||
if (!cancel) {
|
||||
cancel = true;
|
||||
_toast.showBottom('installerView.pressBackAgain');
|
||||
_toast.showBottom(t.installerView.pressBackAgain);
|
||||
} else if (!isCanceled) {
|
||||
await stopPatcher();
|
||||
} else {
|
||||
_toast.showBottom('installerView.noExit');
|
||||
_toast.showBottom(t.installerView.noExit);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
Reference in New Issue
Block a user