Skip to content

Commit dda6e16

Browse files
committed
close and lock
1 parent 72de907 commit dda6e16

3 files changed

Lines changed: 96 additions & 9 deletions

File tree

‎lib/common/dao/IssueDao.dart‎

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import 'dart:io';
2+
3+
import 'package:dio/dio.dart';
14
import 'package:gsy_github_app_flutter/common/dao/DaoResult.dart';
25
import 'package:gsy_github_app_flutter/common/net/Address.dart';
36
import 'package:gsy_github_app_flutter/common/net/Api.dart';
@@ -105,4 +108,84 @@ class IssueDao {
105108
return new DataResult(null, false);
106109
}
107110
}
111+
112+
/**
113+
* 增加issue的回复
114+
*/
115+
static addIssueCommentDao(userName, repository, number, comment) async {
116+
String url = Address.addIssueComment(userName, repository, number);
117+
var res = await HttpManager.netFetch(url, {"body": comment}, {"Accept": 'application/vnd.github.VERSION.full+json'}, new Options(method: 'POST'));
118+
if (res != null && res.result) {
119+
return new DataResult(res.data, true);
120+
} else {
121+
return new DataResult(null, false);
122+
}
123+
}
124+
125+
/**
126+
* 编辑issue
127+
*/
128+
static editIssueDao(userName, repository, number, issue) async {
129+
String url = Address.editIssue(userName, repository, number);
130+
var res = await HttpManager.netFetch(url, issue, {"Accept": 'application/vnd.github.VERSION.full+json'}, new Options(method: 'PATCH'));
131+
if (res != null && res.result) {
132+
return new DataResult(res.data, true);
133+
} else {
134+
return new DataResult(null, false);
135+
}
136+
}
137+
138+
/**
139+
* 锁定issue
140+
*/
141+
static lockIssueDao(userName, repository, number, locked) async {
142+
String url = Address.lockIssue(userName, repository, number);
143+
var res = await HttpManager.netFetch(
144+
url, null, {"Accept": 'application/vnd.github.VERSION.full+json'}, new Options(method: locked ? "DELETE" : 'PUT', contentType: ContentType.TEXT),
145+
noTip: true);
146+
if (res != null && res.result) {
147+
return new DataResult(res.data, true);
148+
} else {
149+
return new DataResult(null, false);
150+
}
151+
}
152+
153+
/**
154+
* 创建issue
155+
*/
156+
static createIssueDao(userName, repository, issue) async {
157+
String url = Address.createIssue(userName, repository);
158+
var res = await HttpManager.netFetch(url, issue, {"Accept": 'application/vnd.github.VERSION.full+json'}, new Options(method: 'POST'));
159+
if (res != null && res.result) {
160+
return new DataResult(res.data, true);
161+
} else {
162+
return new DataResult(null, false);
163+
}
164+
}
165+
166+
/**
167+
* 编辑issue回复
168+
*/
169+
static editCommentDao(userName, repository, number, commentId, comment) async {
170+
String url = Address.editComment(userName, repository, commentId);
171+
var res = await HttpManager.netFetch(url, comment, {"Accept": 'application/vnd.github.VERSION.full+json'}, new Options(method: 'PATCH'));
172+
if (res != null && res.result) {
173+
return new DataResult(res.data, true);
174+
} else {
175+
return new DataResult(null, false);
176+
}
177+
}
178+
179+
/**
180+
* 删除issue回复
181+
*/
182+
static deleteCommentDao(userName, repository, number, commentId) async {
183+
String url = Address.editComment(userName, repository, commentId);
184+
var res = await HttpManager.netFetch(url, null, null, new Options(method: 'DELETE'));
185+
if (res != null && res.result) {
186+
return new DataResult(res.data, true);
187+
} else {
188+
return new DataResult(null, false);
189+
}
190+
}
108191
}

‎lib/common/utils/EventUtils.dart‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ class EventUtils {
177177
if (fullName.toLowerCase() == currentRepository.toLowerCase()) {
178178
return;
179179
}
180-
NavigatorUtils.goReposDetail(context, owner, repositoryName);
180+
NavigatorUtils.goReposDetail(context, "carsmallguo", "GSYGithubApp-Weex");
181181
break;
182182
}
183183
}

‎lib/page/IssueDetailPage.dart‎

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -85,22 +85,26 @@ class _IssueDetailPageState extends GSYListState<IssueDetailPage> {
8585
},
8686
child: new Text(GSYStrings.issue_reply, style: GSYConstant.smallText)),
8787
new Container(width: 0.3, height: 30.0, color: Color(GSYColors.subLightTextColor)),
88+
new FlatButton(onPressed: () {}, child: new Text(GSYStrings.issue_edit, style: GSYConstant.smallText)),
89+
new Container(width: 0.3, height: 30.0, color: Color(GSYColors.subLightTextColor)),
8890
new FlatButton(
8991
onPressed: () {
9092
CommonUtils.showLoadingDialog(context);
91-
/*return ReposDao.doRepositoryWatchDao(userName, reposName, bottomStatusModel.watch).then((result) {
92-
_refresh();
93+
IssueDao.editIssueDao(userName, reposName, issueNum, {"state": (issueHeaderViewModel.state == "closed") ? 'open' : 'closed'}).then((result) {
94+
_getHeaderInfo();
9395
Navigator.pop(context);
94-
});*/
96+
});
9597
},
96-
child: new Text(GSYStrings.issue_edit, style: GSYConstant.smallText)),
97-
new Container(width: 0.3, height: 30.0, color: Color(GSYColors.subLightTextColor)),
98-
new FlatButton(
99-
onPressed: () {},
10098
child: new Text((issueHeaderViewModel.state == 'closed') ? GSYStrings.issue_open : GSYStrings.issue_close, style: GSYConstant.smallText)),
10199
new Container(width: 0.3, height: 30.0, color: Color(GSYColors.subLightTextColor)),
102100
new FlatButton(
103-
onPressed: () {},
101+
onPressed: () {
102+
CommonUtils.showLoadingDialog(context);
103+
IssueDao.lockIssueDao(userName, reposName, issueNum, issueHeaderViewModel.locked).then((result) {
104+
_getHeaderInfo();
105+
Navigator.pop(context);
106+
});
107+
},
104108
child: new Text((issueHeaderViewModel.locked) ? GSYStrings.issue_unlock : GSYStrings.issue_lock, style: GSYConstant.smallText)),
105109
];
106110
return bottomWidget;

0 commit comments

Comments
 (0)