fix: Only show share and install options if patching was successful

This commit is contained in:
Alberto Ponces
2022-09-12 14:20:25 +01:00
parent a3c14e0a51
commit 3bb5e70d1c
10 changed files with 23 additions and 21 deletions

View File

@ -166,7 +166,7 @@ class HomeViewModel extends BaseViewModel {
title: I18nText('homeView.updateDialogTitle'),
backgroundColor: Theme.of(context).colorScheme.secondaryContainer,
content: I18nText('homeView.updateDialogText'),
actions: [
actions: <Widget>[
CustomMaterialButton(
isFilled: false,
label: I18nText('cancelButton'),

View File

@ -30,7 +30,7 @@ class InstallerView extends StatelessWidget {
),
actions: <Widget>[
Visibility(
visible: !model.isPatching,
visible: !model.isPatching && model.hasErrors,
child: CustomPopupMenu(
onSelected: (value) => model.onMenuSelection(value),
children: {
@ -89,7 +89,7 @@ class InstallerView extends StatelessWidget {
child: Align(
alignment: Alignment.bottomCenter,
child: Visibility(
visible: !model.isPatching,
visible: !model.isPatching && !model.hasErrors,
child: Padding(
padding: const EdgeInsets.all(20.0).copyWith(top: 0.0),
child: Row(

View File

@ -26,6 +26,7 @@ class InstallerViewModel extends BaseViewModel {
String headerLogs = '';
bool isPatching = true;
bool isInstalled = false;
bool hasErrors = false;
Future<void> initialize(BuildContext context) async {
try {
@ -79,6 +80,7 @@ class InstallerViewModel extends BaseViewModel {
if (progress == 0.0) {
logs = '';
isInstalled = false;
hasErrors = false;
}
if (header.isNotEmpty) {
headerLogs = header;
@ -115,9 +117,11 @@ class InstallerViewModel extends BaseViewModel {
update(0.0, '', 'Creating working directory');
await _patcherAPI.runPatcher(_app.packageName, apkFilePath, _patches);
} on Exception {
hasErrors = true;
update(1.0, 'Aborting...', 'An error occurred! Aborting');
}
} else {
hasErrors = true;
update(1.0, 'Aborting...', 'No app or patches selected! Aborting');
}
try {
@ -144,8 +148,6 @@ class InstallerViewModel extends BaseViewModel {
_app.patchDate = DateTime.now();
_app.appliedPatches = _patches.map((p) => p.name).toList();
await _managerAPI.savePatchedApp(_app);
} else {
update(1.0, 'Aborting...', 'An error occurred! Aborting');
}
}

View File

@ -88,7 +88,7 @@ class _PatchesSelectorViewState extends State<PatchesSelectorView> {
tapHeaderToExpand: true,
),
header: Column(
children: [
children: <Widget>[
GestureDetector(
onLongPress: () =>
expController.toggle(),
@ -138,7 +138,7 @@ class _PatchesSelectorViewState extends State<PatchesSelectorView> {
BorderRadius.circular(12),
),
child: Column(
children: [
children: <Widget>[
Text(
"Patch options",
style: GoogleFonts.inter(

View File

@ -100,7 +100,7 @@ class SettingsViewModel extends BaseViewModel {
context: context,
builder: (context) => AlertDialog(
title: Row(
children: [
children: <Widget>[
I18nText('settingsView.sourcesLabel'),
const Spacer(),
IconButton(
@ -160,7 +160,7 @@ class SettingsViewModel extends BaseViewModel {
],
),
),
actions: [
actions: <Widget>[
CustomMaterialButton(
isFilled: false,
label: I18nText('cancelButton'),
@ -196,7 +196,7 @@ class SettingsViewModel extends BaseViewModel {
title: I18nText('settingsView.sourcesResetDialogTitle'),
backgroundColor: Theme.of(context).colorScheme.secondaryContainer,
content: I18nText('settingsView.sourcesResetDialogText'),
actions: [
actions: <Widget>[
CustomMaterialButton(
isFilled: false,
label: I18nText('cancelButton'),