@@ -2,7 +2,6 @@ import 'package:flutter/material.dart';
22import 'package:fluttertoast/fluttertoast.dart' ;
33import 'package:gsy_github_app_flutter/common/dao/IssueDao.dart' ;
44import 'package:gsy_github_app_flutter/common/model/Issue.dart' ;
5- import 'package:gsy_github_app_flutter/common/net/Address.dart' ;
65import 'package:gsy_github_app_flutter/common/style/GSYStyle.dart' ;
76import 'package:gsy_github_app_flutter/common/utils/CommonUtils.dart' ;
87import 'package:gsy_github_app_flutter/common/utils/NavigatorUtils.dart' ;
@@ -54,14 +53,15 @@ class _IssueDetailPageState extends GSYListState<IssueDetailPage> {
5453
5554 TextEditingController issueInfoValueControl = new TextEditingController ();
5655
57- TextEditingController issueInfoCommitValueControl = new TextEditingController ();
56+ final TextEditingController issueInfoCommitValueControl = new TextEditingController ();
57+
58+ final OptionControl titleOptionControl = new OptionControl ();
5859
5960 _IssueDetailPageState (this .issueNum, this .userName, this .reposName, this .needHomeIcon);
6061
6162 _renderEventItem (index) {
6263 if (index == 0 ) {
63- return new IssueHeaderItem (issueHeaderViewModel, onPressed: () {
64- });
64+ return new IssueHeaderItem (issueHeaderViewModel, onPressed: () {});
6565 }
6666 Issue issue = pullLoadWidgetControl.dataList[index - 1 ];
6767 return new IssueItem (
@@ -116,8 +116,10 @@ class _IssueDetailPageState extends GSYListState<IssueDetailPage> {
116116 _getHeaderInfo () async {
117117 var res = await IssueDao .getIssueInfoDao (userName, reposName, issueNum);
118118 if (res != null && res.result) {
119+ Issue issue = res.data;
119120 setState (() {
120- issueHeaderViewModel = IssueHeaderViewModel .fromMap (res.data);
121+ issueHeaderViewModel = IssueHeaderViewModel .fromMap (issue);
122+ titleOptionControl.url = issue.htmlUrl;
121123 headerStatus = true ;
122124 });
123125 }
@@ -132,13 +134,11 @@ class _IssueDetailPageState extends GSYListState<IssueDetailPage> {
132134 context,
133135 GSYStrings .issue_edit_issue,
134136 null ,
135- (contentValue) {
137+ (contentValue) {
136138 contentData = contentValue;
137139 },
138- () {
139- if (contentData == null || contentData
140- .trim ()
141- .length == 0 ) {
140+ () {
141+ if (contentData == null || contentData.trim ().length == 0 ) {
142142 Fluttertoast .showToast (msg: GSYStrings .issue_edit_issue_content_not_be_null);
143143 return ;
144144 }
@@ -174,22 +174,18 @@ class _IssueDetailPageState extends GSYListState<IssueDetailPage> {
174174 CommonUtils .showEditDialog (
175175 context,
176176 GSYStrings .issue_edit_issue,
177- (titleValue) {
177+ (titleValue) {
178178 title = titleValue;
179179 },
180- (contentValue) {
180+ (contentValue) {
181181 content = contentValue;
182182 },
183- () {
184- if (title == null || title
185- .trim ()
186- .length == 0 ) {
183+ () {
184+ if (title == null || title.trim ().length == 0 ) {
187185 Fluttertoast .showToast (msg: GSYStrings .issue_edit_issue_title_not_be_null);
188186 return ;
189187 }
190- if (content == null || content
191- .trim ()
192- .length == 0 ) {
188+ if (content == null || content.trim ().length == 0 ) {
193189 Fluttertoast .showToast (msg: GSYStrings .issue_edit_issue_content_not_be_null);
194190 return ;
195191 }
@@ -213,9 +209,7 @@ class _IssueDetailPageState extends GSYListState<IssueDetailPage> {
213209 CommonUtils .showEditDialog (context, GSYStrings .issue_reply_issue, null , (replyContent) {
214210 content = replyContent;
215211 }, () {
216- if (content == null || content
217- .trim ()
218- .length == 0 ) {
212+ if (content == null || content.trim ().length == 0 ) {
219213 Fluttertoast .showToast (msg: GSYStrings .issue_edit_issue_content_not_be_null);
220214 return ;
221215 }
@@ -233,41 +227,40 @@ class _IssueDetailPageState extends GSYListState<IssueDetailPage> {
233227 List <Widget > bottomWidget = (! headerStatus)
234228 ? []
235229 : < Widget > [
236- new FlatButton (
237- onPressed: () {
238- _replyIssue ();
239- },
240- child: new Text (GSYStrings .issue_reply, style: GSYConstant .smallText),
241- ),
242- new Container (width: 0.3 , height: 30.0 , color: Color (GSYColors .subLightTextColor)),
243- new FlatButton (
244- onPressed: () {
245- _editIssue ();
246- },
247- child: new Text (GSYStrings .issue_edit, style: GSYConstant .smallText),
248- ),
249- new Container (width: 0.3 , height: 30.0 , color: Color (GSYColors .subLightTextColor)),
250- new FlatButton (
251- onPressed: () {
252- CommonUtils .showLoadingDialog (context);
253- IssueDao .editIssueDao (userName, reposName, issueNum, {"state" : (issueHeaderViewModel.state == "closed" ) ? 'open' : 'closed' }).then ((
254- result) {
255- _getHeaderInfo ();
256- Navigator .pop (context);
257- });
258- },
259- child: new Text ((issueHeaderViewModel.state == 'closed' ) ? GSYStrings .issue_open : GSYStrings .issue_close, style: GSYConstant .smallText)),
260- new Container (width: 0.3 , height: 30.0 , color: Color (GSYColors .subLightTextColor)),
261- new FlatButton (
262- onPressed: () {
263- CommonUtils .showLoadingDialog (context);
264- IssueDao .lockIssueDao (userName, reposName, issueNum, issueHeaderViewModel.locked).then ((result) {
265- _getHeaderInfo ();
266- Navigator .pop (context);
267- });
268- },
269- child: new Text ((issueHeaderViewModel.locked) ? GSYStrings .issue_unlock : GSYStrings .issue_lock, style: GSYConstant .smallText)),
270- ];
230+ new FlatButton (
231+ onPressed: () {
232+ _replyIssue ();
233+ },
234+ child: new Text (GSYStrings .issue_reply, style: GSYConstant .smallText),
235+ ),
236+ new Container (width: 0.3 , height: 30.0 , color: Color (GSYColors .subLightTextColor)),
237+ new FlatButton (
238+ onPressed: () {
239+ _editIssue ();
240+ },
241+ child: new Text (GSYStrings .issue_edit, style: GSYConstant .smallText),
242+ ),
243+ new Container (width: 0.3 , height: 30.0 , color: Color (GSYColors .subLightTextColor)),
244+ new FlatButton (
245+ onPressed: () {
246+ CommonUtils .showLoadingDialog (context);
247+ IssueDao .editIssueDao (userName, reposName, issueNum, {"state" : (issueHeaderViewModel.state == "closed" ) ? 'open' : 'closed' }).then ((result) {
248+ _getHeaderInfo ();
249+ Navigator .pop (context);
250+ });
251+ },
252+ child: new Text ((issueHeaderViewModel.state == 'closed' ) ? GSYStrings .issue_open : GSYStrings .issue_close, style: GSYConstant .smallText)),
253+ new Container (width: 0.3 , height: 30.0 , color: Color (GSYColors .subLightTextColor)),
254+ new FlatButton (
255+ onPressed: () {
256+ CommonUtils .showLoadingDialog (context);
257+ IssueDao .lockIssueDao (userName, reposName, issueNum, issueHeaderViewModel.locked).then ((result) {
258+ _getHeaderInfo ();
259+ Navigator .pop (context);
260+ });
261+ },
262+ child: new Text ((issueHeaderViewModel.locked) ? GSYStrings .issue_unlock : GSYStrings .issue_lock, style: GSYConstant .smallText)),
263+ ];
271264 return bottomWidget;
272265 }
273266
@@ -293,8 +286,7 @@ class _IssueDetailPageState extends GSYListState<IssueDetailPage> {
293286 @override
294287 Widget build (BuildContext context) {
295288 super .build (context); // See AutomaticKeepAliveClientMixin.
296- String url = Address .hostWeb + userName + "/" + reposName + "/issues/" + issueNum;
297- Widget widget = (needHomeIcon) ? null : new GSYCommonOptionWidget (url);
289+ Widget widget = (needHomeIcon) ? null : new GSYCommonOptionWidget (titleOptionControl);
298290 return new Scaffold (
299291 persistentFooterButtons: _getBottomWidget (),
300292 appBar: new AppBar (
@@ -310,7 +302,7 @@ class _IssueDetailPageState extends GSYListState<IssueDetailPage> {
310302 ),
311303 body: GSYPullLoadWidget (
312304 pullLoadWidgetControl,
313- (BuildContext context, int index) => _renderEventItem (index),
305+ (BuildContext context, int index) => _renderEventItem (index),
314306 handleRefresh,
315307 onLoadMore,
316308 refreshKey: refreshIndicatorKey,
0 commit comments