v8
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:iroute/components/components.dart';
|
||||
import '../router/app_router_delegate.dart';
|
||||
import '../router/iroute_config.dart';
|
||||
|
||||
class AppNavigationRail extends StatefulWidget {
|
||||
const AppNavigationRail({super.key});
|
||||
@@ -10,13 +11,12 @@ class AppNavigationRail extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _AppNavigationRailState extends State<AppNavigationRail> {
|
||||
|
||||
final List<MenuMeta> deskNavBarMenus = const [
|
||||
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'),
|
||||
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
|
||||
@@ -42,7 +42,10 @@ class _AppNavigationRailState extends State<AppNavigationRail> {
|
||||
),
|
||||
tail: Padding(
|
||||
padding: const EdgeInsets.only(bottom: 6.0),
|
||||
child: Text('V0.0.7',style: TextStyle(color: Colors.white,fontSize: 12),),
|
||||
child: Text(
|
||||
'V0.0.8',
|
||||
style: TextStyle(color: Colors.white, fontSize: 12),
|
||||
),
|
||||
),
|
||||
backgroundColor: const Color(0xff3975c6),
|
||||
onDestinationSelected: _onDestinationSelected,
|
||||
@@ -53,21 +56,26 @@ class _AppNavigationRailState extends State<AppNavigationRail> {
|
||||
|
||||
RegExp _segReg = RegExp(r'/\w+');
|
||||
|
||||
int? get activeIndex{
|
||||
int? get activeIndex {
|
||||
String path = router.path;
|
||||
RegExpMatch? match = _segReg.firstMatch(path);
|
||||
if(match==null) return null;
|
||||
if (match == null) return null;
|
||||
String? target = match.group(0);
|
||||
int index = deskNavBarMenus.indexWhere((menu) => menu.path==target);
|
||||
if(index==-1) return null;
|
||||
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(path,keepAlive: true);
|
||||
}else{
|
||||
if (index == 1) {
|
||||
router.changePath(path, keepAlive: true);
|
||||
return;
|
||||
}
|
||||
if (index == 4) {
|
||||
router.changePath(path, style: RouteStyle.push);
|
||||
return;
|
||||
} else {
|
||||
router.changePath(path);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:iroute/components/components.dart';
|
||||
import '../../router/app_router_delegate.dart';
|
||||
import '../../router/views/route_back_indicator.dart';
|
||||
import 'app_router_editor.dart';
|
||||
import 'history_view_icon.dart';
|
||||
import 'route_history_button.dart';
|
||||
@@ -17,6 +18,7 @@ class AppTopBar extends StatelessWidget {
|
||||
child: Row(
|
||||
children: [
|
||||
const SizedBox(width: 16),
|
||||
const RouteBackIndicator(),
|
||||
const RouterIndicator(),
|
||||
Expanded(
|
||||
child: Row(children: [
|
||||
@@ -58,6 +60,7 @@ Map<String, String> kRouteLabelMap = {
|
||||
'/color/detail': '颜色详情',
|
||||
'/counter': '计数器',
|
||||
'/sort': '可视化排序算法',
|
||||
'/sort/settings': '排序配置',
|
||||
'/user': '我的',
|
||||
'/settings': '系统设置',
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user