Skip to content

Commit 968aaed

Browse files
committed
branch
1 parent 1744373 commit 968aaed

6 files changed

Lines changed: 59 additions & 33 deletions

File tree

‎lib/common/dao/ReposDao.dart‎

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,10 @@ class ReposDao {
5555
/**
5656
* 仓库的详情数据
5757
*/
58-
static getRepositoryDetailDao(userName, reposName) async {
59-
String url = Address.getReposDetail(userName, reposName);
58+
static getRepositoryDetailDao(userName, reposName, branch) async {
59+
String url = Address.getReposDetail(userName, reposName) + "?ref=" + branch;
6060
var res = await HttpManager.netFetch(url, null, {"Accept": 'application/vnd.github.mercy-preview+json'}, null);
6161
if (res != null && res.result && res.data.length > 0) {
62-
List<ReposHeaderViewModel> list = new List();
6362
var data = res.data;
6463
if (data == null || data.length == 0) {
6564
return new DataResult(null, false);
@@ -73,8 +72,8 @@ class ReposDao {
7372
/**
7473
* 仓库活动事件
7574
*/
76-
static getRepositoryEventDao(userName, reposName, {page = 0}) async {
77-
String url = Address.getReposEvent(userName, reposName) + Address.getPageParams("?", page);
75+
static getRepositoryEventDao(userName, reposName, {page = 0, branch="master"}) async {
76+
String url = Address.getReposEvent(userName, reposName) + Address.getPageParams("?", page) + "&ref=" + branch;
7877
var res = await HttpManager.netFetch(url, null, null, null);
7978
if (res != null && res.result) {
8079
List<EventViewModel> list = new List();
@@ -106,8 +105,8 @@ class ReposDao {
106105
/**
107106
* 获取仓库的提交列表
108107
*/
109-
static getReposCommitsDao(userName, reposName, {page = 0}) async {
110-
String url = Address.getReposCommits(userName, reposName) + Address.getPageParams("?", page);
108+
static getReposCommitsDao(userName, reposName, {page = 0, branch="master"}) async {
109+
String url = Address.getReposCommits(userName, reposName) + Address.getPageParams("?", page) + "&ref=" + branch;
111110
var res = await HttpManager.netFetch(url, null, null, null);
112111
if (res != null && res.result) {
113112
List<EventViewModel> list = new List();

‎lib/page/RepositoryDetailPage.dart‎

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,18 @@ class _RepositoryDetailPageState extends State<RepositoryDetailPage> {
4242

4343
final TarWidgetControl tarBarControl = new TarWidgetControl();
4444

45-
String currentBranch = "master";
45+
final BranchControl branchControl = new BranchControl("master");
46+
47+
final GlobalKey<RepositoryDetailFileListPageState> fileListKey = new GlobalKey<RepositoryDetailFileListPageState>();
48+
49+
final GlobalKey<ReposDetailInfoPageState> infoListKey = new GlobalKey<ReposDetailInfoPageState>();
4650

4751
List<String> branchList = new List();
4852

4953
_RepositoryDetailPageState(this.userName, this.reposName);
5054

5155
_getReposDetail() async {
52-
var result = await ReposDao.getRepositoryDetailDao(userName, reposName);
56+
var result = await ReposDao.getRepositoryDetailDao(userName, reposName, branchControl.currentBranch);
5357
if (result != null && result.result) {
5458
setState(() {
5559
reposDetailInfoPageControl.reposHeaderViewModel = result.data;
@@ -183,7 +187,14 @@ class _RepositoryDetailPageState extends State<RepositoryDetailPage> {
183187
padding: 5.0,
184188
mainAxisAlignment: MainAxisAlignment.center,
185189
)),
186-
_renderBranchPopItem(currentBranch, branchList, (value) {}),
190+
_renderBranchPopItem(branchControl.currentBranch, branchList, (value) {
191+
setState(() {
192+
branchControl.currentBranch = value;
193+
});
194+
_getReposDetail();
195+
//fileListKey.currentState.showRefreshLoading();
196+
infoListKey.currentState.showRefreshLoading();
197+
}),
187198
];
188199
return bottomWidget;
189200
}
@@ -207,9 +218,9 @@ class _RepositoryDetailPageState extends State<RepositoryDetailPage> {
207218
new Tab(text: GSYStrings.repos_tab_readme),
208219
],
209220
tabViews: [
210-
new ReposDetailInfoPage(reposDetailInfoPageControl, userName, reposName),
221+
new ReposDetailInfoPage(reposDetailInfoPageControl, userName, reposName, branchControl, key: infoListKey),
211222
new RepositoryDetailIssuePage(userName, reposName),
212-
new RepositoryDetailFileListPage(userName, reposName),
223+
new RepositoryDetailFileListPage(userName, reposName, branchControl, key: fileListKey),
213224
new RepositoryDetailReadmePage(),
214225
],
215226
backgroundColor: GSYColors.primarySwatch,
@@ -228,3 +239,9 @@ class BottomStatusModel {
228239

229240
BottomStatusModel(this.watchText, this.starText, this.watchIcon, this.starIcon, this.watch, this.star);
230241
}
242+
243+
class BranchControl {
244+
String currentBranch;
245+
246+
BranchControl(this.currentBranch);
247+
}

‎lib/page/RepositoryFileListPage.dart‎

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import 'package:flutter/material.dart';
22
import 'package:gsy_github_app_flutter/common/dao/ReposDao.dart';
33
import 'package:gsy_github_app_flutter/common/style/GSYStyle.dart';
4+
import 'package:gsy_github_app_flutter/page/RepositoryDetailPage.dart';
45
import 'package:gsy_github_app_flutter/widget/GSYCardItem.dart';
56
import 'package:gsy_github_app_flutter/widget/GSYListState.dart';
67
import 'package:gsy_github_app_flutter/widget/GSYPullLoadWidget.dart';
@@ -16,27 +17,30 @@ class RepositoryDetailFileListPage extends StatefulWidget {
1617

1718
final String reposName;
1819

19-
RepositoryDetailFileListPage(this.userName, this.reposName);
20+
final BranchControl branchControl;
21+
22+
RepositoryDetailFileListPage(this.userName, this.reposName, this.branchControl, { Key key }) : super(key: key);
2023

2124
@override
22-
_RepositoryDetailFileListPageState createState() => _RepositoryDetailFileListPageState(userName, reposName);
25+
RepositoryDetailFileListPageState createState() => RepositoryDetailFileListPageState(userName, reposName, branchControl);
2326
}
2427

2528
// ignore: mixin_inherits_from_not_object
26-
class _RepositoryDetailFileListPageState extends GSYListState<RepositoryDetailFileListPage> {
29+
class RepositoryDetailFileListPageState extends GSYListState<RepositoryDetailFileListPage> {
2730
final String userName;
2831

2932
final String reposName;
3033

31-
String curBranch;
34+
final BranchControl branchControl;
35+
3236
String path = '';
3337

3438
String searchText;
3539
String issueState;
3640

3741
List<String> headerList = ["."];
3842

39-
_RepositoryDetailFileListPageState(this.userName, this.reposName);
43+
RepositoryDetailFileListPageState(this.userName, this.reposName, this.branchControl);
4044

4145
///渲染文件item
4246
_renderEventItem(index) {
@@ -110,7 +114,7 @@ class _RepositoryDetailFileListPageState extends GSYListState<RepositoryDetailFi
110114
}
111115

112116
_getDataLogic(String searchString) async {
113-
return await ReposDao.getReposFileDirDao(userName, reposName, path: path, branch: curBranch);
117+
return await ReposDao.getReposFileDirDao(userName, reposName, path: path, branch: branchControl.currentBranch);
114118
}
115119

116120
@override

‎lib/page/RepostoryDetailInfoPage.dart‎

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import 'package:flutter/material.dart';
22
import 'package:gsy_github_app_flutter/common/dao/ReposDao.dart';
33
import 'package:gsy_github_app_flutter/common/utils/EventUtils.dart';
4+
import 'package:gsy_github_app_flutter/page/RepositoryDetailPage.dart';
45
import 'package:gsy_github_app_flutter/widget/EventItem.dart';
56
import 'package:gsy_github_app_flutter/widget/GSYListState.dart';
67
import 'package:gsy_github_app_flutter/widget/GSYPullLoadWidget.dart';
@@ -17,23 +18,27 @@ class ReposDetailInfoPage extends StatefulWidget {
1718
final String reposName;
1819
final ReposDetailInfoPageControl reposDetailInfoPageControl;
1920

20-
ReposDetailInfoPage(this.reposDetailInfoPageControl, this.userName, this.reposName);
21+
final BranchControl branchControl;
22+
23+
ReposDetailInfoPage(this.reposDetailInfoPageControl, this.userName, this.reposName, this.branchControl, { Key key }) : super(key: key);
2124

2225
@override
23-
_ReposDetailInfoPageState createState() => _ReposDetailInfoPageState(reposDetailInfoPageControl, userName, reposName);
26+
ReposDetailInfoPageState createState() => ReposDetailInfoPageState(reposDetailInfoPageControl, userName, reposName, branchControl);
2427
}
2528

2629
// ignore: mixin_inherits_from_not_object
27-
class _ReposDetailInfoPageState extends GSYListState<ReposDetailInfoPage> {
30+
class ReposDetailInfoPageState extends GSYListState<ReposDetailInfoPage> {
2831
final String userName;
2932

3033
final String reposName;
3134

3235
final ReposDetailInfoPageControl reposDetailInfoPageControl;
3336

37+
final BranchControl branchControl;
38+
3439
int selectIndex = 0;
3540

36-
_ReposDetailInfoPageState(this.reposDetailInfoPageControl, this.userName, this.reposName);
41+
ReposDetailInfoPageState(this.reposDetailInfoPageControl, this.userName, this.reposName, this.branchControl);
3742

3843
_renderEventItem(index) {
3944
if (index == 0) {
@@ -65,9 +70,9 @@ class _ReposDetailInfoPageState extends GSYListState<ReposDetailInfoPage> {
6570

6671
_getDataLogic() async {
6772
if (selectIndex == 1) {
68-
return await ReposDao.getReposCommitsDao(userName, reposName, page: page);
73+
return await ReposDao.getReposCommitsDao(userName, reposName, page: page, branch: branchControl.currentBranch);
6974
}
70-
return await ReposDao.getRepositoryEventDao(userName, reposName, page: page);
75+
return await ReposDao.getRepositoryEventDao(userName, reposName, page: page, branch: branchControl.currentBranch);
7176
}
7277

7378
@override

‎lib/widget/GSYListState.dart‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,13 @@ abstract class GSYListState<T extends StatefulWidget> extends State<T> with Auto
2121

2222
final GlobalKey<RefreshIndicatorState> refreshIndicatorKey = new GlobalKey<RefreshIndicatorState>();
2323

24+
25+
showRefreshLoading() {
26+
new Future.delayed(const Duration(seconds: 0), () {
27+
refreshIndicatorKey.currentState.show().then((e) {});
28+
});
29+
}
30+
2431
@protected
2532
Future<Null> handleRefresh() async {
2633
if (isLoading) {
@@ -65,13 +72,6 @@ abstract class GSYListState<T extends StatefulWidget> extends State<T> with Auto
6572
});
6673
}
6774

68-
@protected
69-
showRefreshLoading() {
70-
new Future.delayed(const Duration(seconds: 0), () {
71-
refreshIndicatorKey.currentState.show().then((e) {});
72-
});
73-
}
74-
7575
@protected
7676
clearData() {
7777
setState(() {

‎lib/widget/ReposHeaderItem.dart‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,11 @@ class ReposHeaderItem extends StatelessWidget {
2323
child: new Center(
2424
child: new FlatButton(
2525
onPressed: onPressed,
26+
padding:new EdgeInsets.all(0.0),
2627
child: new GSYIConText(
2728
icon,
2829
text,
29-
GSYConstant.middleSubText,
30+
GSYConstant.subSmallText,
3031
Color(GSYColors.subTextColor),
3132
15.0,
3233
padding: 3.0,
@@ -93,7 +94,7 @@ class ReposHeaderItem extends StatelessWidget {
9394
color: Color(GSYColors.subTextColor),
9495
),
9596
new Padding(
96-
padding: new EdgeInsets.all(5.0),
97+
padding: new EdgeInsets.all(0.0),
9798
child: new Row(
9899
crossAxisAlignment: CrossAxisAlignment.center,
99100
mainAxisAlignment: MainAxisAlignment.center,

0 commit comments

Comments
 (0)