mirror of
https://github.com/revanced/revanced-manager.git
synced 2025-06-12 12:47:37 +02:00
fix: reorganize main and navigation
This commit is contained in:
@ -8,10 +8,10 @@ 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/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';
|
||||
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';
|
||||
|
||||
@ -46,7 +46,7 @@ class HomeViewModel extends BaseViewModel {
|
||||
locator<PatcherViewModel>().selectedPatches =
|
||||
await _patcherAPI.getAppliedPatches(app.appliedPatches);
|
||||
locator<PatcherViewModel>().notifyListeners();
|
||||
locator<MainViewModel>().setIndex(1);
|
||||
locator<NavigationViewModel>().setIndex(1);
|
||||
}
|
||||
|
||||
void _getPatchedApps() {
|
||||
|
64
lib/ui/views/navigation/navigation_view.dart
Normal file
64
lib/ui/views/navigation/navigation_view.dart
Normal file
@ -0,0 +1,64 @@
|
||||
import 'package:animations/animations.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_i18n/flutter_i18n.dart';
|
||||
import 'package:revanced_manager/app/app.locator.dart';
|
||||
import 'package:revanced_manager/ui/views/navigation/navigation_viewmodel.dart';
|
||||
import 'package:stacked/stacked.dart';
|
||||
|
||||
class NavigationView extends StatelessWidget {
|
||||
const NavigationView({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ViewModelBuilder<NavigationViewModel>.reactive(
|
||||
viewModelBuilder: () => locator<NavigationViewModel>(),
|
||||
builder: (context, model, child) => Scaffold(
|
||||
body: PageTransitionSwitcher(
|
||||
duration: const Duration(milliseconds: 400),
|
||||
transitionBuilder: (
|
||||
Widget child,
|
||||
Animation<double> animation,
|
||||
Animation<double> secondaryAnimation,
|
||||
) {
|
||||
return FadeThroughTransition(
|
||||
animation: animation,
|
||||
secondaryAnimation: secondaryAnimation,
|
||||
fillColor: Theme.of(context).colorScheme.surface,
|
||||
child: child,
|
||||
);
|
||||
},
|
||||
child: model.getViewForIndex(model.currentIndex),
|
||||
),
|
||||
bottomNavigationBar: NavigationBar(
|
||||
onDestinationSelected: model.setIndex,
|
||||
selectedIndex: model.currentIndex,
|
||||
destinations: <Widget>[
|
||||
NavigationDestination(
|
||||
icon: const Icon(
|
||||
Icons.dashboard,
|
||||
),
|
||||
label: FlutterI18n.translate(
|
||||
context,
|
||||
'main.dashboardTab',
|
||||
),
|
||||
),
|
||||
NavigationDestination(
|
||||
icon: const Icon(Icons.build),
|
||||
label: FlutterI18n.translate(
|
||||
context,
|
||||
'main.patcherTab',
|
||||
),
|
||||
),
|
||||
NavigationDestination(
|
||||
icon: const Icon(Icons.settings),
|
||||
label: FlutterI18n.translate(
|
||||
context,
|
||||
'main.settingsTab',
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
22
lib/ui/views/navigation/navigation_viewmodel.dart
Normal file
22
lib/ui/views/navigation/navigation_viewmodel.dart
Normal file
@ -0,0 +1,22 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:injectable/injectable.dart';
|
||||
import 'package:revanced_manager/ui/views/home/home_view.dart';
|
||||
import 'package:revanced_manager/ui/views/patcher/patcher_view.dart';
|
||||
import 'package:revanced_manager/ui/views/settings/settings_view.dart';
|
||||
import 'package:stacked/stacked.dart';
|
||||
|
||||
@lazySingleton
|
||||
class NavigationViewModel extends IndexTrackingViewModel {
|
||||
Widget getViewForIndex(int index) {
|
||||
switch (index) {
|
||||
case 0:
|
||||
return const HomeView();
|
||||
case 1:
|
||||
return const PatcherView();
|
||||
case 2:
|
||||
return SettingsView();
|
||||
default:
|
||||
return const HomeView();
|
||||
}
|
||||
}
|
||||
}
|
@ -62,7 +62,7 @@ class _PatchesSelectorViewState extends State<PatchesSelectorView> {
|
||||
onSelectAll: (value) => model.selectAllPatches(value),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
//TODO:IMPROVE THIS BAD CODE!!
|
||||
// TODO: IMPROVE THIS BAD CODE
|
||||
Expanded(
|
||||
child: ListView(
|
||||
padding: const EdgeInsets.only(bottom: 80),
|
||||
|
@ -27,6 +27,6 @@ class RootCheckerViewModel extends BaseViewModel {
|
||||
|
||||
Future<void> navigateToHome() async {
|
||||
_managerAPI.setIsRooted(isRooted);
|
||||
_navigationService.navigateTo(Routes.navigation);
|
||||
_navigationService.navigateTo(Routes.navigationView);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user