From 8434211b613a1a9d565db294a9ae9fbbef1f16b7 Mon Sep 17 00:00:00 2001 From: Alberto Ponces Date: Sun, 21 Aug 2022 02:30:40 +0100 Subject: [PATCH] fix: show patcher when clicking on the patch button --- lib/app/app.dart | 8 ++++++-- lib/main.dart | 2 +- lib/main_viewmodel.dart | 7 +++---- lib/ui/views/home/home_viewmodel.dart | 6 ++++-- lib/ui/widgets/available_updates_card.dart | 2 +- lib/ui/widgets/installed_apps_card.dart | 2 +- 6 files changed, 16 insertions(+), 11 deletions(-) diff --git a/lib/app/app.dart b/lib/app/app.dart index 8a1af862..fbc19f6c 100644 --- a/lib/app/app.dart +++ b/lib/app/app.dart @@ -1,9 +1,11 @@ import 'package:revanced_manager/main.dart'; +import 'package:revanced_manager/main_viewmodel.dart'; import 'package:revanced_manager/services/patcher_api.dart'; import 'package:revanced_manager/ui/views/app_selector/app_selector_view.dart'; import 'package:revanced_manager/ui/views/contributors/contributors_view.dart'; import 'package:revanced_manager/ui/views/home/home_viewmodel.dart'; import 'package:revanced_manager/ui/views/installer/installer_view.dart'; +import 'package:revanced_manager/ui/views/patcher/patcher_view.dart'; import 'package:revanced_manager/ui/views/patcher/patcher_viewmodel.dart'; import 'package:revanced_manager/ui/views/patches_selector/patches_selector_view.dart'; import 'package:revanced_manager/ui/views/root_checker/root_checker_view.dart'; @@ -15,6 +17,7 @@ import 'package:stacked_themes/stacked_themes.dart'; @StackedApp( routes: [ MaterialRoute(page: Navigation), + MaterialRoute(page: PatcherView), MaterialRoute(page: AppSelectorView), MaterialRoute(page: PatchesSelectorView), MaterialRoute(page: InstallerView), @@ -23,14 +26,15 @@ import 'package:stacked_themes/stacked_themes.dart'; MaterialRoute(page: RootCheckerView), ], dependencies: [ - LazySingleton(classType: NavigationService), - LazySingleton(classType: PatcherAPI), + LazySingleton(classType: MainViewModel), LazySingleton(classType: HomeViewModel), LazySingleton(classType: PatcherViewModel), + LazySingleton(classType: NavigationService), LazySingleton( classType: ThemeService, resolveUsing: ThemeService.getInstance, ), + LazySingleton(classType: PatcherAPI), ], ) class AppSetup {} diff --git a/lib/main.dart b/lib/main.dart index c545be8c..037a7bf4 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -85,7 +85,7 @@ class Navigation extends StatelessWidget { @override Widget build(BuildContext context) { return ViewModelBuilder.reactive( - viewModelBuilder: () => MainViewModel(), + viewModelBuilder: () => locator(), builder: (context, model, child) => Scaffold( body: getViewForIndex(model.currentIndex), bottomNavigationBar: NavigationBar( diff --git a/lib/main_viewmodel.dart b/lib/main_viewmodel.dart index 5555e751..94929b92 100644 --- a/lib/main_viewmodel.dart +++ b/lib/main_viewmodel.dart @@ -1,6 +1,5 @@ +import 'package:injectable/injectable.dart'; import 'package:stacked/stacked.dart'; -class MainViewModel extends IndexTrackingViewModel { - - -} +@lazySingleton +class MainViewModel extends IndexTrackingViewModel {} diff --git a/lib/ui/views/home/home_viewmodel.dart b/lib/ui/views/home/home_viewmodel.dart index 2fec5d2f..4bdfbc75 100644 --- a/lib/ui/views/home/home_viewmodel.dart +++ b/lib/ui/views/home/home_viewmodel.dart @@ -10,6 +10,7 @@ import 'package:fluttertoast/fluttertoast.dart'; import 'package:injectable/injectable.dart'; import 'package:revanced_manager/app/app.locator.dart'; import 'package:revanced_manager/app/app.router.dart'; +import 'package:revanced_manager/main_viewmodel.dart'; import 'package:revanced_manager/models/patched_application.dart'; import 'package:revanced_manager/services/manager_api.dart'; import 'package:revanced_manager/services/patcher_api.dart'; @@ -42,11 +43,12 @@ class HomeViewModel extends BaseViewModel { notifyListeners(); } - void navigateToInstaller(PatchedApplication app) async { + void navigateToPatcher(PatchedApplication app) async { locator().selectedApp = app; locator().selectedPatches = await _patcherAPI.getAppliedPatches(app); - _navigationService.navigateTo(Routes.installerView); + locator().notifyListeners(); + locator().setIndex(1); } Future> getPatchedApps(bool isUpdatable) async { diff --git a/lib/ui/widgets/available_updates_card.dart b/lib/ui/widgets/available_updates_card.dart index e2af29a3..becf2682 100644 --- a/lib/ui/widgets/available_updates_card.dart +++ b/lib/ui/widgets/available_updates_card.dart @@ -38,7 +38,7 @@ class AvailableUpdatesCard extends StatelessWidget { changelog: snapshot2.data!, isUpdatableApp: true, onPressed: () => - locator().navigateToInstaller( + locator().navigateToPatcher( snapshot.data![index], ), ), diff --git a/lib/ui/widgets/installed_apps_card.dart b/lib/ui/widgets/installed_apps_card.dart index be039b91..407b4906 100644 --- a/lib/ui/widgets/installed_apps_card.dart +++ b/lib/ui/widgets/installed_apps_card.dart @@ -38,7 +38,7 @@ class InstalledAppsCard extends StatelessWidget { changelog: snapshot2.data!, isUpdatableApp: false, onPressed: () => - locator().navigateToInstaller( + locator().navigateToPatcher( snapshot.data![index], ), ),