mirror of
https://github.com/ReVanced/revanced-manager.git
synced 2024-11-10 01:01:56 +01:00
fix(navigation-view): back button closing the app from any page (#1019)
This commit is contained in:
parent
0462815014
commit
c5b0621323
1 changed files with 59 additions and 49 deletions
|
@ -13,58 +13,68 @@ class NavigationView extends StatelessWidget {
|
||||||
return ViewModelBuilder<NavigationViewModel>.reactive(
|
return ViewModelBuilder<NavigationViewModel>.reactive(
|
||||||
onViewModelReady: (model) => model.initialize(context),
|
onViewModelReady: (model) => model.initialize(context),
|
||||||
viewModelBuilder: () => locator<NavigationViewModel>(),
|
viewModelBuilder: () => locator<NavigationViewModel>(),
|
||||||
builder: (context, model, child) => Scaffold(
|
builder: (context, model, child) => WillPopScope(
|
||||||
body: PageTransitionSwitcher(
|
onWillPop: ()async{
|
||||||
duration: const Duration(milliseconds: 400),
|
if(model.currentIndex == 0){
|
||||||
transitionBuilder: (
|
return true;
|
||||||
Widget child,
|
}else{
|
||||||
Animation<double> animation,
|
model.setIndex(0);
|
||||||
Animation<double> secondaryAnimation,
|
return false;
|
||||||
) {
|
}
|
||||||
return FadeThroughTransition(
|
},
|
||||||
animation: animation,
|
child: Scaffold(
|
||||||
secondaryAnimation: secondaryAnimation,
|
body: PageTransitionSwitcher(
|
||||||
fillColor: Theme.of(context).colorScheme.surface,
|
duration: const Duration(milliseconds: 400),
|
||||||
child: child,
|
transitionBuilder: (
|
||||||
);
|
Widget child,
|
||||||
},
|
Animation<double> animation,
|
||||||
child: model.getViewForIndex(model.currentIndex),
|
Animation<double> secondaryAnimation,
|
||||||
),
|
) {
|
||||||
bottomNavigationBar: NavigationBar(
|
return FadeThroughTransition(
|
||||||
onDestinationSelected: model.setIndex,
|
animation: animation,
|
||||||
selectedIndex: model.currentIndex,
|
secondaryAnimation: secondaryAnimation,
|
||||||
destinations: <Widget>[
|
fillColor: Theme.of(context).colorScheme.surface,
|
||||||
NavigationDestination(
|
child: child,
|
||||||
icon: model.isIndexSelected(0)
|
);
|
||||||
? const Icon(Icons.dashboard)
|
},
|
||||||
: const Icon(Icons.dashboard_outlined),
|
child: model.getViewForIndex(model.currentIndex),
|
||||||
label: FlutterI18n.translate(
|
),
|
||||||
context,
|
bottomNavigationBar: NavigationBar(
|
||||||
'navigationView.dashboardTab',
|
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: '',
|
||||||
),
|
),
|
||||||
tooltip: '',
|
NavigationDestination(
|
||||||
),
|
icon: model.isIndexSelected(1)
|
||||||
NavigationDestination(
|
? const Icon(Icons.build)
|
||||||
icon: model.isIndexSelected(1)
|
: const Icon(Icons.build_outlined),
|
||||||
? const Icon(Icons.build)
|
label: FlutterI18n.translate(
|
||||||
: const Icon(Icons.build_outlined),
|
context,
|
||||||
label: FlutterI18n.translate(
|
'navigationView.patcherTab',
|
||||||
context,
|
),
|
||||||
'navigationView.patcherTab',
|
tooltip: '',
|
||||||
),
|
),
|
||||||
tooltip: '',
|
NavigationDestination(
|
||||||
),
|
icon: model.isIndexSelected(2)
|
||||||
NavigationDestination(
|
? const Icon(Icons.settings)
|
||||||
icon: model.isIndexSelected(2)
|
: const Icon(Icons.settings_outlined),
|
||||||
? const Icon(Icons.settings)
|
label: FlutterI18n.translate(
|
||||||
: const Icon(Icons.settings_outlined),
|
context,
|
||||||
label: FlutterI18n.translate(
|
'navigationView.settingsTab',
|
||||||
context,
|
),
|
||||||
'navigationView.settingsTab',
|
tooltip: '',
|
||||||
),
|
),
|
||||||
tooltip: '',
|
],
|
||||||
),
|
),
|
||||||
],
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in a new issue