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: Hide the Install button during installation #1633

Merged
merged 10 commits into from
Feb 25, 2024
38 changes: 20 additions & 18 deletions lib/ui/views/installer/installer_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,24 +23,26 @@ class InstallerView extends StatelessWidget {
child: Scaffold(
floatingActionButton: Visibility(
visible: !model.isPatching && !model.hasErrors,
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,
),
child: model.isInstalled
? HapticFloatingActionButtonExtended(
validcube marked this conversation as resolved.
Show resolved Hide resolved
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
Copy link
Contributor Author

@erayerdin erayerdin Jan 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's been a while since I didn't write anything in Flutter (3 months or sth). AFAIK, passing null to onPressed should also grey-out its styling, but this does not, for some reason (new Metarial 3 thing I suppose).

It behaves correctly, tho.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FABs can't be disabled

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Ushie I can apply a custom disabled styling or hide FAB altogether. Would you like me to? :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, sorry for the late reply

By material design guidelines, FABs can be hidden but not disabled, so it'd certainly be better to go with hiding it

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the feedback. Will apply the patch as soon as I'm available. :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Applied the patch.

: () => model.installTypeDialog(context),
elevation: 0,
),
),
floatingActionButtonLocation:
FloatingActionButtonLocation.endContained,
Expand Down
7 changes: 7 additions & 0 deletions lib/ui/views/installer/installer_viewmodel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -453,6 +454,7 @@ class InstallerViewModel extends BaseViewModel {
}

Future<void> installResult(BuildContext context, bool installAsRoot) async {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was lazy to comprehend all the try-catch thing, so I've set isInstalling in each reasonable line in installResult method.

isInstalling = true;
try {
_app.isRooted = installAsRoot;
if (headerLogs != 'Installing...') {
Expand Down Expand Up @@ -497,11 +499,16 @@ class InstallerViewModel extends BaseViewModel {
'Installation failed',
);
}
isInstalling = false;
} on Exception catch (e) {
isInstalling = false;
if (kDebugMode) {
print(e);
}
} finally {
isInstalling = false;
}
isInstalling = false;
}

void exportResult() {
Expand Down