This commit is contained in:
toly
2023-12-10 15:25:12 +08:00
parent 2ceed8b9b5
commit 7b16b52761
86 changed files with 3635 additions and 930 deletions

View File

@@ -1,10 +1,6 @@
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
import 'package:iroute/components/components.dart';
import 'package:provider/provider.dart';
import '../../../pages/sort/provider/state.dart';
import '../router/app_router_delegate.dart';
import '../router/iroute_config.dart';
import '../router/routes.dart';
class AppNavigationRail extends StatefulWidget {
const AppNavigationRail({super.key});
@@ -14,18 +10,14 @@ 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'),
];
@override
void initState() {
super.initState();
router.addListener(_onRouterChange);
}
@override
void dispose() {
router.removeListener(_onRouterChange);
super.dispose();
}
@override
Widget build(BuildContext context) {
@@ -39,7 +31,7 @@ class _AppNavigationRailState extends State<AppNavigationRail> {
tail: Padding(
padding: const EdgeInsets.only(bottom: 6.0),
child: Text(
'V0.0.11',
'V0.1.1',
style: TextStyle(color: Colors.white, fontSize: 12),
),
),
@@ -50,10 +42,10 @@ class _AppNavigationRailState extends State<AppNavigationRail> {
);
}
RegExp _segReg = RegExp(r'/app/\w+');
final RegExp _segReg = RegExp(r'/\w+');
int? get activeIndex {
String path = router.path;
final String path = GoRouterState.of(context).uri.toString();
RegExpMatch? match = _segReg.firstMatch(path);
if (match == null) return null;
String? target = match.group(0);
@@ -64,25 +56,10 @@ class _AppNavigationRailState extends State<AppNavigationRail> {
void _onDestinationSelected(int index) {
String path = deskNavBarMenus[index].path!;
if (index == 1) {
router.changePath(path, keepAlive: true,recordHistory: true);
return;
if(index==4){
GoRouter.of(context).push(path);
}else{
GoRouter.of(context).go(path);
}
if(index ==2){
SortState state = SortStateScope.read(context);
String name = state.config.name;
router.changePath('/app/sort/$name',recordHistory: true);
return;
}
if (index == 4) {
router.changePath(path, style: RouteStyle.push,recordHistory: true);
return;
} else {
router.changePath(path,recordHistory: true);
}
}
void _onRouterChange() {
setState(() {});
}
}