Skip to content

Commit 693b364

Browse files
committed
增加topic 跳转
1 parent d443e3a commit 693b364

File tree

4 files changed

+38
-10
lines changed

4 files changed

+38
-10
lines changed

VERSION.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
* 增加fork仓库跳转到原仓库
2020
* 增加仓库点击展示 issue 状态信息
2121
* 增加个人状态信息可跳转
22+
* 增加仓库Topic显示
2223

2324
### 1.0.6
2425
* trend修改为redux

lib/common/dao/ReposDao.dart

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -608,10 +608,10 @@ class ReposDao {
608608
: Address.getReposTag(userName, reposName) + Address.getPageParams("?", page);
609609

610610
var res = await HttpManager.netFetch(
611-
url,
612-
null,
613-
{"Accept": (needHtml ? 'application/vnd.github.html,application/vnd.github.VERSION.raw' : "")},
614-
null,
611+
url,
612+
null,
613+
{"Accept": (needHtml ? 'application/vnd.github.html,application/vnd.github.VERSION.raw' : "")},
614+
null
615615
);
616616
if (res != null && res.result && res.data.length > 0) {
617617
List<Release> list = new List();
@@ -691,6 +691,31 @@ class ReposDao {
691691
return new DataResult(null, false);
692692
}
693693

694+
/**
695+
* 搜索话题
696+
*/
697+
static searchTopicRepositoryDao(searchTopic, {page = 0}) async {
698+
String url = Address.searchTopic(searchTopic) + Address.getPageParams("&", page);
699+
var res = await HttpManager.netFetch(url, null, null, null);
700+
var data = (res.data != null && res.data["items"] != null) ? res.data["items"] : res.data;
701+
if (res != null && res.result && data != null && data.length > 0) {
702+
List<Repository> list = new List();
703+
var dataList = data;
704+
if (dataList == null || dataList.length == 0) {
705+
return new DataResult(null, false);
706+
}
707+
for (int i = 0; i < dataList.length; i++) {
708+
var data = dataList[i];
709+
list.add(Repository.fromJson(data));
710+
}
711+
return new DataResult(list, true);
712+
} else {
713+
return new DataResult(null, false);
714+
}
715+
}
716+
717+
718+
694719
/**
695720
* 获取阅读历史
696721
*/

lib/page/CommonListPage.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ class _CommonListPageState extends GSYListState<CommonListPage> {
9595
case 'history':
9696
return await ReposDao.getHistoryDao(page);
9797
case 'topics':
98-
return null;
98+
return await ReposDao.searchTopicRepositoryDao(userName, page: page);
9999
case 'user_be_stared':
100100
return null;
101101
case 'user_orgs':

lib/widget/ReposHeaderItem.dart

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,11 @@ class ReposHeaderItem extends StatelessWidget {
4040
);
4141
}
4242

43-
_renderTopicItem(String item) {
43+
_renderTopicItem(BuildContext context, String item) {
4444
return new RawMaterialButton(
45-
onPressed: () {},
45+
onPressed: () {
46+
NavigatorUtils.gotoCommonList(context, item, "repository", "topics", userName: item, reposName: "");
47+
},
4648
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
4749
padding: const EdgeInsets.all(0.0),
4850
constraints: const BoxConstraints(minWidth: 0.0, minHeight: 0.0),
@@ -61,13 +63,13 @@ class ReposHeaderItem extends StatelessWidget {
6163
}
6264

6365
///话题组控件
64-
_renderTopicGroup() {
66+
_renderTopicGroup(BuildContext context) {
6567
if (reposHeaderViewModel.topics == null || reposHeaderViewModel.topics.length == 0) {
6668
return Container();
6769
}
6870
List<Widget> list = new List();
6971
for (String item in reposHeaderViewModel.topics) {
70-
list.add(_renderTopicItem(item));
72+
list.add(_renderTopicItem(context, item));
7173
}
7274
return new Container(
7375
alignment: Alignment.topLeft,
@@ -232,7 +234,7 @@ class ReposHeaderItem extends StatelessWidget {
232234
),
233235
],
234236
)),
235-
_renderTopicGroup(),
237+
_renderTopicGroup(context),
236238
],
237239
),
238240
),

0 commit comments

Comments
 (0)