@@ -3,6 +3,7 @@ import 'package:efox_flutter/lang/index.dart' show AppLocalizations;
3
3
import 'package:efox_flutter/store/index.dart' show Store, UserModel;
4
4
import 'package:efox_flutter/store/objects/flutter_ui_issues.dart' show IssuesContent;
5
5
import 'package:efox_flutter/store/objects/issues_comment.dart' show IssuesDetails;
6
+ import 'package:efox_flutter/page/app_login/index.dart' as LoginIndex;
6
7
7
8
class Index extends StatefulWidget {
8
9
int indexes;
@@ -12,6 +13,17 @@ class Index extends StatefulWidget {
12
13
}
13
14
14
15
class _IndexState extends State <Index > {
16
+ final TextEditingController _controller = TextEditingController ();
17
+ var _getComment;
18
+ bool isCanSend = false ;
19
+
20
+ @override
21
+ void initState () {
22
+ // TODO: implement initState
23
+ super .initState ();
24
+ _getComment = this ._getIssueComment (context);
25
+ }
26
+
15
27
@override
16
28
Widget build (BuildContext context) {
17
29
return Scaffold (
@@ -22,9 +34,15 @@ class _IndexState extends State<Index> {
22
34
AppLocalizations .$t ('title_comment_detials' )
23
35
),
24
36
),
25
- body: Container (
26
- child: _ContentList (context)
27
- ),
37
+ body: Stack (
38
+ children: < Widget > [
39
+ Container (
40
+ margin: EdgeInsets .only (bottom: 50 ),
41
+ child: _ContentList (context),
42
+ ),
43
+ _SendComment (context)
44
+ ],
45
+ )
28
46
);
29
47
}
30
48
@@ -79,7 +97,7 @@ class _IndexState extends State<Index> {
79
97
80
98
Widget _CommentContent (BuildContext context) {
81
99
return FutureBuilder (
82
- future: _getIssueComment (context) ,
100
+ future: _getComment ,
83
101
builder: (BuildContext context, AsyncSnapshot snapshot) {
84
102
if (snapshot.connectionState == ConnectionState .waiting) {
85
103
return Container (
@@ -112,8 +130,8 @@ class _IndexState extends State<Index> {
112
130
}
113
131
114
132
Future <String > _getIssueComment (BuildContext context) async {
115
- IssuesContent issuesContent = Store .value <UserModel >(context ).flutter_ui_issues.issuesContent[widget.indexes];
116
- await Store .value <UserModel >(context ).getIssueComment (issuesContent.number);
133
+ IssuesContent issuesContent = Store .valueNotCtx <UserModel >().flutter_ui_issues.issuesContent[widget.indexes];
134
+ await Store .valueNotCtx <UserModel >().getIssueComment (issuesContent.number);
117
135
return 'end' ;
118
136
}
119
137
@@ -136,4 +154,120 @@ class _IndexState extends State<Index> {
136
154
),
137
155
);
138
156
}
157
+
158
+ Widget _SendComment (BuildContext context) {
159
+ return Positioned (
160
+ bottom: 0 ,
161
+ left: 0 ,
162
+ child: Container (
163
+ width: MediaQuery .of (context).size.width,
164
+ height: 50 ,
165
+ decoration: BoxDecoration (
166
+ color: Colors .white,
167
+ border: Border (
168
+ top: BorderSide (width: 0.5 , color: Color (int .parse ('0xffe4e4e4' )))
169
+ )
170
+ ),
171
+ child: Row (
172
+ children: < Widget > [
173
+ Expanded (
174
+ flex: 1 ,
175
+ child: _InputBox (),
176
+ ),
177
+ Store .connect <UserModel >(
178
+ builder: (context, child, model) {
179
+ IssuesContent issuesContent = model.flutter_ui_issues.issuesContent[widget.indexes];
180
+ return GestureDetector (
181
+ onTap: () async {
182
+ if (isCanSend) {
183
+ if (model.user.id != null ) {
184
+ print ('发布内容:${_controller .text }' );
185
+ bool isSendSuccess = await model.setIssueComment (
186
+ _controller.text,
187
+ issuesContent.number
188
+ );
189
+ if (isSendSuccess) {
190
+ await this ._getIssueComment (context);
191
+ _controller.text = '' ;
192
+ } else {
193
+ print ('网络错误' );
194
+ Scaffold .of (context).showSnackBar (SnackBar (
195
+ content: Text ('网络出错,请稍后重试' ),
196
+ ));
197
+ }
198
+ } else {
199
+ print ('去往登陆' );
200
+ Navigator .of (context).push (
201
+ MaterialPageRoute (
202
+ builder: (BuildContext context) {
203
+ return LoginIndex .Index ();
204
+ }
205
+ )
206
+ );
207
+ }
208
+ }
209
+ },
210
+ child: Container (
211
+ padding: EdgeInsets .fromLTRB (0 , 0 , 10 , 0 ),
212
+ child: Text (
213
+ '发布' ,
214
+ style: TextStyle (
215
+ color: isCanSend ? Theme .of (context).primaryColor : Colors .grey,
216
+ fontSize: 17
217
+ )
218
+ ),
219
+ ),
220
+ );
221
+ }
222
+ )
223
+ ],
224
+ )
225
+ ),
226
+ );
227
+ }
228
+ Widget _InputBox () {
229
+ return Container (
230
+ height: 30 ,
231
+ margin: EdgeInsets .fromLTRB (10 , 10 , 10 , 10 ),
232
+ decoration: BoxDecoration (
233
+ color: Color (int .parse ('0xffEDEDED' )),
234
+ borderRadius: BorderRadius .circular (15 )
235
+ ),
236
+ child: Row (
237
+ children: < Widget > [
238
+ Expanded (
239
+ flex: 1 ,
240
+ child: TextField (
241
+ controller: _controller,
242
+ autofocus: false ,
243
+ onChanged: _onChanged,
244
+ style: TextStyle (
245
+ fontSize: 18.0 ,
246
+ color: Colors .black,
247
+ fontWeight: FontWeight .w300
248
+ ),
249
+ decoration: InputDecoration (
250
+ contentPadding: EdgeInsets .fromLTRB (10 , 0 , 10 , 0 ),
251
+ border: InputBorder .none,
252
+ hintText: '说点什么吧' ,
253
+ hintStyle: TextStyle (fontSize: 15 )
254
+ ),
255
+ ),
256
+ )
257
+ ],
258
+ )
259
+ );
260
+ }
261
+
262
+ _onChanged (String text) {
263
+ if (text.length > 0 ) {
264
+ setState (() {
265
+ isCanSend = true ;
266
+ });
267
+ } else {
268
+ setState (() {
269
+ isCanSend = false ;
270
+ });
271
+ }
272
+ }
139
273
}
0 commit comments