change page order

This commit is contained in:
Simon Ding
2024-07-18 15:53:58 +08:00
parent 7a3d93ec8e
commit a52e1c6277

View File

@@ -20,16 +20,14 @@ class _NavDrawerState extends State<NavDrawer> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
var uri = GoRouterState.of(context).uri.toString(); var uri = GoRouterState.of(context).uri.toString();
if (uri.contains(WelcomePage.routeMoivie)) { if (uri.contains(WelcomePage.routeTv)) {
_counter = 0; _counter = 0;
} else if (uri.contains(WelcomePage.routeTv)) { } else if (uri.contains(WelcomePage.routeMoivie)) {
_counter = 1; _counter = 1;
} else if (uri.contains(SearchPage.route)) {
_counter = 2;
} else if (uri.contains(ActivityPage.route)) { } else if (uri.contains(ActivityPage.route)) {
_counter = 3; _counter = 2;
} else if (uri.contains(SystemSettingsPage.route)) { } else if (uri.contains(SystemSettingsPage.route)) {
_counter = 4; _counter = 3;
} }
return NavigationRail( return NavigationRail(
selectedIndex: _counter, selectedIndex: _counter,
@@ -38,31 +36,25 @@ class _NavDrawerState extends State<NavDrawer> {
_counter = value; _counter = value;
}); });
if (value == 0) { if (value == 0) {
context.go(WelcomePage.routeMoivie);
} else if (value == 1) {
context.go(WelcomePage.routeTv); context.go(WelcomePage.routeTv);
} else if (value == 1) {
context.go(WelcomePage.routeMoivie);
} else if (value == 2) { } else if (value == 2) {
context.go(SearchPage.route);
} else if (value == 3) {
context.go(ActivityPage.route); context.go(ActivityPage.route);
} else if (value == 4) { } else if (value == 3) {
context.go(SystemSettingsPage.route); context.go(SystemSettingsPage.route);
} }
}, },
extended: MediaQuery.of(context).size.width >= 850, extended: MediaQuery.of(context).size.width >= 850,
unselectedIconTheme: const IconThemeData(color: Colors.grey), unselectedIconTheme: const IconThemeData(color: Colors.grey),
destinations: const <NavigationRailDestination>[ destinations: const <NavigationRailDestination>[
NavigationRailDestination(
icon: Icon(Icons.movie),
label: Text('电影'),
),
NavigationRailDestination( NavigationRailDestination(
icon: Icon(Icons.live_tv), icon: Icon(Icons.live_tv),
label: Text('电视剧'), label: Text('电视剧'),
), ),
NavigationRailDestination( NavigationRailDestination(
icon: Icon(Icons.search), icon: Icon(Icons.movie),
label: Text('搜索'), label: Text('电影'),
), ),
NavigationRailDestination( NavigationRailDestination(
icon: Icon(Icons.download), icon: Icon(Icons.download),