Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(installer): redesign utility options #1062

Merged
merged 8 commits into from
Aug 10, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions assets/i18n/en_US.json
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,8 @@
"notificationTitle": "ReVanced Manager is patching",
"notificationText": "Tap to return to the installer",

"shareApkMenuOption": "Share APK",
"exportApkMenuOption": "Export APK",
"shareLogMenuOption": "Share log",
"saveApkButtonTooltip": "Save APK",
"shareLogButtonTooltip": "Share log",

"installErrorDialogTitle": "Error",
"installErrorDialogText1": "Root install is not possible with the current patches selection.\nRepatch your app or choose non-root install.",
Expand Down
72 changes: 30 additions & 42 deletions lib/ui/views/installer/installer_view.dart
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import 'package:flutter/material.dart';
import 'package:flutter_i18n/flutter_i18n.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:google_fonts/google_fonts.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';
import 'package:revanced_manager/ui/widgets/shared/custom_material_button.dart';
import 'package:revanced_manager/ui/widgets/shared/custom_popup_menu.dart';
import 'package:revanced_manager/ui/widgets/shared/custom_sliver_app_bar.dart';
import 'package:stacked/stacked.dart';

Expand Down Expand Up @@ -33,44 +33,6 @@ class InstallerView extends StatelessWidget {
),
),
onBackButtonPressed: () => model.onWillPop(context),
actions: <Widget>[
Visibility(
visible: !model.isPatching,
child: CustomPopupMenu(
onSelected: (value) => model.onMenuSelection(value),
children: {
if (!model.hasErrors)
0: I18nText(
'installerView.shareApkMenuOption',
child: const Text(
'',
style: TextStyle(
fontWeight: FontWeight.bold,
),
),
),
1: I18nText(
'installerView.exportApkMenuOption',
child: const Text(
'',
style: TextStyle(
fontWeight: FontWeight.bold,
),
),
),
2: I18nText(
'installerView.shareLogMenuOption',
child: const Text(
'',
style: TextStyle(
fontWeight: FontWeight.bold,
),
),
),
},
),
),
],
bottom: PreferredSize(
preferredSize: const Size(double.infinity, 1.0),
child: GradientProgressIndicator(progress: model.progress),
Expand Down Expand Up @@ -106,6 +68,31 @@ class InstallerView extends StatelessWidget {
mainAxisAlignment: MainAxisAlignment.end,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Visibility(
visible: !model.isPatching && !model.hasErrors,
child: IconButton(
tooltip: FlutterI18n.translate(
context,
'installerView.saveApkButtonTooltip',
),
icon: const Icon(Icons.save),
onPressed: () => model.onButtonPressed(0),
),
),
Visibility(
visible: !model.isPatching && !model.hasErrors,
child: IconButton(
tooltip: FlutterI18n.translate(
context,
'installerView.shareLogButtonTooltip',
),
icon: const Icon(
FontAwesomeIcons.solidFileLines,
),
iconSize: 20,
onPressed: () => model.onButtonPressed(1),
),
),
Visibility(
visible: model.isInstalled,
child: CustomMaterialButton(
Expand All @@ -122,8 +109,9 @@ class InstallerView extends StatelessWidget {
visible: !model.isInstalled && model.isRooted,
child: CustomMaterialButton(
isFilled: false,
label:
I18nText('installerView.installRootButton'),
label: I18nText(
'installerView.installRootButton',
),
isExpanded: true,
onPressed: () => model.installResult(
context,
Expand All @@ -134,7 +122,7 @@ class InstallerView extends StatelessWidget {
Visibility(
visible: !model.isInstalled,
child: const SizedBox(
width: 16,
width: 8,
),
),
Visibility(
Expand Down
19 changes: 3 additions & 16 deletions lib/ui/views/installer/installer_viewmodel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ class InstallerViewModel extends BaseViewModel {
CustomMaterialButton(
label: I18nText('okButton'),
onPressed: () => Navigator.of(context).pop(),
)
),
],
),
);
Expand Down Expand Up @@ -233,16 +233,6 @@ class InstallerViewModel extends BaseViewModel {
}
}

void shareResult() {
try {
_patcherAPI.sharePatchedFile(_app.name, _app.version);
} on Exception catch (e) {
if (kDebugMode) {
print(e);
}
}
}

void shareLog() {
_patcherAPI.sharePatcherLog(logs);
}
Expand All @@ -264,17 +254,14 @@ class InstallerViewModel extends BaseViewModel {
DeviceApps.openApp(_app.packageName);
}

void onMenuSelection(int value) {
void onButtonPressed(int value) {
switch (value) {
case 0:
shareResult();
exportResult();
break;
case 1:
exportResult();
break;
case 2:
shareLog();
validcube marked this conversation as resolved.
Show resolved Hide resolved
break;
}
}

Expand Down