From 2eaab01ad3ff4ca488093cb171794e55583f89a9 Mon Sep 17 00:00:00 2001 From: Eray Erdin Date: Fri, 12 Jan 2024 01:08:58 +0300 Subject: [PATCH 1/7] add InstallerViewModel.isInstalling property --- lib/ui/views/installer/installer_viewmodel.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/ui/views/installer/installer_viewmodel.dart b/lib/ui/views/installer/installer_viewmodel.dart index 8919d06254..54f367accc 100644 --- a/lib/ui/views/installer/installer_viewmodel.dart +++ b/lib/ui/views/installer/installer_viewmodel.dart @@ -37,6 +37,7 @@ class InstallerViewModel extends BaseViewModel { String headerLogs = ''; bool isRooted = false; bool isPatching = true; + bool isInstalling = false; bool isInstalled = false; bool hasErrors = false; bool isCanceled = false; From 2152bebe89600b5a2d2c23129f4d576f044e23d8 Mon Sep 17 00:00:00 2001 From: Eray Erdin Date: Fri, 12 Jan 2024 01:10:06 +0300 Subject: [PATCH 2/7] set isInstalling prop in installResult method --- lib/ui/views/installer/installer_viewmodel.dart | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/ui/views/installer/installer_viewmodel.dart b/lib/ui/views/installer/installer_viewmodel.dart index 54f367accc..485fdce6f6 100644 --- a/lib/ui/views/installer/installer_viewmodel.dart +++ b/lib/ui/views/installer/installer_viewmodel.dart @@ -455,6 +455,7 @@ class InstallerViewModel extends BaseViewModel { Future installResult(BuildContext context, bool installAsRoot) async { try { + isInstalling = true; _app.isRooted = installAsRoot; if (headerLogs != 'Installing...') { update( @@ -498,7 +499,9 @@ class InstallerViewModel extends BaseViewModel { 'Installation failed', ); } + isInstalling = false; } on Exception catch (e) { + isInstalling = false; if (kDebugMode) { print(e); } From ed2d5b00a89c2af665a3b6df1b8cb0609a2737dc Mon Sep 17 00:00:00 2001 From: Eray Erdin Date: Fri, 12 Jan 2024 01:28:44 +0300 Subject: [PATCH 3/7] separate FloatingActionButton by model.isInstalled --- lib/ui/views/installer/installer_view.dart | 36 +++++++++++----------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/lib/ui/views/installer/installer_view.dart b/lib/ui/views/installer/installer_view.dart index d1626ed5ab..58e234ccf6 100644 --- a/lib/ui/views/installer/installer_view.dart +++ b/lib/ui/views/installer/installer_view.dart @@ -22,24 +22,24 @@ class InstallerView extends StatelessWidget { child: Scaffold( floatingActionButton: Visibility( visible: !model.isPatching && !model.hasErrors, - child: FloatingActionButton.extended( - label: I18nText( - model.isInstalled - ? 'installerView.openButton' - : 'installerView.installButton', - ), - icon: model.isInstalled - ? const Icon(Icons.open_in_new) - : const Icon(Icons.file_download_outlined), - onPressed: model.isInstalled - ? () => { - model.openApp(), - model.cleanPatcher(), - Navigator.of(context).pop(), - } - : () => model.installTypeDialog(context), - elevation: 0, - ), + child: model.isInstalled + ? FloatingActionButton.extended( + label: I18nText('installerView.openButton'), + icon: const Icon(Icons.open_in_new), + onPressed: () { + model + ..openApp() + ..cleanPatcher(); + Navigator.of(context).pop(); + }, + elevation: 0, + ) + : FloatingActionButton.extended( + label: I18nText('installerView.installButton'), + icon: const Icon(Icons.file_download_outlined), + onPressed: () => model.installTypeDialog(context), + elevation: 0, + ), ), floatingActionButtonLocation: FloatingActionButtonLocation.endContained, From ad86a5daca42505cae0a936aa0669c8b1f749cae Mon Sep 17 00:00:00 2001 From: Eray Erdin Date: Fri, 12 Jan 2024 13:13:35 +0300 Subject: [PATCH 4/7] set isInstalling in installResult --- lib/ui/views/installer/installer_viewmodel.dart | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/ui/views/installer/installer_viewmodel.dart b/lib/ui/views/installer/installer_viewmodel.dart index 485fdce6f6..306f3b086e 100644 --- a/lib/ui/views/installer/installer_viewmodel.dart +++ b/lib/ui/views/installer/installer_viewmodel.dart @@ -454,8 +454,8 @@ class InstallerViewModel extends BaseViewModel { } Future installResult(BuildContext context, bool installAsRoot) async { + isInstalling = true; try { - isInstalling = true; _app.isRooted = installAsRoot; if (headerLogs != 'Installing...') { update( @@ -505,7 +505,10 @@ class InstallerViewModel extends BaseViewModel { if (kDebugMode) { print(e); } + } finally { + isInstalling = false; } + isInstalling = false; } void exportResult() { From 0940d5c0a9c45e9d52d4221718dbed0ef620de29 Mon Sep 17 00:00:00 2001 From: Eray Erdin Date: Fri, 12 Jan 2024 13:14:12 +0300 Subject: [PATCH 5/7] disable install button while installing --- lib/ui/views/installer/installer_view.dart | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/ui/views/installer/installer_view.dart b/lib/ui/views/installer/installer_view.dart index 58e234ccf6..a843f8eec6 100644 --- a/lib/ui/views/installer/installer_view.dart +++ b/lib/ui/views/installer/installer_view.dart @@ -37,7 +37,9 @@ class InstallerView extends StatelessWidget { : FloatingActionButton.extended( label: I18nText('installerView.installButton'), icon: const Icon(Icons.file_download_outlined), - onPressed: () => model.installTypeDialog(context), + onPressed: model.isInstalling + ? null + : () => model.installTypeDialog(context), elevation: 0, ), ), From f74d88e0f60b06b0f41f8741f1514a1d5ee43642 Mon Sep 17 00:00:00 2001 From: Eray Erdin Date: Mon, 5 Feb 2024 14:29:34 +0300 Subject: [PATCH 6/7] hide floating action button while installing --- lib/ui/views/installer/installer_view.dart | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/ui/views/installer/installer_view.dart b/lib/ui/views/installer/installer_view.dart index 8de65f3d0d..c9920c7025 100644 --- a/lib/ui/views/installer/installer_view.dart +++ b/lib/ui/views/installer/installer_view.dart @@ -22,7 +22,11 @@ class InstallerView extends StatelessWidget { bottom: model.isPatching, child: Scaffold( floatingActionButton: Visibility( - visible: !model.isPatching && !model.hasErrors, + visible: [ + !model.isPatching, + !model.hasErrors, + !model.isInstalling, + ].every((element) => element), child: model.isInstalled ? HapticFloatingActionButtonExtended( label: I18nText('installerView.openButton'), From ffbdafaf71968c8aebd44f8d109e00e9e82d6a3e Mon Sep 17 00:00:00 2001 From: Ushie Date: Sun, 25 Feb 2024 23:46:16 +0300 Subject: [PATCH 7/7] refactor: Minor cleanup --- lib/ui/views/installer/installer_view.dart | 45 +++++++++---------- .../views/installer/installer_viewmodel.dart | 4 -- 2 files changed, 20 insertions(+), 29 deletions(-) diff --git a/lib/ui/views/installer/installer_view.dart b/lib/ui/views/installer/installer_view.dart index c9920c7025..7ab9d58969 100644 --- a/lib/ui/views/installer/installer_view.dart +++ b/lib/ui/views/installer/installer_view.dart @@ -22,31 +22,26 @@ class InstallerView extends StatelessWidget { bottom: model.isPatching, child: Scaffold( floatingActionButton: Visibility( - visible: [ - !model.isPatching, - !model.hasErrors, - !model.isInstalling, - ].every((element) => element), - child: model.isInstalled - ? HapticFloatingActionButtonExtended( - label: I18nText('installerView.openButton'), - icon: const Icon(Icons.open_in_new), - onPressed: () { - model - ..openApp() - ..cleanPatcher(); - Navigator.of(context).pop(); - }, - elevation: 0, - ) - : HapticFloatingActionButtonExtended( - label: I18nText('installerView.installButton'), - icon: const Icon(Icons.file_download_outlined), - onPressed: model.isInstalling - ? null - : () => model.installTypeDialog(context), - elevation: 0, - ), + visible: + !model.isPatching && !model.hasErrors && !model.isInstalling, + child: HapticFloatingActionButtonExtended( + label: I18nText( + model.isInstalled + ? 'installerView.openButton' + : 'installerView.installButton', + ), + icon: model.isInstalled + ? const Icon(Icons.open_in_new) + : const Icon(Icons.file_download_outlined), + onPressed: model.isInstalled + ? () => { + model.openApp(), + model.cleanPatcher(), + Navigator.of(context).pop(), + } + : () => model.installTypeDialog(context), + elevation: 0, + ), ), floatingActionButtonLocation: FloatingActionButtonLocation.endContained, diff --git a/lib/ui/views/installer/installer_viewmodel.dart b/lib/ui/views/installer/installer_viewmodel.dart index 306f3b086e..c295718226 100644 --- a/lib/ui/views/installer/installer_viewmodel.dart +++ b/lib/ui/views/installer/installer_viewmodel.dart @@ -499,14 +499,10 @@ class InstallerViewModel extends BaseViewModel { 'Installation failed', ); } - isInstalling = false; } on Exception catch (e) { - isInstalling = false; if (kDebugMode) { print(e); } - } finally { - isInstalling = false; } isInstalling = false; }