11import 'package:flutter/material.dart' ;
22import 'package:fluttertoast/fluttertoast.dart' ;
33import 'package:gsy_github_app_flutter/common/dao/IssueDao.dart' ;
4+ import 'package:gsy_github_app_flutter/common/net/Address.dart' ;
45import 'package:gsy_github_app_flutter/common/style/GSYStyle.dart' ;
56import 'package:gsy_github_app_flutter/common/utils/CommonUtils.dart' ;
67import 'package:gsy_github_app_flutter/common/utils/NavigatorUtils.dart' ;
8+ import 'package:gsy_github_app_flutter/widget/GSYCommonOptionWidget.dart' ;
79import 'package:gsy_github_app_flutter/widget/GSYFlexButton.dart' ;
810import 'package:gsy_github_app_flutter/widget/GSYListState.dart' ;
911import 'package:gsy_github_app_flutter/widget/GSYPullLoadWidget.dart' ;
@@ -23,12 +25,12 @@ class IssueDetailPage extends StatefulWidget {
2325
2426 final String issueNum;
2527
26- final bool needRightIcon ;
28+ final bool needHomeIcon ;
2729
28- IssueDetailPage (this .userName, this .reposName, this .issueNum, {this .needRightIcon = false });
30+ IssueDetailPage (this .userName, this .reposName, this .issueNum, {this .needHomeIcon = false });
2931
3032 @override
31- _IssueDetailPageState createState () => _IssueDetailPageState (issueNum, userName, reposName, needRightIcon );
33+ _IssueDetailPageState createState () => _IssueDetailPageState (issueNum, userName, reposName, needHomeIcon );
3234}
3335
3436// ignore: mixin_inherits_from_not_object
@@ -43,7 +45,7 @@ class _IssueDetailPageState extends GSYListState<IssueDetailPage> {
4345
4446 bool headerStatus = false ;
4547
46- bool needRightIcon = false ;
48+ bool needHomeIcon = false ;
4749
4850 IssueHeaderViewModel issueHeaderViewModel = new IssueHeaderViewModel ();
4951
@@ -53,11 +55,12 @@ class _IssueDetailPageState extends GSYListState<IssueDetailPage> {
5355
5456 TextEditingController issueInfoCommitValueControl = new TextEditingController ();
5557
56- _IssueDetailPageState (this .issueNum, this .userName, this .reposName, this .needRightIcon );
58+ _IssueDetailPageState (this .issueNum, this .userName, this .reposName, this .needHomeIcon );
5759
5860 _renderEventItem (index) {
5961 if (index == 0 ) {
60- return new IssueHeaderItem (issueHeaderViewModel, onPressed: () {});
62+ return new IssueHeaderItem (issueHeaderViewModel, onPressed: () {
63+ });
6164 }
6265 IssueItemViewModel issueItemViewModel = pullLoadWidgetControl.dataList[index - 1 ];
6366 return new IssueItem (
@@ -128,11 +131,13 @@ class _IssueDetailPageState extends GSYListState<IssueDetailPage> {
128131 context,
129132 GSYStrings .issue_edit_issue,
130133 null ,
131- (contentValue) {
134+ (contentValue) {
132135 contentData = contentValue;
133136 },
134- () {
135- if (contentData == null || contentData.trim ().length == 0 ) {
137+ () {
138+ if (contentData == null || contentData
139+ .trim ()
140+ .length == 0 ) {
136141 Fluttertoast .showToast (msg: GSYStrings .issue_edit_issue_content_not_be_null);
137142 return ;
138143 }
@@ -168,18 +173,22 @@ class _IssueDetailPageState extends GSYListState<IssueDetailPage> {
168173 CommonUtils .showEditDialog (
169174 context,
170175 GSYStrings .issue_edit_issue,
171- (titleValue) {
176+ (titleValue) {
172177 title = titleValue;
173178 },
174- (contentValue) {
179+ (contentValue) {
175180 content = contentValue;
176181 },
177- () {
178- if (title == null || title.trim ().length == 0 ) {
182+ () {
183+ if (title == null || title
184+ .trim ()
185+ .length == 0 ) {
179186 Fluttertoast .showToast (msg: GSYStrings .issue_edit_issue_title_not_be_null);
180187 return ;
181188 }
182- if (content == null || content.trim ().length == 0 ) {
189+ if (content == null || content
190+ .trim ()
191+ .length == 0 ) {
183192 Fluttertoast .showToast (msg: GSYStrings .issue_edit_issue_content_not_be_null);
184193 return ;
185194 }
@@ -203,7 +212,9 @@ class _IssueDetailPageState extends GSYListState<IssueDetailPage> {
203212 CommonUtils .showEditDialog (context, GSYStrings .issue_reply_issue, null , (replyContent) {
204213 content = replyContent;
205214 }, () {
206- if (content == null || content.trim ().length == 0 ) {
215+ if (content == null || content
216+ .trim ()
217+ .length == 0 ) {
207218 Fluttertoast .showToast (msg: GSYStrings .issue_edit_issue_content_not_be_null);
208219 return ;
209220 }
@@ -221,40 +232,41 @@ class _IssueDetailPageState extends GSYListState<IssueDetailPage> {
221232 List <Widget > bottomWidget = (! headerStatus)
222233 ? []
223234 : < Widget > [
224- new FlatButton (
225- onPressed: () {
226- _replyIssue ();
227- },
228- child: new Text (GSYStrings .issue_reply, style: GSYConstant .smallText),
229- ),
230- new Container (width: 0.3 , height: 30.0 , color: Color (GSYColors .subLightTextColor)),
231- new FlatButton (
232- onPressed: () {
233- _editIssue ();
234- },
235- child: new Text (GSYStrings .issue_edit, style: GSYConstant .smallText),
236- ),
237- new Container (width: 0.3 , height: 30.0 , color: Color (GSYColors .subLightTextColor)),
238- new FlatButton (
239- onPressed: () {
240- CommonUtils .showLoadingDialog (context);
241- IssueDao .editIssueDao (userName, reposName, issueNum, {"state" : (issueHeaderViewModel.state == "closed" ) ? 'open' : 'closed' }).then ((result) {
242- _getHeaderInfo ();
243- Navigator .pop (context);
244- });
245- },
246- child: new Text ((issueHeaderViewModel.state == 'closed' ) ? GSYStrings .issue_open : GSYStrings .issue_close, style: GSYConstant .smallText)),
247- new Container (width: 0.3 , height: 30.0 , color: Color (GSYColors .subLightTextColor)),
248- new FlatButton (
249- onPressed: () {
250- CommonUtils .showLoadingDialog (context);
251- IssueDao .lockIssueDao (userName, reposName, issueNum, issueHeaderViewModel.locked).then ((result) {
252- _getHeaderInfo ();
253- Navigator .pop (context);
254- });
255- },
256- child: new Text ((issueHeaderViewModel.locked) ? GSYStrings .issue_unlock : GSYStrings .issue_lock, style: GSYConstant .smallText)),
257- ];
235+ new FlatButton (
236+ onPressed: () {
237+ _replyIssue ();
238+ },
239+ child: new Text (GSYStrings .issue_reply, style: GSYConstant .smallText),
240+ ),
241+ new Container (width: 0.3 , height: 30.0 , color: Color (GSYColors .subLightTextColor)),
242+ new FlatButton (
243+ onPressed: () {
244+ _editIssue ();
245+ },
246+ child: new Text (GSYStrings .issue_edit, style: GSYConstant .smallText),
247+ ),
248+ new Container (width: 0.3 , height: 30.0 , color: Color (GSYColors .subLightTextColor)),
249+ new FlatButton (
250+ onPressed: () {
251+ CommonUtils .showLoadingDialog (context);
252+ IssueDao .editIssueDao (userName, reposName, issueNum, {"state" : (issueHeaderViewModel.state == "closed" ) ? 'open' : 'closed' }).then ((
253+ result) {
254+ _getHeaderInfo ();
255+ Navigator .pop (context);
256+ });
257+ },
258+ child: new Text ((issueHeaderViewModel.state == 'closed' ) ? GSYStrings .issue_open : GSYStrings .issue_close, style: GSYConstant .smallText)),
259+ new Container (width: 0.3 , height: 30.0 , color: Color (GSYColors .subLightTextColor)),
260+ new FlatButton (
261+ onPressed: () {
262+ CommonUtils .showLoadingDialog (context);
263+ IssueDao .lockIssueDao (userName, reposName, issueNum, issueHeaderViewModel.locked).then ((result) {
264+ _getHeaderInfo ();
265+ Navigator .pop (context);
266+ });
267+ },
268+ child: new Text ((issueHeaderViewModel.locked) ? GSYStrings .issue_unlock : GSYStrings .issue_lock, style: GSYConstant .smallText)),
269+ ];
258270 return bottomWidget;
259271 }
260272
@@ -280,12 +292,15 @@ class _IssueDetailPageState extends GSYListState<IssueDetailPage> {
280292 @override
281293 Widget build (BuildContext context) {
282294 super .build (context); // See AutomaticKeepAliveClientMixin.
295+ String url = Address .hostWeb + userName + "/" + reposName + "/issues/" + issueNum;
296+ Widget widget = (needHomeIcon) ? null : new GSYCommonOptionWidget (url);
283297 return new Scaffold (
284298 persistentFooterButtons: _getBottomWidget (),
285299 appBar: new AppBar (
286300 title: GSYTitleBar (
287301 reposName,
288- needRightIcon: needRightIcon,
302+ rightWidget: widget,
303+ needRightLocalIcon: needHomeIcon,
289304 iconData: GSYICons .HOME ,
290305 onPressed: () {
291306 NavigatorUtils .goReposDetail (context, userName, reposName);
@@ -294,7 +309,7 @@ class _IssueDetailPageState extends GSYListState<IssueDetailPage> {
294309 ),
295310 body: GSYPullLoadWidget (
296311 pullLoadWidgetControl,
297- (BuildContext context, int index) => _renderEventItem (index),
312+ (BuildContext context, int index) => _renderEventItem (index),
298313 handleRefresh,
299314 onLoadMore,
300315 refreshKey: refreshIndicatorKey,
0 commit comments