Skip to content

Commit 20c925c

Browse files
committed
增加issue 快速输入
1 parent 6459c8c commit 20c925c

5 files changed

Lines changed: 105 additions & 18 deletions

File tree

‎VERSION.md‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,20 @@
1313
* 多语言、主题。
1414
* 本地阅读历史。
1515
* 个人动态表。
16-
17-
* issue尝试换成htmlview
1816
* markdown点击跳转。
1917
* webview点击跳转。
2018
* markdown htmlview 表格。
19+
* issue输入框的快速按键。
2120

2221
### 1.0.2 (更新中)
2322

2423
* 启动页变形问题。
2524
* 触摸隐藏键盘。
26-
* issue 输入框的快速按键和键盘收起问题。
2725
* 点击检测版本。
2826
* 个人页面数字字体动态大小。
2927
* 趋势语言,搜索语言加dart。
3028
* 前后台切换刷新动态。
29+
* issue使用markdown解析
3130

3231

3332
### 1.0.1 (已发布)

‎lib/common/style/GSYStyle.dart‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,17 @@ class GSYICons {
367367
static const IconData ISSUE_ITEM_COMMENT = const IconData(0xe6ba, fontFamily: GSYICons.FONT_FAMILY);
368368
static const IconData ISSUE_ITEM_ADD = const IconData(0xe662, fontFamily: GSYICons.FONT_FAMILY);
369369

370+
371+
372+
static const IconData ISSUE_EDIT_H1 = Icons.filter_1;
373+
static const IconData ISSUE_EDIT_H2 = Icons.filter_2;
374+
static const IconData ISSUE_EDIT_H3 = Icons.filter_3;
375+
static const IconData ISSUE_EDIT_BOLD = Icons.format_bold;
376+
static const IconData ISSUE_EDIT_ITALIC = Icons.format_italic;
377+
static const IconData ISSUE_EDIT_QUOTE = Icons.format_quote;
378+
static const IconData ISSUE_EDIT_CODE = Icons.format_shapes;
379+
static const IconData ISSUE_EDIT_LINK = Icons.insert_link;
380+
370381
static const IconData NOTIFY_ALL_READ = const IconData(0xe62f, fontFamily: GSYICons.FONT_FAMILY);
371382

372383
static const IconData PUSH_ITEM_EDIT = Icons.mode_edit;

‎lib/page/RepositoryDetailIssueListPage.dart‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@ class _RepositoryDetailIssuePageState extends GSYListState<RepositoryDetailIssue
101101
});
102102
},
103103
needTitle: true,
104+
titleController: new TextEditingController(),
105+
valueController: new TextEditingController()
104106
);
105107
}
106108

‎lib/widget/HomeDrawer.dart‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ class HomeDrawer extends StatelessWidget {
8484
Navigator.pop(context);
8585
Navigator.pop(context);
8686
});
87-
}, needTitle: false);
87+
}, titleController: new TextEditingController(), valueController: new TextEditingController(), needTitle: false);
8888
}),
8989
new ListTile(
9090
title: new Text(

‎lib/widget/IssueEditDIalog.dart‎

Lines changed: 89 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ class _IssueEditDialogState extends State<IssueEditDialog> {
4949
_IssueEditDialogState(
5050
this.dialogTitle, this.onTitleChanged, this.onContentChanged, this.onPressed, this.titleController, this.valueController, this.needTitle);
5151

52-
@override
53-
Widget build(BuildContext context) {
54-
Widget title = (needTitle)
52+
///标题输入框
53+
renderTitleInput() {
54+
return (needTitle)
5555
? new Padding(
5656
padding: new EdgeInsets.all(5.0),
5757
child: new GSYInputWidget(
@@ -61,11 +61,51 @@ class _IssueEditDialogState extends State<IssueEditDialog> {
6161
obscureText: false,
6262
))
6363
: new Container();
64+
}
6465

66+
///快速输入框
67+
_renderFastInputContainer() {
68+
///因为是Column下包含了ListView,所以需要设置高度
69+
return new Container(
70+
height: 30.0,
71+
child: ListView.builder(
72+
scrollDirection: Axis.horizontal,
73+
itemBuilder: (context, index) {
74+
return new RawMaterialButton(
75+
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
76+
padding: EdgeInsets.only(left: 8.0, right: 8.0, top: 5.0, bottom: 5.0),
77+
constraints: const BoxConstraints(minWidth: 0.0, minHeight: 0.0),
78+
child: Icon(FAST_INPUT_LIST[index].iconData, size: 16.0),
79+
onPressed: () {
80+
String text = FAST_INPUT_LIST[index].content;
81+
String newText = "";
82+
if (valueController.value != null) {
83+
newText = valueController.value.text;
84+
}
85+
newText = newText + text;
86+
print("fffff");
87+
print(newText);
88+
setState(() {
89+
valueController.value = new TextEditingValue(text: newText);
90+
});
91+
if (onContentChanged != null) {
92+
onContentChanged(newText);
93+
}
94+
});
95+
},
96+
itemCount: FAST_INPUT_LIST.length,
97+
),
98+
);
99+
}
100+
101+
@override
102+
Widget build(BuildContext context) {
65103
return new Container(
66104
height: MediaQuery.of(context).size.height,
67105
width: MediaQuery.of(context).size.width,
68106
color: Colors.black12,
107+
108+
///触摸收起键盘
69109
child: new GestureDetector(
70110
behavior: HitTestBehavior.translucent,
71111
onTap: () {
@@ -80,12 +120,17 @@ class _IssueEditDialogState extends State<IssueEditDialog> {
80120
child: new Column(
81121
mainAxisSize: MainAxisSize.min,
82122
children: <Widget>[
123+
///dialog标题
83124
new Padding(
84125
padding: new EdgeInsets.only(top: 5.0, bottom: 15.0),
85126
child: new Center(
86127
child: new Text(dialogTitle, style: GSYConstant.normalTextBold),
87128
)),
88-
title,
129+
130+
///标题输入框
131+
renderTitleInput(),
132+
133+
///内容输入框
89134
new Container(
90135
height: MediaQuery.of(context).size.width * 3 / 4,
91136
decoration: new BoxDecoration(
@@ -94,22 +139,32 @@ class _IssueEditDialogState extends State<IssueEditDialog> {
94139
border: new Border.all(color: Color(GSYColors.subTextColor), width: .3),
95140
),
96141
padding: new EdgeInsets.only(left: 20.0, top: 12.0, right: 20.0, bottom: 12.0),
97-
child: new TextField(
98-
autofocus: false,
99-
maxLines: 999,
100-
onChanged: onContentChanged,
101-
controller: valueController,
102-
decoration: new InputDecoration.collapsed(
103-
hintText: GSYStrings.issue_edit_issue_title_tip,
104-
hintStyle: GSYConstant.middleSubText,
105-
),
106-
style: GSYConstant.middleText,
142+
child: new Column(
143+
children: <Widget>[
144+
new Expanded(
145+
child: new TextField(
146+
autofocus: false,
147+
maxLines: 999,
148+
onChanged: onContentChanged,
149+
controller: valueController,
150+
decoration: new InputDecoration.collapsed(
151+
hintText: GSYStrings.issue_edit_issue_title_tip,
152+
hintStyle: GSYConstant.middleSubText,
153+
),
154+
style: GSYConstant.middleText,
155+
),
156+
),
157+
158+
///快速输入框
159+
_renderFastInputContainer(),
160+
],
107161
),
108162
),
109163
new Container(height: 10.0),
110164
new Row(
111165
crossAxisAlignment: CrossAxisAlignment.center,
112166
children: <Widget>[
167+
///取消
113168
new Expanded(
114169
child: new RawMaterialButton(
115170
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
@@ -120,6 +175,8 @@ class _IssueEditDialogState extends State<IssueEditDialog> {
120175
Navigator.pop(context);
121176
})),
122177
new Container(width: 0.3, height: 25.0, color: Color(GSYColors.subTextColor)),
178+
179+
///确定
123180
new Expanded(
124181
child: new RawMaterialButton(
125182
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
@@ -138,3 +195,21 @@ class _IssueEditDialogState extends State<IssueEditDialog> {
138195
);
139196
}
140197
}
198+
199+
var FAST_INPUT_LIST = [
200+
FastInputIconModel(GSYICons.ISSUE_EDIT_H1, "\n# "),
201+
FastInputIconModel(GSYICons.ISSUE_EDIT_H2, "\n## "),
202+
FastInputIconModel(GSYICons.ISSUE_EDIT_H3, "\n### "),
203+
FastInputIconModel(GSYICons.ISSUE_EDIT_BOLD, "****"),
204+
FastInputIconModel(GSYICons.ISSUE_EDIT_ITALIC, "__"),
205+
FastInputIconModel(GSYICons.ISSUE_EDIT_QUOTE, "` `"),
206+
FastInputIconModel(GSYICons.ISSUE_EDIT_CODE, " \n``` \n\n``` \n"),
207+
FastInputIconModel(GSYICons.ISSUE_EDIT_LINK, "[](url)"),
208+
];
209+
210+
class FastInputIconModel {
211+
final IconData iconData;
212+
final String content;
213+
214+
FastInputIconModel(this.iconData, this.content);
215+
}

0 commit comments

Comments
 (0)