Skip to content

Commit 73e6c28

Browse files
committed
增加 input dialog
1 parent 7bb8364 commit 73e6c28

5 files changed

Lines changed: 163 additions & 63 deletions

File tree

‎lib/common/style/GSYStyle.dart‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,8 @@ class GSYStrings {
182182
static const String welcomeMessage = "Welcome To Flutter";
183183

184184
static const String app_name = "GSYGithubAppFlutter";
185+
static const String app_ok = "确定";
186+
static const String app_cancel = "取消";
185187

186188
static const String nothing_now = "目前什么都没有。";
187189
static const String loading_text = "加载中···";
@@ -224,7 +226,6 @@ class GSYStrings {
224226
static const String repos_tab_issue_open = "打开";
225227
static const String repos_tab_issue_closed = "关闭";
226228

227-
228229
static const String repos_issue_search = "搜索";
229230

230231
static const String issue_reply = "回复";
@@ -233,7 +234,10 @@ class GSYStrings {
233234
static const String issue_close = "关闭";
234235
static const String issue_lock = "锁定";
235236
static const String issue_unlock = "解锁";
236-
237+
static const String issue_reply_issue = "回复Issue";
238+
static const String issue_commit_issue = "提交Issue";
239+
static const String issue_edit_issue = "编译Issue";
240+
static const String issue_edit_issue_commit = "编译回复";
237241
}
238242

239243
class GSYICons {

‎lib/common/utils/CommonUtils.dart‎

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,29 @@ class CommonUtils {
8484
});
8585
}
8686

87-
static Future<Null> showEditDialog(BuildContext context) {
87+
static Future<Null> showEditDialog(
88+
BuildContext context,
89+
String dialogTitle,
90+
ValueChanged<String> onTitleChanged,
91+
ValueChanged<String> onContentChanged,
92+
VoidCallback onPressed, {
93+
TextEditingController titleController,
94+
TextEditingController valueController,
95+
bool needTitle = true,
96+
}) {
8897
return showDialog(
8998
context: context,
9099
builder: (BuildContext context) {
91100
return Center(
92-
child: new IssueEditDialog(),
101+
child: new IssueEditDialog(
102+
dialogTitle,
103+
onTitleChanged,
104+
onContentChanged,
105+
onPressed,
106+
titleController: valueController,
107+
valueController: valueController,
108+
needTitle: needTitle,
109+
),
93110
);
94111
});
95112
}

‎lib/page/IssueDetailPage.dart‎

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,12 @@ class _IssueDetailPageState extends GSYListState<IssueDetailPage> {
3939

4040
IssueHeaderViewModel issueHeaderViewModel = new IssueHeaderViewModel();
4141

42+
TextEditingController issueInfoTitleControl = new TextEditingController();
43+
44+
TextEditingController issueInfoValueControl = new TextEditingController();
45+
46+
TextEditingController issueInfoCommitValueControl = new TextEditingController();
47+
4248
_IssueDetailPageState(this.issueNum, this.userName, this.reposName);
4349

4450
_renderEventItem(index) {
@@ -77,15 +83,21 @@ class _IssueDetailPageState extends GSYListState<IssueDetailPage> {
7783
: <Widget>[
7884
new FlatButton(
7985
onPressed: () {
80-
/*return ReposDao.doRepositoryStarDao(userName, reposName, bottomStatusModel.star).then((result) {
81-
_getHeaderInfo();
82-
Navigator.pop(context);
83-
});*/
84-
CommonUtils.showEditDialog(context);
86+
//回复 Info
87+
CommonUtils.showEditDialog(context, GSYStrings.issue_reply_issue, null, (replyContent) {}, () {}, needTitle: false);
8588
},
8689
child: new Text(GSYStrings.issue_reply, style: GSYConstant.smallText)),
8790
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)),
91+
new FlatButton(
92+
onPressed: () {
93+
String title = issueHeaderViewModel.issueDes;
94+
String content = issueHeaderViewModel.issueDesHtml;
95+
issueInfoTitleControl = new TextEditingController();
96+
issueInfoValueControl = new TextEditingController();
97+
//编译Issue Info
98+
CommonUtils.showEditDialog(context, GSYStrings.issue_edit_issue, (titleValue) {}, (contentValue) {}, () {}, needTitle: true);
99+
},
100+
child: new Text(GSYStrings.issue_edit, style: GSYConstant.smallText)),
89101
new Container(width: 0.3, height: 30.0, color: Color(GSYColors.subLightTextColor)),
90102
new FlatButton(
91103
onPressed: () {

‎lib/widget/IssueEditDIalog.dart‎

Lines changed: 62 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,59 @@ import 'package:gsy_github_app_flutter/widget/GSYInputWidget.dart';
99
* on 2018/7/21.
1010
*/
1111
class IssueEditDialog extends StatefulWidget {
12+
final String dialogTitle;
13+
14+
final ValueChanged<String> onTitleChanged;
15+
16+
final ValueChanged<String> onContentChanged;
17+
18+
final VoidCallback onPressed;
19+
20+
final TextEditingController titleController;
21+
22+
final TextEditingController valueController;
23+
24+
final bool needTitle;
25+
26+
IssueEditDialog(this.dialogTitle, this.onContentChanged, this.onTitleChanged, this.onPressed,
27+
{this.titleController, this.valueController, this.needTitle = true});
28+
1229
@override
13-
_IssueEditDialogState createState() => _IssueEditDialogState();
30+
_IssueEditDialogState createState() =>
31+
_IssueEditDialogState(this.dialogTitle, this.onContentChanged, this.onTitleChanged, this.onPressed, titleController, valueController, needTitle);
1432
}
1533

1634
class _IssueEditDialogState extends State<IssueEditDialog> {
35+
final String dialogTitle;
36+
37+
final ValueChanged<String> onTitleChanged;
38+
39+
final ValueChanged<String> onContentChanged;
40+
41+
final VoidCallback onPressed;
42+
43+
final TextEditingController titleController;
44+
45+
final TextEditingController valueController;
46+
47+
final bool needTitle;
48+
49+
_IssueEditDialogState(
50+
this.dialogTitle, this.onContentChanged, this.onTitleChanged, this.onPressed, this.titleController, this.valueController, this.needTitle);
51+
1752
@override
1853
Widget build(BuildContext context) {
54+
Widget title = (needTitle)
55+
? new Padding(
56+
padding: new EdgeInsets.all(5.0),
57+
child: new GSYInputWidget(
58+
onChanged: onTitleChanged,
59+
controller: titleController,
60+
hintText: GSYStrings.login_password_hint_text,
61+
obscureText: false,
62+
))
63+
: new Container();
64+
1965
return new GSYCardItem(
2066
margin: EdgeInsets.all(30.0),
2167
shape: new RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(10.0))),
@@ -24,13 +70,12 @@ class _IssueEditDialogState extends State<IssueEditDialog> {
2470
child: new Column(
2571
mainAxisSize: MainAxisSize.min,
2672
children: <Widget>[
27-
new Container(height: 10.0),
28-
new Center(child: new Text("Title")),
29-
new GSYInputWidget(
30-
hintText: GSYStrings.login_password_hint_text,
31-
obscureText: false,
32-
),
33-
new Container(height: 10.0),
73+
new Padding(
74+
padding: new EdgeInsets.all(5.0),
75+
child: new Center(
76+
child: new Text(dialogTitle, style: GSYConstant.smallTextBold),
77+
)),
78+
title,
3479
new Container(
3580
height: 300.0,
3681
decoration: new BoxDecoration(
@@ -41,6 +86,8 @@ class _IssueEditDialogState extends State<IssueEditDialog> {
4186
padding: new EdgeInsets.only(left: 20.0, top: 12.0, right: 20.0, bottom: 12.0),
4287
child: new TextField(
4388
autofocus: false,
89+
onChanged: onContentChanged,
90+
controller: valueController,
4491
decoration: new InputDecoration.collapsed(
4592
hintText: GSYStrings.repos_issue_search,
4693
hintStyle: GSYConstant.middleSubText,
@@ -52,9 +99,14 @@ class _IssueEditDialogState extends State<IssueEditDialog> {
5299
new Row(
53100
crossAxisAlignment: CrossAxisAlignment.center,
54101
children: <Widget>[
55-
new Expanded(child: new FlatButton(child: new Text("FFF"), onPressed: () {})),
102+
new Expanded(
103+
child: new FlatButton(
104+
child: new Text(GSYStrings.app_cancel),
105+
onPressed: () {
106+
Navigator.pop(context);
107+
})),
56108
new Container(width: 0.3, height: 30.0, color: Color(GSYColors.subTextColor)),
57-
new Expanded(child: new FlatButton(child: new Text("FFF"), onPressed: () {})),
109+
new Expanded(child: new FlatButton(child: new Text(GSYStrings.app_cancel), onPressed: () {})),
58110
],
59111
)
60112
],

‎lib/widget/IssueHeaderItem.dart‎

Lines changed: 58 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -54,53 +54,68 @@ class IssueHeaderItem extends StatelessWidget {
5454
onPressed: onPressed,
5555
child: new Padding(
5656
padding: new EdgeInsets.all(10.0),
57-
child: new Row(crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[
58-
new IconButton(
59-
icon: new ClipOval(
60-
child: new FadeInImage.assetNetwork(
61-
placeholder: "static/images/logo.png",
62-
//预览图
63-
fit: BoxFit.fitWidth,
64-
image: issueHeaderViewModel.actionUserPic,
65-
width: 80.0,
66-
height: 80.0,
67-
),
68-
),
69-
onPressed: () {
70-
NavigatorUtils.goPerson(context, issueHeaderViewModel.actionUser);
71-
}),
72-
new Expanded(
73-
child: Column(
74-
mainAxisSize: MainAxisSize.min,
57+
child: new Column(
58+
children: <Widget>[
59+
new Row(
60+
crossAxisAlignment: CrossAxisAlignment.start,
7561
children: <Widget>[
76-
new Row(
77-
children: <Widget>[
78-
new Expanded(child: new Text(issueHeaderViewModel.actionUser, style: GSYConstant.normalTextWhite)),
79-
new Text(
80-
issueHeaderViewModel.actionTime,
81-
style: GSYConstant.subSmallText,
82-
maxLines: 2,
83-
overflow: TextOverflow.ellipsis,
84-
),
85-
],
86-
),
87-
new Padding(padding: new EdgeInsets.all(2.0)),
88-
bottomContainer,
89-
new Container(
90-
child: new Text(
91-
issueHeaderViewModel.issueComment,
92-
style: GSYConstant.smallTextWhite,
93-
maxLines: 2,
62+
new IconButton(
63+
icon: new ClipOval(
64+
child: new FadeInImage.assetNetwork(
65+
placeholder: "static/images/logo.png",
66+
//预览图
67+
fit: BoxFit.fitWidth,
68+
image: issueHeaderViewModel.actionUserPic,
69+
width: 80.0,
70+
height: 80.0,
71+
),
9472
),
95-
margin: new EdgeInsets.only(top: 6.0, bottom: 2.0),
96-
alignment: Alignment.topLeft),
97-
new Padding(
98-
padding: new EdgeInsets.only(left: 0.0, top: 2.0, right: 0.0, bottom: 0.0),
73+
onPressed: () {
74+
NavigatorUtils.goPerson(context, issueHeaderViewModel.actionUser);
75+
}),
76+
new Expanded(
77+
child: Column(
78+
mainAxisSize: MainAxisSize.min,
79+
children: <Widget>[
80+
new Row(
81+
children: <Widget>[
82+
new Expanded(child: new Text(issueHeaderViewModel.actionUser, style: GSYConstant.normalTextWhite)),
83+
new Text(
84+
issueHeaderViewModel.actionTime,
85+
style: GSYConstant.subSmallText,
86+
maxLines: 2,
87+
overflow: TextOverflow.ellipsis,
88+
),
89+
],
90+
),
91+
new Padding(padding: new EdgeInsets.all(2.0)),
92+
bottomContainer,
93+
new Container(
94+
child: new Text(
95+
issueHeaderViewModel.issueComment,
96+
style: GSYConstant.smallTextWhite,
97+
maxLines: 2,
98+
),
99+
margin: new EdgeInsets.only(top: 6.0, bottom: 2.0),
100+
alignment: Alignment.topLeft),
101+
new Padding(
102+
padding: new EdgeInsets.only(left: 0.0, top: 2.0, right: 0.0, bottom: 0.0),
103+
),
104+
],
105+
),
99106
),
100107
],
101108
),
102-
),
103-
]),
109+
new Container(
110+
child: new Text(
111+
issueHeaderViewModel.issueDesHtml,
112+
style: GSYConstant.smallTextWhite,
113+
maxLines: 2,
114+
),
115+
margin: new EdgeInsets.all(10.0),
116+
alignment: Alignment.topLeft)
117+
],
118+
),
104119
),
105120
),
106121
);
@@ -129,7 +144,7 @@ class IssueHeaderViewModel {
129144
closed_by = issueMap["closed_by"] != null ? issueMap["closed_by"]["login"] : "";
130145
locked = issueMap["locked"];
131146
issueComment = issueMap["title"];
132-
issueDesHtml = issueMap["body_html"] != null ? issueMap["body_html"] : "";
147+
issueDesHtml = issueMap["body_html"] != null ? issueMap["body_html"] : (issueMap["body"] != null) ? issueMap["body"] : "";
133148
commentCount = issueMap["comments"].toString() + "";
134149
state = issueMap["state"];
135150
issueDes = issueMap["body"] != null ? ": \n" + issueMap["body"] : '';

0 commit comments

Comments
 (0)