fix: show patcher when clicking on the patch button

This commit is contained in:
Alberto Ponces 2022-08-21 02:30:40 +01:00
parent b327926219
commit 8434211b61
6 changed files with 16 additions and 11 deletions

View File

@ -1,9 +1,11 @@
import 'package:revanced_manager/main.dart'; 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/services/patcher_api.dart';
import 'package:revanced_manager/ui/views/app_selector/app_selector_view.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/contributors/contributors_view.dart';
import 'package:revanced_manager/ui/views/home/home_viewmodel.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/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/patcher/patcher_viewmodel.dart';
import 'package:revanced_manager/ui/views/patches_selector/patches_selector_view.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'; import 'package:revanced_manager/ui/views/root_checker/root_checker_view.dart';
@ -15,6 +17,7 @@ import 'package:stacked_themes/stacked_themes.dart';
@StackedApp( @StackedApp(
routes: [ routes: [
MaterialRoute(page: Navigation), MaterialRoute(page: Navigation),
MaterialRoute(page: PatcherView),
MaterialRoute(page: AppSelectorView), MaterialRoute(page: AppSelectorView),
MaterialRoute(page: PatchesSelectorView), MaterialRoute(page: PatchesSelectorView),
MaterialRoute(page: InstallerView), MaterialRoute(page: InstallerView),
@ -23,14 +26,15 @@ import 'package:stacked_themes/stacked_themes.dart';
MaterialRoute(page: RootCheckerView), MaterialRoute(page: RootCheckerView),
], ],
dependencies: [ dependencies: [
LazySingleton(classType: NavigationService), LazySingleton(classType: MainViewModel),
LazySingleton(classType: PatcherAPI),
LazySingleton(classType: HomeViewModel), LazySingleton(classType: HomeViewModel),
LazySingleton(classType: PatcherViewModel), LazySingleton(classType: PatcherViewModel),
LazySingleton(classType: NavigationService),
LazySingleton( LazySingleton(
classType: ThemeService, classType: ThemeService,
resolveUsing: ThemeService.getInstance, resolveUsing: ThemeService.getInstance,
), ),
LazySingleton(classType: PatcherAPI),
], ],
) )
class AppSetup {} class AppSetup {}

View File

@ -85,7 +85,7 @@ class Navigation extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return ViewModelBuilder<MainViewModel>.reactive( return ViewModelBuilder<MainViewModel>.reactive(
viewModelBuilder: () => MainViewModel(), viewModelBuilder: () => locator<MainViewModel>(),
builder: (context, model, child) => Scaffold( builder: (context, model, child) => Scaffold(
body: getViewForIndex(model.currentIndex), body: getViewForIndex(model.currentIndex),
bottomNavigationBar: NavigationBar( bottomNavigationBar: NavigationBar(

View File

@ -1,6 +1,5 @@
import 'package:injectable/injectable.dart';
import 'package:stacked/stacked.dart'; import 'package:stacked/stacked.dart';
class MainViewModel extends IndexTrackingViewModel { @lazySingleton
class MainViewModel extends IndexTrackingViewModel {}
}

View File

@ -10,6 +10,7 @@ import 'package:fluttertoast/fluttertoast.dart';
import 'package:injectable/injectable.dart'; import 'package:injectable/injectable.dart';
import 'package:revanced_manager/app/app.locator.dart'; import 'package:revanced_manager/app/app.locator.dart';
import 'package:revanced_manager/app/app.router.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/models/patched_application.dart';
import 'package:revanced_manager/services/manager_api.dart'; import 'package:revanced_manager/services/manager_api.dart';
import 'package:revanced_manager/services/patcher_api.dart'; import 'package:revanced_manager/services/patcher_api.dart';
@ -42,11 +43,12 @@ class HomeViewModel extends BaseViewModel {
notifyListeners(); notifyListeners();
} }
void navigateToInstaller(PatchedApplication app) async { void navigateToPatcher(PatchedApplication app) async {
locator<PatcherViewModel>().selectedApp = app; locator<PatcherViewModel>().selectedApp = app;
locator<PatcherViewModel>().selectedPatches = locator<PatcherViewModel>().selectedPatches =
await _patcherAPI.getAppliedPatches(app); await _patcherAPI.getAppliedPatches(app);
_navigationService.navigateTo(Routes.installerView); locator<PatcherViewModel>().notifyListeners();
locator<MainViewModel>().setIndex(1);
} }
Future<List<PatchedApplication>> getPatchedApps(bool isUpdatable) async { Future<List<PatchedApplication>> getPatchedApps(bool isUpdatable) async {

View File

@ -38,7 +38,7 @@ class AvailableUpdatesCard extends StatelessWidget {
changelog: snapshot2.data!, changelog: snapshot2.data!,
isUpdatableApp: true, isUpdatableApp: true,
onPressed: () => onPressed: () =>
locator<HomeViewModel>().navigateToInstaller( locator<HomeViewModel>().navigateToPatcher(
snapshot.data![index], snapshot.data![index],
), ),
), ),

View File

@ -38,7 +38,7 @@ class InstalledAppsCard extends StatelessWidget {
changelog: snapshot2.data!, changelog: snapshot2.data!,
isUpdatableApp: false, isUpdatableApp: false,
onPressed: () => onPressed: () =>
locator<HomeViewModel>().navigateToInstaller( locator<HomeViewModel>().navigateToPatcher(
snapshot.data![index], snapshot.data![index],
), ),
), ),