Skip to content

Commit

Permalink
update repos detail default branch
Browse files Browse the repository at this point in the history
  • Loading branch information
CarGuo committed Nov 28, 2019
1 parent 86a25ac commit 3cbddca
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 37 deletions.
2 changes: 1 addition & 1 deletion lib/model/RepositoryQL.dart
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class RepositoryQL {
issuesClosed: map["issuesClosed"]["totalCount"],
issuesOpen: map["issuesOpen"]["totalCount"],
issuesTotal: map["issues"]["totalCount"],
defaultBranch: map["defaultBranchRef"]["name"],
defaultBranch: map["defaultBranchRef"] != null ? map["defaultBranchRef"]["name"] : null,
reposName: map["name"],
hasIssuesEnabled: map["hasIssuesEnabled"],
reposFullName: map["nameWithOwner"],
Expand Down
10 changes: 8 additions & 2 deletions lib/page/repos/repository_detail_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,12 @@ class _RepositoryDetailPageState extends State<RepositoryDetailPage>
parent: animationController, curve: CurveBezier()),
child: FloatingActionButton(
onPressed: () {
if (model.repository?.hasIssuesEnabled == false) {
Fluttertoast.showToast(
msg: GSYLocalizations.i18n(context)
.repos_no_support_issue);
return;
}
_createIssue();
},
child: Icon(Icons.add),
Expand Down Expand Up @@ -286,6 +292,6 @@ class BottomStatusModel {
final IconData watchIcon;
final IconData starIcon;

BottomStatusModel(this.watchText, this.starText, this.watchIcon,
this.starIcon);
BottomStatusModel(
this.watchText, this.starText, this.watchIcon, this.starIcon);
}
79 changes: 45 additions & 34 deletions lib/page/repos/repostory_detail_info_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,11 @@ class ReposDetailInfoPageState extends State<ReposDetailInfoPage>
ReposDetailModel.of(context).currentBranch)
.then((result) {
if (result != null && result.result) {
ReposDetailModel.of(context).currentBranch = result.data.defaultBranch;
if (result.data.defaultBranch != null &&
result.data.defaultBranch.length > 0) {
ReposDetailModel.of(context).currentBranch =
result.data.defaultBranch;
}
ReposDetailModel.of(context).repository = result.data;
ReposDetailModel.of(context).getReposStatus(_getBottomWidget);
if (result.next != null) {
Expand All @@ -141,43 +145,50 @@ class ReposDetailInfoPageState extends State<ReposDetailInfoPage>
///绘制底部状态
List<Widget> _getBottomWidget() {
///根据网络返回数据,返回底部状态数据
List<Widget> bottomWidget = ( ReposDetailModel.of(context).bottomModel == null)
List<Widget> bottomWidget = (ReposDetailModel.of(context).bottomModel ==
null)
? []
: <Widget>[
/// star
_renderBottomItem( ReposDetailModel.of(context).bottomModel.starText,
ReposDetailModel.of(context).bottomModel.starIcon, () {
CommonUtils.showLoadingDialog(context);
return ReposDao.doRepositoryStarDao(widget.userName,
widget.reposName, ReposDetailModel.of(context).repository.isStared)
.then((result) {
showRefreshLoading();
Navigator.pop(context);
});
}),
/// star
_renderBottomItem(ReposDetailModel.of(context).bottomModel.starText,
ReposDetailModel.of(context).bottomModel.starIcon, () {
CommonUtils.showLoadingDialog(context);
return ReposDao.doRepositoryStarDao(
widget.userName,
widget.reposName,
ReposDetailModel.of(context).repository.isStared)
.then((result) {
showRefreshLoading();
Navigator.pop(context);
});
}),

/// watch
_renderBottomItem( ReposDetailModel.of(context).bottomModel.watchText,
ReposDetailModel.of(context).bottomModel.watchIcon, () {
CommonUtils.showLoadingDialog(context);
return ReposDao.doRepositoryWatchDao(widget.userName,
widget.reposName, ReposDetailModel.of(context).repository.isSubscription == "SUBSCRIBED")
.then((result) {
showRefreshLoading();
Navigator.pop(context);
});
}),
/// watch
_renderBottomItem(
ReposDetailModel.of(context).bottomModel.watchText,
ReposDetailModel.of(context).bottomModel.watchIcon, () {
CommonUtils.showLoadingDialog(context);
return ReposDao.doRepositoryWatchDao(
widget.userName,
widget.reposName,
ReposDetailModel.of(context).repository.isSubscription ==
"SUBSCRIBED")
.then((result) {
showRefreshLoading();
Navigator.pop(context);
});
}),

///fork
_renderBottomItem("fork", GSYICons.REPOS_ITEM_FORK, () {
CommonUtils.showLoadingDialog(context);
return ReposDao.createForkDao(widget.userName, widget.reposName)
.then((result) {
showRefreshLoading();
Navigator.pop(context);
});
}),
];
///fork
_renderBottomItem("fork", GSYICons.REPOS_ITEM_FORK, () {
CommonUtils.showLoadingDialog(context);
return ReposDao.createForkDao(widget.userName, widget.reposName)
.then((result) {
showRefreshLoading();
Navigator.pop(context);
});
}),
];
return bottomWidget;
}

Expand Down

0 comments on commit 3cbddca

Please sign in to comment.