v7
This commit is contained in:
@@ -12,10 +12,11 @@ class AppNavigationRail extends StatefulWidget {
|
||||
class _AppNavigationRailState extends State<AppNavigationRail> {
|
||||
|
||||
final List<MenuMeta> deskNavBarMenus = const [
|
||||
MenuMeta(label: '颜色板', icon: Icons.color_lens_outlined),
|
||||
MenuMeta(label: '计数器', icon: Icons.add_chart),
|
||||
MenuMeta(label: '我的', icon: Icons.person),
|
||||
MenuMeta(label: '设置', icon: Icons.settings),
|
||||
MenuMeta(label: '颜色板', icon: Icons.color_lens_outlined,path: '/color'),
|
||||
MenuMeta(label: '计数器', icon: Icons.add_chart,path: '/counter'),
|
||||
MenuMeta(label: '排序', icon: Icons.sort,path: '/sort'),
|
||||
MenuMeta(label: '我的', icon: Icons.person,path: '/user'),
|
||||
MenuMeta(label: '设置', icon: Icons.settings,path: '/settings'),
|
||||
];
|
||||
|
||||
@override
|
||||
@@ -41,21 +42,33 @@ class _AppNavigationRailState extends State<AppNavigationRail> {
|
||||
),
|
||||
tail: Padding(
|
||||
padding: const EdgeInsets.only(bottom: 6.0),
|
||||
child: Text('V0.0.6',style: TextStyle(color: Colors.white,fontSize: 12),),
|
||||
child: Text('V0.0.7',style: TextStyle(color: Colors.white,fontSize: 12),),
|
||||
),
|
||||
backgroundColor: const Color(0xff3975c6),
|
||||
onDestinationSelected: _onDestinationSelected,
|
||||
selectedIndex: router.activeIndex,
|
||||
selectedIndex: activeIndex,
|
||||
),
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
RegExp _segReg = RegExp(r'/\w+');
|
||||
|
||||
int? get activeIndex{
|
||||
String path = router.path;
|
||||
RegExpMatch? match = _segReg.firstMatch(path);
|
||||
if(match==null) return null;
|
||||
String? target = match.group(0);
|
||||
int index = deskNavBarMenus.indexWhere((menu) => menu.path==target);
|
||||
if(index==-1) return null;
|
||||
return index;
|
||||
}
|
||||
|
||||
void _onDestinationSelected(int index) {
|
||||
String path = deskNavBarMenus[index].path!;
|
||||
if(index==1){
|
||||
router.changePath(kDestinationsPaths[index],keepAlive: true);
|
||||
router.changePath(path,keepAlive: true);
|
||||
}else{
|
||||
router.changePath(kDestinationsPaths[index]);
|
||||
router.changePath(path);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -57,6 +57,7 @@ Map<String, String> kRouteLabelMap = {
|
||||
'/color/add': '添加颜色',
|
||||
'/color/detail': '颜色详情',
|
||||
'/counter': '计数器',
|
||||
'/sort': '可视化排序算法',
|
||||
'/user': '我的',
|
||||
'/settings': '系统设置',
|
||||
};
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:iroute/components/components.dart';
|
||||
import '../../router/app_router_delegate.dart';
|
||||
import '../../router/route_history.dart';
|
||||
import '../../router/iroute_config.dart';
|
||||
import 'app_top_bar.dart';
|
||||
|
||||
class HistoryViewIcon extends StatelessWidget{
|
||||
@@ -55,7 +55,7 @@ class HistoryViewIcon extends StatelessWidget{
|
||||
}
|
||||
|
||||
class HistoryItem extends StatefulWidget {
|
||||
final RouteHistory history;
|
||||
final IRouteConfig history;
|
||||
final VoidCallback onPressed;
|
||||
final VoidCallback onDelete;
|
||||
|
||||
@@ -83,7 +83,7 @@ class _HistoryItemState extends State<HistoryItem> {
|
||||
const SizedBox(
|
||||
height: 2,
|
||||
),
|
||||
Text(kRouteLabelMap[widget.history.path]!),
|
||||
Text(kRouteLabelMap[widget.history.path]??'未知路由'),
|
||||
],
|
||||
)),
|
||||
GestureDetector(
|
||||
@@ -124,7 +124,8 @@ class _HistoryPanelState extends State<HistoryPanel> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if(router.histories.isEmpty){
|
||||
List<IRouteConfig> histories = router.historyManager.histories;
|
||||
if(histories.isEmpty){
|
||||
return const Center(
|
||||
child: Text(
|
||||
'暂无浏览历史记录',
|
||||
@@ -135,18 +136,18 @@ class _HistoryPanelState extends State<HistoryPanel> {
|
||||
return ListView.builder(
|
||||
padding: const EdgeInsets.symmetric(vertical: 12, horizontal: 16),
|
||||
itemExtent: 46,
|
||||
itemCount: router.histories.length,
|
||||
itemCount: histories.length,
|
||||
itemBuilder: (_, index) =>
|
||||
HistoryItem(
|
||||
onDelete: (){
|
||||
int fixIndex = router.histories.length - 1 - index;
|
||||
int fixIndex = histories.length - 1 - index;
|
||||
router.closeHistory(fixIndex);
|
||||
},
|
||||
onPressed: (){
|
||||
router.toHistory(router.histories[index]);
|
||||
router.changeRoute(histories[index].copyWith(recordHistory: false));
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
history: router.histories[index]),
|
||||
history: histories[index]),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -25,8 +25,8 @@ class _RouteHistoryButtonState extends State<RouteHistoryButton> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
bool hasHistory = router.hasHistory;
|
||||
bool hasBackHistory = router.hasBackHistory;
|
||||
bool hasHistory = router.historyManager.hasHistory;
|
||||
bool hasBackHistory = router.historyManager.hasBackHistory;
|
||||
Color activeColor = const Color(0xff9195AC);
|
||||
Color inActiveColor = const Color(0xffC7CAD5);
|
||||
Color historyColor = hasHistory?activeColor:inActiveColor;
|
||||
|
||||
Reference in New Issue
Block a user