mirror of
https://github.com/ReVanced/revanced-manager.git
synced 2025-05-11 21:15:37 +02:00
fix: reorganize main and navigation
This commit is contained in:
parent
9b91e4aaa3
commit
db02dc623f
10 changed files with 96 additions and 93 deletions
|
@ -1,18 +1,13 @@
|
|||
import 'package:animations/animations.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_i18n/flutter_i18n.dart';
|
||||
// ignore: depend_on_referenced_packages
|
||||
import 'package:flutter_localizations/flutter_localizations.dart';
|
||||
import 'package:revanced_manager/app/app.locator.dart';
|
||||
import 'package:revanced_manager/main_viewmodel.dart';
|
||||
import 'package:revanced_manager/services/manager_api.dart';
|
||||
import 'package:revanced_manager/services/patcher_api.dart';
|
||||
import 'package:revanced_manager/ui/theme/dynamic_theme_builder.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/navigation/navigation_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:stacked/stacked.dart';
|
||||
import 'package:stacked_themes/stacked_themes.dart';
|
||||
|
||||
Future main() async {
|
||||
|
@ -62,79 +57,8 @@ class MyApp extends StatelessWidget {
|
|||
await locator<PatcherAPI>().initialize();
|
||||
bool? isRooted = locator<ManagerAPI>().isRooted();
|
||||
if (isRooted != null) {
|
||||
return const Navigation();
|
||||
return const NavigationView();
|
||||
}
|
||||
return const RootCheckerView();
|
||||
}
|
||||
}
|
||||
|
||||
class Navigation extends StatelessWidget {
|
||||
const Navigation({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ViewModelBuilder<MainViewModel>.reactive(
|
||||
viewModelBuilder: () => locator<MainViewModel>(),
|
||||
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: 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',
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget getViewForIndex(int index) {
|
||||
switch (index) {
|
||||
case 0:
|
||||
return const HomeView();
|
||||
case 1:
|
||||
return const PatcherView();
|
||||
case 2:
|
||||
return SettingsView();
|
||||
default:
|
||||
return const HomeView();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue