24
This commit is contained in:
43
lib/navigation/router/routers/app.dart
Normal file
43
lib/navigation/router/routers/app.dart
Normal file
@@ -0,0 +1,43 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:iroute/v12/pages/empty/empty_panel.dart';
|
||||
|
||||
import '../../../navigation/app_navigation.dart';
|
||||
import 'dashboard.dart';
|
||||
import 'draw.dart';
|
||||
|
||||
|
||||
final RouteBase appRoute = ShellRoute(
|
||||
builder: (BuildContext context, GoRouterState state, Widget child) {
|
||||
return BookAppNavigation(content: child);
|
||||
},
|
||||
routes: <RouteBase>[
|
||||
dashboardRouters,
|
||||
drawRouters,
|
||||
// GoRoute(
|
||||
// path: 'counter',
|
||||
// builder: (BuildContext context, GoRouterState state) {
|
||||
// return const CounterPage();
|
||||
// }),
|
||||
// sortRouters,
|
||||
// GoRoute(
|
||||
// path: 'user',
|
||||
// builder: (BuildContext context, GoRouterState state) {
|
||||
// return const UserPage();
|
||||
// },
|
||||
// ),
|
||||
// GoRoute(
|
||||
// path: 'settings',
|
||||
// builder: (BuildContext context, GoRouterState state) {
|
||||
// return const SettingPage();
|
||||
// },
|
||||
// ),
|
||||
GoRoute(
|
||||
path: '/404',
|
||||
builder: (BuildContext context, GoRouterState state) {
|
||||
String msg = '无法访问: ${state.extra}';
|
||||
return EmptyPanel(msg: msg);
|
||||
},
|
||||
)
|
||||
],
|
||||
);
|
||||
32
lib/navigation/router/routers/dashboard.dart
Normal file
32
lib/navigation/router/routers/dashboard.dart
Normal file
@@ -0,0 +1,32 @@
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:iroute/pages/dashboard/chat_room.dart';
|
||||
import 'package:iroute/pages/dashboard/view_books.dart';
|
||||
|
||||
final RouteBase dashboardRouters = GoRoute(
|
||||
path: '/dashboard',
|
||||
redirect: (_,state) {
|
||||
if (state.fullPath == '/dashboard') {
|
||||
return '/dashboard/view';
|
||||
}
|
||||
return null;
|
||||
},
|
||||
routes: <RouteBase>[
|
||||
GoRoute(
|
||||
path: 'view',
|
||||
builder: (BuildContext context, GoRouterState state) {
|
||||
return const ViewBooks();
|
||||
},
|
||||
),
|
||||
GoRoute(
|
||||
path: 'chat/:roomId',
|
||||
builder: (BuildContext context, GoRouterState state) {
|
||||
String? roomId = state.pathParameters['roomId'];
|
||||
return ChatRoom(
|
||||
roomId: roomId,
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
47
lib/navigation/router/routers/draw.dart
Normal file
47
lib/navigation/router/routers/draw.dart
Normal file
@@ -0,0 +1,47 @@
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:idraw/idraw.dart';
|
||||
import 'package:iroute/pages/dashboard/chat_room.dart';
|
||||
|
||||
|
||||
final RouteBase drawRouters = GoRoute(
|
||||
path: '/draw',
|
||||
redirect: (_,state) {
|
||||
if (state.fullPath == '/draw') {
|
||||
return '/draw/chapter1';
|
||||
}
|
||||
return null;
|
||||
},
|
||||
routes: <RouteBase>[
|
||||
GoRoute(
|
||||
path: 'chapter1',
|
||||
builder: (BuildContext context, GoRouterState state) {
|
||||
return const P01Page();
|
||||
},
|
||||
),
|
||||
GoRoute(
|
||||
path: 'chapter2',
|
||||
builder: (BuildContext context, GoRouterState state) {
|
||||
return const P02Page();
|
||||
},
|
||||
),
|
||||
GoRoute(
|
||||
path: 'chapter3',
|
||||
builder: (BuildContext context, GoRouterState state) {
|
||||
return const P03Page();
|
||||
},
|
||||
),
|
||||
GoRoute(
|
||||
path: 'chapter4',
|
||||
builder: (BuildContext context, GoRouterState state) {
|
||||
return const P04Page();
|
||||
},
|
||||
), GoRoute(
|
||||
path: 'chapter5',
|
||||
builder: (BuildContext context, GoRouterState state) {
|
||||
return const P05Page();
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
Reference in New Issue
Block a user