fix: unblock UI while running Patcher (#4)

This commit is contained in:
Alberto Ponces
2022-08-17 12:48:03 +01:00
committed by GitHub
parent 014450642d
commit 165bd4aec2
8 changed files with 354 additions and 396 deletions

View File

@ -18,7 +18,7 @@ class PatcherView extends StatelessWidget {
viewModelBuilder: () => locator<PatcherViewModel>(),
builder: (context, model, child) => Scaffold(
floatingActionButton: Visibility(
visible: locator<PatcherViewModel>().showFabButton,
visible: model.showFabButton(),
child: FloatingActionButton.extended(
onPressed: () => model.navigateToInstaller(),
label: I18nText('patcherView.fabButton'),
@ -52,8 +52,8 @@ class PatcherView extends StatelessWidget {
const SizedBox(height: 16),
Opacity(
opacity: isDark
? (model.dimPatchCard ? 0.5 : 1)
: (model.dimPatchCard ? 0.75 : 1),
? (model.dimPatchesCard() ? 0.5 : 1)
: (model.dimPatchesCard() ? 0.75 : 1),
child: PatchSelectorCard(
onPressed: model.navigateToPatchesSelector,
color: Theme.of(context).colorScheme.primary,

View File

@ -1,12 +1,12 @@
import 'package:revanced_manager/app/app.locator.dart';
import 'package:revanced_manager/app/app.router.dart';
import 'package:revanced_manager/ui/views/app_selector/app_selector_viewmodel.dart';
import 'package:revanced_manager/ui/views/patches_selector/patches_selector_viewmodel.dart';
import 'package:stacked/stacked.dart';
import 'package:stacked_services/stacked_services.dart';
class PatcherViewModel extends BaseViewModel {
final _navigationService = locator<NavigationService>();
bool dimPatchCard = true;
bool showFabButton = false;
void navigateToAppSelector() {
_navigationService.navigateTo(Routes.appSelectorView);
@ -19,4 +19,12 @@ class PatcherViewModel extends BaseViewModel {
void navigateToInstaller() {
_navigationService.navigateTo(Routes.installerView);
}
bool showFabButton() {
return locator<PatchesSelectorViewModel>().selectedPatches.isNotEmpty;
}
bool dimPatchesCard() {
return locator<AppSelectorViewModel>().selectedApp == null;
}
}