Skip to content

Commit 41049f0

Browse files
committed
Merge remote-tracking branch 'origin/master'
2 parents 49eb9ec + f875c13 commit 41049f0

14 files changed

Lines changed: 418 additions & 25 deletions

‎lib/common/dao/ReposDao.dart‎

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,4 +348,51 @@ class ReposDao {
348348
}
349349
return new DataResult(null, false);
350350
}
351+
352+
/**
353+
* 搜索仓库
354+
* @param q 搜索关键字
355+
* @param sort 分类排序,beat match、most star等
356+
* @param order 倒序或者正序
357+
* @param type 搜索类型,人或者仓库 null \ 'user',
358+
* @param page
359+
* @param pageSize
360+
*/
361+
static searchRepositoryDao(q, language, sort, order, type, page, pageSize) async {
362+
if (language != null) {
363+
q = q + "%2Blanguage%3A$language";
364+
}
365+
String url = Address.search(q, sort, order, type, page, pageSize);
366+
var res = await HttpManager.netFetch(url, null, null, null);
367+
if (type == null) {
368+
if (res != null && res.result && res.data["items"] != null) {
369+
List<ReposViewModel> list = new List();
370+
var dataList = res.data["items"];
371+
if (dataList == null || dataList.length == 0) {
372+
return new DataResult(null, false);
373+
}
374+
for (int i = 0; i < dataList.length; i++) {
375+
var data = dataList[i];
376+
list.add(ReposViewModel.fromMap(data));
377+
}
378+
return new DataResult(list, true);
379+
} else {
380+
return new DataResult(null, false);
381+
}
382+
} else {
383+
if (res != null && res.result && res.data["items"] != null) {
384+
List<UserItemViewModel> list = new List();
385+
var data = res.data["items"];
386+
if (data == null || data.length == 0) {
387+
return new DataResult(null, false);
388+
}
389+
for (int i = 0; i < data.length; i++) {
390+
list.add(new UserItemViewModel(data[i]['login'], data[i]["avatar_url"]));
391+
}
392+
return new DataResult(list, true);
393+
} else {
394+
return new DataResult(null, false);
395+
}
396+
}
397+
}
351398
}

‎lib/common/style/GSYStyle.dart‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
22

33
///颜色
44
class GSYColors {
5+
static const String primaryValueString = "#24292E";
56
static const int primaryValue = 0xFF24292E;
67
static const int primaryLightValue = 0xFF42464b;
78
static const int primaryDarkValue = 0xFF121917;
@@ -260,14 +261,24 @@ class GSYStrings {
260261
static const String notify_status = "状态";
261262
static const String notify_type = "类型";
262263

264+
static const String search_title = "搜索";
265+
static const String search_tab_repos = "仓库";
266+
static const String search_tab_user = "用户";
267+
263268
}
264269

265270
class GSYICons {
266271
static const String FONT_FAMILY = 'wxcIconFont';
267272

273+
static const IconData HOME = const IconData(0xe624, fontFamily: GSYICons.FONT_FAMILY);
274+
268275
static const IconData MAIN_DT = const IconData(0xe684, fontFamily: GSYICons.FONT_FAMILY);
269276
static const IconData MAIN_QS = const IconData(0xe818, fontFamily: GSYICons.FONT_FAMILY);
270277
static const IconData MAIN_MY = const IconData(0xe6d0, fontFamily: GSYICons.FONT_FAMILY);
278+
static const IconData MAIN_SEARCH = const IconData(0xe61c, fontFamily: GSYICons.FONT_FAMILY);
279+
280+
static const IconData LOGIN_USER = const IconData(0xe666, fontFamily: GSYICons.FONT_FAMILY);
281+
static const IconData LOGIN_PW = const IconData(0xe60e, fontFamily: GSYICons.FONT_FAMILY);
271282

272283
static const IconData REPOS_ITEM_USER = const IconData(0xe63e, fontFamily: GSYICons.FONT_FAMILY);
273284
static const IconData REPOS_ITEM_STAR = const IconData(0xe643, fontFamily: GSYICons.FONT_FAMILY);

‎lib/common/utils/EventUtils.dart‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ class EventUtils {
155155
break;
156156
case 'IssueCommentEvent':
157157
case 'IssuesEvent':
158-
NavigatorUtils.goIssueDetail(context, owner, repositoryName, event["payload"]["issue"]["number"].toString());
158+
NavigatorUtils.goIssueDetail(context, owner, repositoryName, event["payload"]["issue"]["number"].toString(), needRightIcon: true);
159159
break;
160160
default:
161161
if (fullName.toLowerCase() == currentRepository.toLowerCase()) {

‎lib/common/utils/NavigatorUtils.dart‎

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import 'package:gsy_github_app_flutter/page/LoginPage.dart';
99
import 'package:gsy_github_app_flutter/page/NotifyPage.dart';
1010
import 'package:gsy_github_app_flutter/page/PersonPage.dart';
1111
import 'package:gsy_github_app_flutter/page/RepositoryDetailPage.dart';
12+
import 'package:gsy_github_app_flutter/page/SearchPage.dart';
1213

1314
/**
1415
* 导航栏
@@ -47,8 +48,16 @@ class NavigatorUtils {
4748
}
4849

4950
///issue详情
50-
static Future<Null> goIssueDetail(BuildContext context, String userName, String reposName, String num) {
51-
return Navigator.push(context, new MaterialPageRoute(builder: (context) => new IssueDetailPage(userName, reposName, num)));
51+
static Future<Null> goIssueDetail(BuildContext context, String userName, String reposName, String num, {bool needRightIcon = false}) {
52+
return Navigator.push(
53+
context,
54+
new MaterialPageRoute(
55+
builder: (context) => new IssueDetailPage(
56+
userName,
57+
reposName,
58+
num,
59+
needRightIcon: needRightIcon,
60+
)));
5261
}
5362

5463
///通用列表
@@ -84,4 +93,11 @@ class NavigatorUtils {
8493
static Future<Null> goNotifyPage(BuildContext context) {
8594
return Navigator.push(context, new MaterialPageRoute(builder: (context) => new NotifyPage()));
8695
}
96+
97+
///搜索
98+
static Future<Null> goSearchPage(BuildContext context) {
99+
return Navigator.push(context, new MaterialPageRoute(builder: (context) => new SearchPage()));
100+
}
101+
102+
87103
}

‎lib/main.dart‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ class FlutterReduxApp extends StatelessWidget {
2424
return new StoreProvider(
2525
store: store,
2626
child: new MaterialApp(
27-
title: 'Flutter Demo',
2827
theme: new ThemeData(
2928
primarySwatch: GSYColors.primarySwatch,
3029
),

‎lib/page/HomePage.dart‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
import 'package:flutter/material.dart';
22
import 'package:gsy_github_app_flutter/common/style/GSYStyle.dart';
3+
import 'package:gsy_github_app_flutter/common/utils/NavigatorUtils.dart';
34
import 'package:gsy_github_app_flutter/page/DynamicPage.dart';
45
import 'package:gsy_github_app_flutter/page/MyPage.dart';
56
import 'package:gsy_github_app_flutter/page/TrendPage.dart';
67
import 'package:gsy_github_app_flutter/widget/GSYTabBarWidget.dart';
8+
import 'package:gsy_github_app_flutter/widget/GSYTitleBar.dart';
79
import 'package:gsy_github_app_flutter/widget/HomeDrawer.dart';
810

911
/**
@@ -47,6 +49,13 @@ class HomePage extends StatelessWidget {
4749
],
4850
backgroundColor: GSYColors.primarySwatch,
4951
indicatorColor: Colors.white,
50-
title: GSYStrings.app_name);
52+
title: GSYTitleBar(
53+
GSYStrings.app_name,
54+
iconData: GSYICons.MAIN_SEARCH,
55+
needRightIcon: true,
56+
onPressed: () {
57+
NavigatorUtils.goSearchPage(context);
58+
},
59+
));
5160
}
5261
}

‎lib/page/IssueDetailPage.dart‎

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@ import 'package:fluttertoast/fluttertoast.dart';
33
import 'package:gsy_github_app_flutter/common/dao/IssueDao.dart';
44
import 'package:gsy_github_app_flutter/common/style/GSYStyle.dart';
55
import 'package:gsy_github_app_flutter/common/utils/CommonUtils.dart';
6+
import 'package:gsy_github_app_flutter/common/utils/NavigatorUtils.dart';
67
import 'package:gsy_github_app_flutter/widget/GSYFlexButton.dart';
78
import 'package:gsy_github_app_flutter/widget/GSYListState.dart';
89
import 'package:gsy_github_app_flutter/widget/GSYPullLoadWidget.dart';
10+
import 'package:gsy_github_app_flutter/widget/GSYTitleBar.dart';
911
import 'package:gsy_github_app_flutter/widget/IssueHeaderItem.dart';
1012
import 'package:gsy_github_app_flutter/widget/IssueItem.dart';
1113

@@ -21,10 +23,12 @@ class IssueDetailPage extends StatefulWidget {
2123

2224
final String issueNum;
2325

24-
IssueDetailPage(this.userName, this.reposName, this.issueNum);
26+
final bool needRightIcon;
27+
28+
IssueDetailPage(this.userName, this.reposName, this.issueNum, {this.needRightIcon = false});
2529

2630
@override
27-
_IssueDetailPageState createState() => _IssueDetailPageState(issueNum, userName, reposName);
31+
_IssueDetailPageState createState() => _IssueDetailPageState(issueNum, userName, reposName, needRightIcon);
2832
}
2933

3034
// ignore: mixin_inherits_from_not_object
@@ -39,6 +43,8 @@ class _IssueDetailPageState extends GSYListState<IssueDetailPage> {
3943

4044
bool headerStatus = false;
4145

46+
bool needRightIcon = false;
47+
4248
IssueHeaderViewModel issueHeaderViewModel = new IssueHeaderViewModel();
4349

4450
TextEditingController issueInfoTitleControl = new TextEditingController();
@@ -47,7 +53,7 @@ class _IssueDetailPageState extends GSYListState<IssueDetailPage> {
4753

4854
TextEditingController issueInfoCommitValueControl = new TextEditingController();
4955

50-
_IssueDetailPageState(this.issueNum, this.userName, this.reposName);
56+
_IssueDetailPageState(this.issueNum, this.userName, this.reposName, this.needRightIcon);
5157

5258
_renderEventItem(index) {
5359
if (index == 0) {
@@ -277,11 +283,15 @@ class _IssueDetailPageState extends GSYListState<IssueDetailPage> {
277283
return new Scaffold(
278284
persistentFooterButtons: _getBottomWidget(),
279285
appBar: new AppBar(
280-
title: new Text(
281-
reposName,
282-
maxLines: 1,
283-
overflow: TextOverflow.ellipsis,
284-
)),
286+
title: GSYTitleBar(
287+
reposName,
288+
needRightIcon: needRightIcon,
289+
iconData: GSYICons.HOME,
290+
onPressed: () {
291+
NavigatorUtils.goReposDetail(context, userName, reposName);
292+
},
293+
),
294+
),
285295
body: GSYPullLoadWidget(
286296
pullLoadWidgetControl,
287297
(BuildContext context, int index) => _renderEventItem(index),

‎lib/page/LoginPage.dart‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ class _LoginPageState extends State<LoginPage> {
7070
new Padding(padding: new EdgeInsets.all(10.0)),
7171
new GSYInputWidget(
7272
hintText: GSYStrings.login_username_hint_text,
73-
iconData: Icons.access_alarm,
73+
iconData: GSYICons.LOGIN_USER,
7474
onChanged: (String value) {
7575
_userName = value;
7676
},
@@ -79,7 +79,7 @@ class _LoginPageState extends State<LoginPage> {
7979
new Padding(padding: new EdgeInsets.all(10.0)),
8080
new GSYInputWidget(
8181
hintText: GSYStrings.login_password_hint_text,
82-
iconData: Icons.access_alarm,
82+
iconData: GSYICons.LOGIN_PW,
8383
obscureText: true,
8484
onChanged: (String value) {
8585
_password = value;

‎lib/page/NotifyPage.dart‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class _NotifyPageState extends GSYListState<NotifyPage> {
3939
String number = tmp[tmp.length - 1];
4040
String userName = eventMap["repository"]["owner"]["login"];
4141
String reposName = eventMap["repository"]["name"];
42-
NavigatorUtils.goIssueDetail(context, userName, reposName, number).then((res) {
42+
NavigatorUtils.goIssueDetail(context, userName, reposName, number, needRightIcon: true).then((res) {
4343
showRefreshLoading();
4444
});
4545
}

‎lib/page/RepositoryDetailPage.dart‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import 'package:gsy_github_app_flutter/page/RepositoryFileListPage.dart';
99
import 'package:gsy_github_app_flutter/page/RepostoryDetailInfoPage.dart';
1010
import 'package:gsy_github_app_flutter/widget/GSYIConText.dart';
1111
import 'package:gsy_github_app_flutter/widget/GSYTabBarWidget.dart';
12+
import 'package:gsy_github_app_flutter/widget/GSYTitleBar.dart';
1213
import 'package:gsy_github_app_flutter/widget/ReposHeaderItem.dart';
1314

1415
/**
@@ -237,7 +238,7 @@ class _RepositoryDetailPageState extends State<RepositoryDetailPage> {
237238
],
238239
backgroundColor: GSYColors.primarySwatch,
239240
indicatorColor: Colors.white,
240-
title: reposName);
241+
title: new GSYTitleBar(reposName));
241242
}
242243
}
243244

0 commit comments

Comments
 (0)