2022-09-05 10:07:38 +02:00
|
|
|
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 {
|
2023-11-11 13:07:32 +01:00
|
|
|
const NavigationView({super.key});
|
2022-09-05 10:07:38 +02:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return ViewModelBuilder<NavigationViewModel>.reactive(
|
2023-01-30 13:35:06 +01:00
|
|
|
onViewModelReady: (model) => model.initialize(context),
|
2022-09-05 10:07:38 +02:00
|
|
|
viewModelBuilder: () => locator<NavigationViewModel>(),
|
2023-12-11 13:02:13 +01:00
|
|
|
builder: (context, model, child) => WillPopScope(
|
|
|
|
onWillPop: () async {
|
|
|
|
if (model.currentIndex == 0) {
|
|
|
|
return true;
|
|
|
|
} else {
|
2023-07-13 15:40:48 +02:00
|
|
|
model.setIndex(0);
|
2023-12-11 13:02:13 +01:00
|
|
|
return false;
|
2023-07-13 15:40:48 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
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: model.isIndexSelected(0)
|
|
|
|
? const Icon(Icons.dashboard)
|
|
|
|
: const Icon(Icons.dashboard_outlined),
|
|
|
|
label: FlutterI18n.translate(
|
|
|
|
context,
|
|
|
|
'navigationView.dashboardTab',
|
|
|
|
),
|
|
|
|
tooltip: '',
|
2022-09-05 10:07:38 +02:00
|
|
|
),
|
2023-07-13 15:40:48 +02:00
|
|
|
NavigationDestination(
|
|
|
|
icon: model.isIndexSelected(1)
|
|
|
|
? const Icon(Icons.build)
|
|
|
|
: const Icon(Icons.build_outlined),
|
|
|
|
label: FlutterI18n.translate(
|
|
|
|
context,
|
|
|
|
'navigationView.patcherTab',
|
|
|
|
),
|
|
|
|
tooltip: '',
|
2022-09-05 10:07:38 +02:00
|
|
|
),
|
2023-07-13 15:40:48 +02:00
|
|
|
NavigationDestination(
|
|
|
|
icon: model.isIndexSelected(2)
|
|
|
|
? const Icon(Icons.settings)
|
|
|
|
: const Icon(Icons.settings_outlined),
|
|
|
|
label: FlutterI18n.translate(
|
|
|
|
context,
|
|
|
|
'navigationView.settingsTab',
|
|
|
|
),
|
|
|
|
tooltip: '',
|
2022-09-05 10:07:38 +02:00
|
|
|
),
|
2023-07-13 15:40:48 +02:00
|
|
|
],
|
|
|
|
),
|
2022-09-05 10:07:38 +02:00
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|