From af2ebea86d146aa1d902130be572182d611144c5 Mon Sep 17 00:00:00 2001 From: lauirf <592184299@qq.com> Date: Thu, 19 Dec 2024 16:24:27 +0800 Subject: [PATCH] simplify code --- lib/pages/menu/menu.dart | 23 +---------------------- lib/pages/menu/side_menu.dart | 15 +-------------- 2 files changed, 2 insertions(+), 36 deletions(-) diff --git a/lib/pages/menu/menu.dart b/lib/pages/menu/menu.dart index 1d91bf5a..79520133 100644 --- a/lib/pages/menu/menu.dart +++ b/lib/pages/menu/menu.dart @@ -85,28 +85,7 @@ class _BottomMenu extends State { // selectedIndex = index; // }); state.updateSelectedIndex(index); - switch (index) { - case 0: - { - Modular.to.navigate('/tab/popular/'); - } - break; - case 1: - { - Modular.to.navigate('/tab/timeline/'); - } - break; - case 2: - { - Modular.to.navigate('/tab/collect/'); - } - break; - case 3: - { - Modular.to.navigate('/tab/my/'); - } - break; - } + Modular.to.navigate("/tab${menu.getPath(index)}/"); }, ); }), diff --git a/lib/pages/menu/side_menu.dart b/lib/pages/menu/side_menu.dart index 769b6c67..bd8c920c 100644 --- a/lib/pages/menu/side_menu.dart +++ b/lib/pages/menu/side_menu.dart @@ -90,20 +90,7 @@ class _SideMenu extends State { selectedIndex: state.selectedIndex, onDestinationSelected: (int index) { state.updateSelectedIndex(index); - switch (index) { - case 0: - Modular.to.navigate('/tab/popular/'); - break; - case 1: - Modular.to.navigate('/tab/timeline/'); - break; - case 2: - Modular.to.navigate('/tab/collect/'); - break; - case 3: - Modular.to.navigate('/tab/my/'); - break; - } + Modular.to.navigate("/tab${menu.getPath(index)}/"); }, ), ),