diff --git a/lib/app/app.dart b/lib/app/app.dart index 9bbd16e9..95405a24 100644 --- a/lib/app/app.dart +++ b/lib/app/app.dart @@ -11,6 +11,7 @@ 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'; import 'package:revanced_manager/ui/views/settings/settings_view.dart'; +import 'package:revanced_manager/ui/widgets/appInfoView/app_info_view.dart'; import 'package:stacked/stacked_annotations.dart'; import 'package:stacked_services/stacked_services.dart'; @@ -24,6 +25,7 @@ import 'package:stacked_services/stacked_services.dart'; MaterialRoute(page: SettingsView), MaterialRoute(page: ContributorsView), MaterialRoute(page: RootCheckerView), + MaterialRoute(page: AppInfoView), ], dependencies: [ LazySingleton(classType: NavigationViewModel), diff --git a/lib/ui/views/home/home_viewmodel.dart b/lib/ui/views/home/home_viewmodel.dart index d0971d69..240f1be3 100644 --- a/lib/ui/views/home/home_viewmodel.dart +++ b/lib/ui/views/home/home_viewmodel.dart @@ -8,15 +8,18 @@ import 'package:flutter_local_notifications/flutter_local_notifications.dart'; 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/models/patched_application.dart'; import 'package:revanced_manager/services/manager_api.dart'; import 'package:revanced_manager/services/patcher_api.dart'; import 'package:revanced_manager/ui/views/navigation/navigation_viewmodel.dart'; import 'package:revanced_manager/ui/views/patcher/patcher_viewmodel.dart'; import 'package:stacked/stacked.dart'; +import 'package:stacked_services/stacked_services.dart'; @lazySingleton class HomeViewModel extends BaseViewModel { + final NavigationService _navigationService = locator(); final ManagerAPI _managerAPI = locator(); final PatcherAPI _patcherAPI = locator(); final FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin = @@ -36,6 +39,13 @@ class HomeViewModel extends BaseViewModel { _managerAPI.reAssessSavedApps().then((_) => _getPatchedApps()); } + void navigateToAppInfo(PatchedApplication app) { + _navigationService.navigateTo( + Routes.appInfoView, + arguments: AppInfoViewArguments(app: app), + ); + } + void toggleUpdatableApps(bool value) { showUpdatableApps = value; notifyListeners(); diff --git a/lib/ui/views/patcher/patcher_view.dart b/lib/ui/views/patcher/patcher_view.dart index b0a74182..db858fb5 100644 --- a/lib/ui/views/patcher/patcher_view.dart +++ b/lib/ui/views/patcher/patcher_view.dart @@ -2,14 +2,10 @@ import 'package:flutter/material.dart'; import 'package:flutter_i18n/flutter_i18n.dart'; import 'package:google_fonts/google_fonts.dart'; import 'package:revanced_manager/app/app.locator.dart'; -import 'package:revanced_manager/ui/views/app_selector/app_selector_view.dart'; -import 'package:revanced_manager/ui/views/installer/installer_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/widgets/patcherView/app_selector_card.dart'; import 'package:revanced_manager/ui/widgets/patcherView/patch_selector_card.dart'; import 'package:revanced_manager/ui/widgets/shared/custom_sliver_app_bar.dart'; -import 'package:revanced_manager/ui/widgets/shared/open_container_wrapper.dart'; import 'package:stacked/stacked.dart'; class PatcherView extends StatelessWidget { @@ -23,13 +19,10 @@ class PatcherView extends StatelessWidget { builder: (context, model, child) => Scaffold( floatingActionButton: Visibility( visible: model.showPatchButton(), - child: OpenContainerWrapper( - openBuilder: (_, __) => const InstallerView(), - closedBuilder: (_, openContainer) => FloatingActionButton.extended( - label: I18nText('patcherView.patchButton'), - icon: const Icon(Icons.build), - onPressed: openContainer, - ), + child: FloatingActionButton.extended( + label: I18nText('patcherView.patchButton'), + icon: const Icon(Icons.build), + onPressed: () => model.navigateToInstaller(), ), ), body: CustomScrollView( @@ -50,21 +43,16 @@ class PatcherView extends StatelessWidget { sliver: SliverList( delegate: SliverChildListDelegate.fixed( [ - OpenContainerWrapper( - openBuilder: (_, __) => const AppSelectorView(), - closedBuilder: (_, openContainer) => AppSelectorCard( - onPressed: openContainer, - ), + AppSelectorCard( + onPressed: () => model.navigateToAppSelector(), ), const SizedBox(height: 16), Opacity( opacity: model.dimPatchesCard() ? 0.5 : 1, - child: OpenContainerWrapper( - openBuilder: (_, __) => const PatchesSelectorView(), - closedBuilder: (_, openContainer) => PatchSelectorCard( - onPressed: - model.dimPatchesCard() ? () => {} : openContainer, - ), + child: PatchSelectorCard( + onPressed: model.dimPatchesCard() + ? () => {} + : () => model.navigateToPatchesSelector(), ), ), ], diff --git a/lib/ui/views/patcher/patcher_viewmodel.dart b/lib/ui/views/patcher/patcher_viewmodel.dart index ab319c07..2fc9ffe9 100644 --- a/lib/ui/views/patcher/patcher_viewmodel.dart +++ b/lib/ui/views/patcher/patcher_viewmodel.dart @@ -1,13 +1,29 @@ 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/models/patch.dart'; import 'package:revanced_manager/models/patched_application.dart'; import 'package:stacked/stacked.dart'; +import 'package:stacked_services/stacked_services.dart'; @lazySingleton class PatcherViewModel extends BaseViewModel { + final NavigationService _navigationService = locator(); PatchedApplication? selectedApp; List selectedPatches = []; + void navigateToAppSelector() { + _navigationService.navigateTo(Routes.appSelectorView); + } + + void navigateToPatchesSelector() { + _navigationService.navigateTo(Routes.patchesSelectorView); + } + + void navigateToInstaller() { + _navigationService.navigateTo(Routes.installerView); + } + bool showPatchButton() { return selectedPatches.isNotEmpty; } diff --git a/lib/ui/views/settings/settings_view.dart b/lib/ui/views/settings/settings_view.dart index e35014fd..d1a4ba0d 100644 --- a/lib/ui/views/settings/settings_view.dart +++ b/lib/ui/views/settings/settings_view.dart @@ -1,7 +1,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_i18n/flutter_i18n.dart'; import 'package:google_fonts/google_fonts.dart'; -import 'package:revanced_manager/ui/views/contributors/contributors_view.dart'; import 'package:revanced_manager/ui/views/settings/settings_viewmodel.dart'; import 'package:revanced_manager/ui/widgets/settingsView/about_widget.dart'; import 'package:revanced_manager/ui/widgets/settingsView/custom_switch_tile.dart'; @@ -10,7 +9,6 @@ import 'package:revanced_manager/ui/widgets/settingsView/settings_section.dart'; import 'package:revanced_manager/ui/widgets/settingsView/social_media_widget.dart'; import 'package:revanced_manager/ui/widgets/settingsView/sources_widget.dart'; import 'package:revanced_manager/ui/widgets/shared/custom_sliver_app_bar.dart'; -import 'package:revanced_manager/ui/widgets/shared/open_container_wrapper.dart'; import 'package:stacked/stacked.dart'; class SettingsView extends StatelessWidget { @@ -143,23 +141,20 @@ class SettingsView extends StatelessWidget { SettingsSection( title: 'settingsView.teamSectionTitle', children: [ - OpenContainerWrapper( - openBuilder: (_, __) => const ContributorsView(), - closedBuilder: (_, openContainer) => ListTile( - contentPadding: EdgeInsets.zero, - title: I18nText( - 'settingsView.contributorsLabel', - child: const Text( - '', - style: TextStyle( - fontSize: 20, - fontWeight: FontWeight.w500, - ), + ListTile( + contentPadding: EdgeInsets.zero, + title: I18nText( + 'settingsView.contributorsLabel', + child: const Text( + '', + style: TextStyle( + fontSize: 20, + fontWeight: FontWeight.w500, ), ), - subtitle: I18nText('settingsView.contributorsHint'), - onTap: openContainer, ), + subtitle: I18nText('settingsView.contributorsHint'), + onTap: () => model.navigateToContributors(), ), const SocialMediaWidget(), ], diff --git a/lib/ui/views/settings/settings_viewmodel.dart b/lib/ui/views/settings/settings_viewmodel.dart index 00a04efc..53c3c4a6 100644 --- a/lib/ui/views/settings/settings_viewmodel.dart +++ b/lib/ui/views/settings/settings_viewmodel.dart @@ -22,6 +22,10 @@ class SettingsViewModel extends BaseViewModel { _navigationService.navigateTo(Routes.rootCheckerView); } + void navigateToContributors() { + _navigationService.navigateTo(Routes.contributorsView); + } + Future updateLanguage(BuildContext context, String? value) async { if (value != null) { await FlutterI18n.refresh(context, Locale(value)); diff --git a/lib/ui/widgets/homeView/installed_apps_card.dart b/lib/ui/widgets/homeView/installed_apps_card.dart index 3d82bd17..2be557e4 100644 --- a/lib/ui/widgets/homeView/installed_apps_card.dart +++ b/lib/ui/widgets/homeView/installed_apps_card.dart @@ -3,10 +3,8 @@ import 'package:flutter_i18n/flutter_i18n.dart'; import 'package:revanced_manager/app/app.locator.dart'; import 'package:revanced_manager/models/patched_application.dart'; import 'package:revanced_manager/ui/views/home/home_viewmodel.dart'; -import 'package:revanced_manager/ui/widgets/appInfoView/app_info_view.dart'; import 'package:revanced_manager/ui/widgets/shared/application_item.dart'; import 'package:revanced_manager/ui/widgets/shared/custom_card.dart'; -import 'package:revanced_manager/ui/widgets/shared/open_container_wrapper.dart'; class InstalledAppsCard extends StatelessWidget { InstalledAppsCard({Key? key}) : super(key: key); @@ -41,16 +39,14 @@ class InstalledAppsCard extends StatelessWidget { physics: const NeverScrollableScrollPhysics(), children: apps .map( - (app) => OpenContainerWrapper( - openBuilder: (_, __) => AppInfoView(app: app), - closedBuilder: (_, openContainer) => ApplicationItem( - icon: app.icon, - name: app.name, - patchDate: app.patchDate, - changelog: app.changelog, - isUpdatableApp: false, - onPressed: openContainer, - ), + (app) => ApplicationItem( + icon: app.icon, + name: app.name, + patchDate: app.patchDate, + changelog: app.changelog, + isUpdatableApp: false, + onPressed: () => + locator().navigateToAppInfo(app), ), ) .toList(),