Skip to content

Commit 4eb9a47

Browse files
committed
add commit edit
1 parent b9972f6 commit 4eb9a47

5 files changed

Lines changed: 70 additions & 8 deletions

File tree

‎lib/common/dao/IssueDao.dart‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ class IssueDao {
181181
*/
182182
static deleteCommentDao(userName, repository, number, commentId) async {
183183
String url = Address.editComment(userName, repository, commentId);
184-
var res = await HttpManager.netFetch(url, null, null, new Options(method: 'DELETE'));
184+
var res = await HttpManager.netFetch(url, null, null, new Options(method: 'DELETE', contentType: ContentType.TEXT), noTip: true);
185185
if (res != null && res.result) {
186186
return new DataResult(res.data, true);
187187
} else {

‎lib/common/style/GSYStyle.dart‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,10 @@ class GSYStrings {
238238
static const String issue_commit_issue = "提交Issue";
239239
static const String issue_edit_issue = "编译Issue";
240240
static const String issue_edit_issue_commit = "编译回复";
241+
static const String issue_edit_issue_edit_commit = "编辑";
242+
static const String issue_edit_issue_delete_commit = "删除";
243+
static const String issue_edit_issue_content_not_be_null = "内容不能为空";
244+
static const String issue_edit_issue_title_not_be_null = "标题不能为空";
241245
}
242246

243247
class GSYICons {

‎lib/common/utils/EventUtils.dart‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,6 @@ class EventUtils {
178178
return;
179179
}
180180
NavigatorUtils.goReposDetail(context, owner, repositoryName);
181-
NavigatorUtils.goReposDetail(context, "carsmallguo", "GSYGithubApp-Weex");
182181
break;
183182
}
184183
}

‎lib/page/IssueDetailPage.dart‎

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import 'package:flutter/material.dart';
2+
import 'package:fluttertoast/fluttertoast.dart';
23
import 'package:gsy_github_app_flutter/common/dao/IssueDao.dart';
34
import 'package:gsy_github_app_flutter/common/style/GSYStyle.dart';
45
import 'package:gsy_github_app_flutter/common/utils/CommonUtils.dart';
6+
import 'package:gsy_github_app_flutter/widget/GSYFlexButton.dart';
57
import 'package:gsy_github_app_flutter/widget/GSYListState.dart';
68
import 'package:gsy_github_app_flutter/widget/GSYPullLoadWidget.dart';
79
import 'package:gsy_github_app_flutter/widget/IssueHeaderItem.dart';
@@ -56,7 +58,39 @@ class _IssueDetailPageState extends GSYListState<IssueDetailPage> {
5658
issueItemViewModel,
5759
hideBottom: true,
5860
limitComment: false,
59-
onPressed: () {},
61+
onPressed: () {
62+
showDialog(
63+
context: context,
64+
builder: (BuildContext context) {
65+
return new Center(
66+
child: new Container(
67+
decoration: new BoxDecoration(
68+
borderRadius: BorderRadius.all(Radius.circular(4.0)),
69+
color: Colors.white,
70+
border: new Border.all(color: Color(GSYColors.subTextColor), width: 0.3)),
71+
margin: EdgeInsets.all(10.0),
72+
child: Column(
73+
mainAxisSize: MainAxisSize.min,
74+
mainAxisAlignment: MainAxisAlignment.center,
75+
children: <Widget>[
76+
new GSYFlexButton(
77+
color: Colors.white,
78+
text: GSYStrings.issue_edit_issue_edit_commit,
79+
onPress: () {},
80+
),
81+
new GSYFlexButton(
82+
color: Colors.white,
83+
text: GSYStrings.issue_edit_issue_delete_commit,
84+
onPress: () {
85+
_deleteCommit(issueItemViewModel.id);
86+
},
87+
),
88+
],
89+
),
90+
),
91+
);
92+
});
93+
},
6094
);
6195
}
6296

@@ -77,6 +111,16 @@ class _IssueDetailPageState extends GSYListState<IssueDetailPage> {
77111
}
78112
}
79113

114+
_deleteCommit(id) {
115+
Navigator.pop(context);
116+
CommonUtils.showLoadingDialog(context);
117+
//提交修改
118+
IssueDao.deleteCommentDao(userName, reposName, issueNum, id).then()((result) {
119+
showRefreshLoading();
120+
Navigator.pop(context);
121+
});
122+
}
123+
80124
_editIssue() {
81125
String title = issueHeaderViewModel.issueComment;
82126
String content = issueHeaderViewModel.issueDesHtml;
@@ -93,6 +137,14 @@ class _IssueDetailPageState extends GSYListState<IssueDetailPage> {
93137
content = contentValue;
94138
},
95139
() {
140+
if (title == null || title.trim().length == 0) {
141+
Fluttertoast.showToast(msg: GSYStrings.issue_edit_issue_title_not_be_null);
142+
return;
143+
}
144+
if (content == null || content.trim().length == 0) {
145+
Fluttertoast.showToast(msg: GSYStrings.issue_edit_issue_content_not_be_null);
146+
return;
147+
}
96148
CommonUtils.showLoadingDialog(context);
97149
//提交修改
98150
IssueDao.editIssueDao(userName, reposName, issueNum, {"title": title, "body": content}).then((result) {
@@ -113,6 +165,10 @@ class _IssueDetailPageState extends GSYListState<IssueDetailPage> {
113165
CommonUtils.showEditDialog(context, GSYStrings.issue_reply_issue, null, (replyContent) {
114166
content = replyContent;
115167
}, () {
168+
if (content == null || content.trim().length == 0) {
169+
Fluttertoast.showToast(msg: GSYStrings.issue_edit_issue_content_not_be_null);
170+
return;
171+
}
116172
CommonUtils.showLoadingDialog(context);
117173
//提交评论
118174
IssueDao.addIssueCommentDao(userName, reposName, issueNum, content).then((result) {

‎lib/widget/IssueItem.dart‎

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,14 @@ import 'package:gsy_github_app_flutter/widget/GSYIConText.dart';
1313
class IssueItem extends StatelessWidget {
1414
final IssueItemViewModel issueItemViewModel;
1515

16-
final VoidCallback onPressed;
16+
final GestureTapCallback onPressed;
17+
final GestureTapCallback onLongPress;
1718

1819
final bool hideBottom;
1920

2021
final bool limitComment;
2122

22-
IssueItem(this.issueItemViewModel, {this.onPressed, this.hideBottom = false, this.limitComment = true});
23+
IssueItem(this.issueItemViewModel, {this.onPressed, this.onLongPress, this.hideBottom = false, this.limitComment = true});
2324

2425
@override
2526
Widget build(BuildContext context) {
@@ -54,9 +55,9 @@ class IssueItem extends StatelessWidget {
5455
],
5556
);
5657
return new GSYCardItem(
57-
child: new FlatButton(
58-
padding: new EdgeInsets.all(0.0),
59-
onPressed: onPressed,
58+
child: new InkWell(
59+
onTap: onPressed,
60+
onLongPress: onLongPress,
6061
child: new Padding(
6162
padding: new EdgeInsets.only(left: 5.0, top: 5.0, right: 10.0, bottom: 8.0),
6263
child: new Row(crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[
@@ -120,6 +121,7 @@ class IssueItemViewModel {
120121
String state = "---";
121122
String issueTag = "---";
122123
String number = "---";
124+
String id = "";
123125

124126
IssueItemViewModel();
125127

@@ -136,6 +138,7 @@ class IssueItemViewModel {
136138
number = issueMap["number"].toString();
137139
} else {
138140
issueComment = issueMap["body"] != null ? issueMap["body"] : "";
141+
id = issueMap["id"].toString();
139142
}
140143
}
141144
}

0 commit comments

Comments
 (0)