Skip to content

Commit bb1a920

Browse files
committed
统一跳转
1 parent f237ccd commit bb1a920

File tree

1 file changed

+39
-63
lines changed

1 file changed

+39
-63
lines changed
Lines changed: 39 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import 'dart:async';
2-
import 'dart:io';
32

43
import 'package:flutter/cupertino.dart';
54
import 'package:flutter/material.dart';
@@ -46,144 +45,115 @@ class NavigatorUtils {
4645

4746
///个人中心
4847
static goPerson(BuildContext context, String userName) {
49-
Navigator.push(context, new CupertinoPageRoute(builder: (context) => new PersonPage(userName)));
48+
NavigatorRouter(context, new PersonPage(userName));
5049
}
5150

5251
///仓库详情
53-
static Future<Null> goReposDetail(BuildContext context, String userName, String reposName) {
54-
return Navigator.push(context, new CupertinoPageRoute(builder: (context) => new RepositoryDetailPage(userName, reposName)));
52+
static Future goReposDetail(BuildContext context, String userName, String reposName) {
53+
return NavigatorRouter(context, RepositoryDetailPage(userName, reposName));
5554
}
5655

5756
///仓库版本列表
58-
static Future<Null> goReleasePage(BuildContext context, String userName, String reposName, String releaseUrl, String tagUrl) {
59-
return Navigator.push(
57+
static Future goReleasePage(BuildContext context, String userName, String reposName, String releaseUrl, String tagUrl) {
58+
return NavigatorRouter(
6059
context,
61-
new CupertinoPageRoute(
62-
builder: (context) => new ReleasePage(
60+
new ReleasePage(
6361
userName,
6462
reposName,
6563
releaseUrl,
6664
tagUrl,
67-
)));
65+
));
6866
}
6967

7068
///issue详情
71-
static Future<Null> goIssueDetail(BuildContext context, String userName, String reposName, String num, {bool needRightLocalIcon = false}) {
72-
return Navigator.push(
69+
static Future goIssueDetail(BuildContext context, String userName, String reposName, String num, {bool needRightLocalIcon = false}) {
70+
return NavigatorRouter(
7371
context,
74-
new CupertinoPageRoute(
75-
builder: (context) => new IssueDetailPage(
72+
new IssueDetailPage(
7673
userName,
7774
reposName,
7875
num,
7976
needHomeIcon: needRightLocalIcon,
80-
)));
77+
));
8178
}
8279

8380
///通用列表
8481
static gotoCommonList(BuildContext context, String title, String showType, String dataType, {String userName, String reposName}) {
85-
Navigator.push(
82+
NavigatorRouter(
8683
context,
87-
new CupertinoPageRoute(
88-
builder: (context) => new CommonListPage(
84+
new CommonListPage(
8985
title,
9086
showType,
9187
dataType,
9288
userName: userName,
9389
reposName: reposName,
94-
)));
90+
));
9591
}
9692

9793
///文件代码详情
9894
static gotoCodeDetailPage(BuildContext context,
9995
{String title, String userName, String reposName, String path, String data, String branch, String htmlUrl}) {
100-
Navigator.push(
96+
NavigatorRouter(
10197
context,
102-
new CupertinoPageRoute(
103-
builder: (context) => new CodeDetailPage(
98+
new CodeDetailPage(
10499
title: title,
105100
userName: userName,
106101
reposName: reposName,
107102
path: path,
108103
data: data,
109104
branch: branch,
110105
htmlUrl: htmlUrl,
111-
)));
106+
));
112107
}
113108

114109
///仓库详情通知
115-
static Future<Null> goNotifyPage(BuildContext context) {
116-
return Navigator.push(context, new CupertinoPageRoute(builder: (context) => new NotifyPage()));
110+
static Future goNotifyPage(BuildContext context) {
111+
return NavigatorRouter(context, new NotifyPage());
117112
}
118113

119114
///搜索
120-
static Future<Null> goSearchPage(BuildContext context) {
121-
return Navigator.push(context, new CupertinoPageRoute(builder: (context) => new SearchPage()));
115+
static Future goSearchPage(BuildContext context) {
116+
return NavigatorRouter(context, new SearchPage());
122117
}
123118

124119
///提交详情
125-
static Future<Null> goPushDetailPage(BuildContext context, String userName, String reposName, String sha, bool needHomeIcon) {
126-
return Navigator.push(
120+
static Future goPushDetailPage(BuildContext context, String userName, String reposName, String sha, bool needHomeIcon) {
121+
return NavigatorRouter(
127122
context,
128-
new CupertinoPageRoute(
129-
builder: (context) => new PushDetailPage(
123+
new PushDetailPage(
130124
sha,
131125
userName,
132126
reposName,
133127
needHomeIcon: needHomeIcon,
134-
)));
128+
));
135129
}
136130

137131
///全屏Web页面
138-
static Future<Null> goGSYWebView(BuildContext context, String url, String title) {
139-
return Navigator.push(
132+
static Future goGSYWebView(BuildContext context, String url, String title) {
133+
return NavigatorRouter(
140134
context,
141-
new CupertinoPageRoute(
142-
builder: (context) => new GSYWebView(url, title),
143-
),
135+
new GSYWebView(url, title)
144136
);
145137
}
146138

147139
///文件代码详情Web
148140
static gotoCodeDetailPageWeb(BuildContext context,
149141
{String title, String userName, String reposName, String path, String data, String branch, String htmlUrl}) {
150-
Navigator.push(
151-
context,
152-
new CupertinoPageRoute(
153-
builder: (context) => new CodeDetailPageWeb(
142+
NavigatorRouter(
143+
context, new CodeDetailPageWeb(
154144
title: title,
155145
userName: userName,
156146
reposName: reposName,
157147
path: path,
158148
data: data,
159149
branch: branch,
160150
htmlUrl: htmlUrl,
161-
)));
151+
));
162152
}
163153

164154
///根据平台跳转文件代码详情Web
165155
static gotoCodeDetailPlatform(BuildContext context,
166156
{String title, String userName, String reposName, String path, String data, String branch, String htmlUrl}) {
167-
/*if (Platform.isIOS) {
168-
NavigatorUtils.gotoCodeDetailPage(
169-
context,
170-
title: title,
171-
reposName: reposName,
172-
userName: userName,
173-
path: path,
174-
branch: branch,
175-
);
176-
} else {
177-
NavigatorUtils.gotoCodeDetailPageWeb(
178-
context,
179-
title: title,
180-
reposName: reposName,
181-
userName: userName,
182-
path: path,
183-
branch: branch,
184-
);
185-
}
186-
*/
187157
NavigatorUtils.gotoCodeDetailPageWeb(
188158
context,
189159
title: title,
@@ -196,11 +166,17 @@ class NavigatorUtils {
196166

197167
///图片预览
198168
static gotoPhotoViewPage(BuildContext context, String url) {
199-
Navigator.push(context, new CupertinoPageRoute(builder: (context) => new PhotoViewPage(url)));
169+
NavigatorRouter(context, new PhotoViewPage(url));
200170
}
201171

202172
///用户配置
203173
static gotoUserProfileInfo(BuildContext context) {
204-
Navigator.push(context, new CupertinoPageRoute(builder: (context) => new UserProfileInfo()));
174+
NavigatorRouter(context, new UserProfileInfo());
205175
}
176+
177+
178+
static NavigatorRouter(BuildContext context, Widget widget) {
179+
return Navigator.push(context, new CupertinoPageRoute(builder: (context) => widget));
180+
}
181+
206182
}

0 commit comments

Comments
 (0)