forked from CarGuo/gsy_github_app_flutter
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnavigator_utils.dart
More file actions
248 lines (223 loc) · 6.93 KB
/
navigator_utils.dart
File metadata and controls
248 lines (223 loc) · 6.93 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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
import 'dart:async';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:gsy_github_app_flutter/common/router/size_route.dart';
import 'package:gsy_github_app_flutter/page/code_detail_page.dart';
import 'package:gsy_github_app_flutter/page/code_detail_page_web.dart';
import 'package:gsy_github_app_flutter/page/common_list_page.dart';
import 'package:gsy_github_app_flutter/page/gsy_webview.dart';
import 'package:gsy_github_app_flutter/page/home_page.dart';
import 'package:gsy_github_app_flutter/page/honor_list_page.dart';
import 'package:gsy_github_app_flutter/page/issue_detail_page.dart';
import 'package:gsy_github_app_flutter/page/login_page.dart';
import 'package:gsy_github_app_flutter/page/notify_page.dart';
import 'package:gsy_github_app_flutter/page/person_page.dart';
import 'package:gsy_github_app_flutter/page/photoview_page.dart';
import 'package:gsy_github_app_flutter/page/push_detail_page.dart';
import 'package:gsy_github_app_flutter/page/release_page.dart';
import 'package:gsy_github_app_flutter/page/repository_detail_page.dart';
import 'package:gsy_github_app_flutter/page/search_page.dart';
import 'package:gsy_github_app_flutter/page/user_profile_page.dart';
/**
* 导航栏
* Created by guoshuyu
* Date: 2018-07-16
*/
class NavigatorUtils {
///替换
static pushReplacementNamed(BuildContext context, String routeName) {
Navigator.pushReplacementNamed(context, routeName);
}
///切换无参数页面
static pushNamed(BuildContext context, String routeName) {
Navigator.pushNamed(context, routeName);
}
///主页
static goHome(BuildContext context) {
Navigator.pushReplacementNamed(context, HomePage.sName);
}
///登录页
static goLogin(BuildContext context) {
Navigator.pushReplacementNamed(context, LoginPage.sName);
}
///个人中心
static goPerson(BuildContext context, String userName) {
NavigatorRouter(context, new PersonPage(userName));
}
///仓库详情
static Future goReposDetail(
BuildContext context, String userName, String reposName) {
///利用 SizeRoute 动画大小打开
return Navigator.push(
context,
new SizeRoute(
widget: pageContainer(RepositoryDetailPage(userName, reposName))));
}
///荣耀列表
static Future goHonorListPage(BuildContext context, List list) {
return Navigator.push(
context, new SizeRoute(widget: pageContainer(HonorListPage(list))));
}
///仓库版本列表
static Future goReleasePage(BuildContext context, String userName,
String reposName, String releaseUrl, String tagUrl) {
return NavigatorRouter(
context,
new ReleasePage(
userName,
reposName,
releaseUrl,
tagUrl,
));
}
///issue详情
static Future goIssueDetail(
BuildContext context, String userName, String reposName, String num,
{bool needRightLocalIcon = false}) {
return NavigatorRouter(
context,
new IssueDetailPage(
userName,
reposName,
num,
needHomeIcon: needRightLocalIcon,
));
}
///通用列表
static gotoCommonList(
BuildContext context, String title, String showType, String dataType,
{String userName, String reposName}) {
NavigatorRouter(
context,
new CommonListPage(
title,
showType,
dataType,
userName: userName,
reposName: reposName,
));
}
///文件代码详情
static gotoCodeDetailPage(BuildContext context,
{String title,
String userName,
String reposName,
String path,
String data,
String branch,
String htmlUrl}) {
NavigatorRouter(
context,
new CodeDetailPage(
title: title,
userName: userName,
reposName: reposName,
path: path,
data: data,
branch: branch,
htmlUrl: htmlUrl,
));
}
///仓库详情通知
static Future goNotifyPage(BuildContext context) {
return NavigatorRouter(context, new NotifyPage());
}
///搜索
static Future goSearchPage(BuildContext context) {
return NavigatorRouter(context, new SearchPage());
}
///提交详情
static Future goPushDetailPage(BuildContext context, String userName,
String reposName, String sha, bool needHomeIcon) {
return NavigatorRouter(
context,
new PushDetailPage(
sha,
userName,
reposName,
needHomeIcon: needHomeIcon,
));
}
///全屏Web页面
static Future goGSYWebView(BuildContext context, String url, String title) {
return NavigatorRouter(context, new GSYWebView(url, title));
}
///文件代码详情Web
static gotoCodeDetailPageWeb(BuildContext context,
{String title,
String userName,
String reposName,
String path,
String data,
String branch,
String htmlUrl}) {
NavigatorRouter(
context,
new CodeDetailPageWeb(
title: title,
userName: userName,
reposName: reposName,
path: path,
data: data,
branch: branch,
htmlUrl: htmlUrl,
));
}
///根据平台跳转文件代码详情Web
static gotoCodeDetailPlatform(BuildContext context,
{String title,
String userName,
String reposName,
String path,
String data,
String branch,
String htmlUrl}) {
NavigatorUtils.gotoCodeDetailPageWeb(
context,
title: title,
reposName: reposName,
userName: userName,
data: data,
path: path,
branch: branch,
);
}
///图片预览
static gotoPhotoViewPage(BuildContext context, String url) {
NavigatorRouter(context, new PhotoViewPage(url));
}
///用户配置
static gotoUserProfileInfo(BuildContext context) {
NavigatorRouter(context, new UserProfileInfo());
}
///公共打开方式
static NavigatorRouter(BuildContext context, Widget widget) {
return Navigator.push(context,
new CupertinoPageRoute(builder: (context) => pageContainer(widget)));
}
///Page页面的容器,做一次通用自定义
static Widget pageContainer(widget) {
return MediaQuery(
///不受系统字体缩放影响
data: MediaQueryData.fromWindow(WidgetsBinding.instance.window)
.copyWith(textScaleFactor: 1),
child: widget);
}
///弹出 dialog
static Future<T> showGSYDialog<T>({
@required BuildContext context,
bool barrierDismissible = true,
WidgetBuilder builder,
}) {
return showDialog<T>(
context: context,
barrierDismissible: barrierDismissible,
builder: (context) {
return MediaQuery(
///不受系统字体缩放影响
data: MediaQueryData.fromWindow(WidgetsBinding.instance.window)
.copyWith(textScaleFactor: 1),
child: new SafeArea(child: builder(context)));
});
}
}