routes.dart
3.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
import 'dart:io';
import 'package:appframe/ui/pages/adv_page.dart';
import 'package:appframe/ui/pages/im_page.dart';
import 'package:appframe/ui/pages/link_page.dart';
import 'package:appframe/ui/pages/login_main_page.dart';
import 'package:appframe/ui/pages/login_phone_page.dart';
import 'package:appframe/ui/pages/login_qr_page.dart';
import 'package:appframe/ui/pages/reload_page.dart';
import 'package:appframe/ui/pages/scan_code_page.dart';
import 'package:appframe/ui/pages/setting/account_page.dart';
import 'package:appframe/ui/pages/setting/account_phone_page.dart';
import 'package:appframe/ui/pages/web_page.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
// iOS平台使用Cupertino转场动画以支持侧滑返回手势
Page<dynamic> _buildPageWithTransition({
required Widget child,
required GoRouterState state,
}) {
if (Platform.isIOS) {
return CupertinoPage(
key: state.pageKey,
child: child,
);
}
return MaterialPage(
key: state.pageKey,
child: child,
);
}
final GoRouter router = GoRouter(
initialLocation: '/web',
routes: <RouteBase>[
GoRoute(
path: '/web',
pageBuilder: (BuildContext context, GoRouterState state) {
return _buildPageWithTransition(
child: const WebPage(),
state: state,
);
},
),
GoRoute(
path: '/scanCode',
pageBuilder: (BuildContext context, GoRouterState state) {
return _buildPageWithTransition(
child: const ScanCodePage(),
state: state,
);
},
),
GoRoute(
path: '/link',
pageBuilder: (BuildContext context, GoRouterState state) {
return _buildPageWithTransition(
child: const LinkPage(),
state: state,
);
},
),
GoRoute(
path: '/loginMain',
pageBuilder: (BuildContext context, GoRouterState state) {
return _buildPageWithTransition(
child: const LoginMainPage(),
state: state,
);
},
),
GoRoute(
path: '/loginPhone',
pageBuilder: (BuildContext context, GoRouterState state) {
return _buildPageWithTransition(
child: const LoginPhonePage(),
state: state,
);
},
),
GoRoute(
path: '/loginQr',
pageBuilder: (BuildContext context, GoRouterState state) {
return _buildPageWithTransition(
child: const LoginQrPage(),
state: state,
);
},
),
GoRoute(
path: '/account',
pageBuilder: (BuildContext context, GoRouterState state) {
return _buildPageWithTransition(
child: const AccountPage(),
state: state,
);
},
),
GoRoute(
path: '/account/phone',
pageBuilder: (BuildContext context, GoRouterState state) {
return _buildPageWithTransition(
child: const AccountPhonePage(),
state: state,
);
},
),
GoRoute(
path: '/adv',
pageBuilder: (BuildContext context, GoRouterState state) {
return _buildPageWithTransition(
child: const AdvPage(),
state: state,
);
},
),
GoRoute(
path: '/im',
pageBuilder: (BuildContext context, GoRouterState state) {
return _buildPageWithTransition(
child: const ImPage(),
state: state,
);
},
),
GoRoute(
path: '/reload',
pageBuilder: (BuildContext context, GoRouterState state) {
return _buildPageWithTransition(
child: const ReloadPage(),
state: state,
);
},
),
],
);