842b7132
liangchengyou
feat:磨耳朵/练习页面调整
|
1
2
3
|
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
e3c2820c
liangchengyou
feat:先声SDK逻辑调整
|
4
|
import 'package:wow_english/common/core/user_util.dart';
|
842b7132
liangchengyou
feat:磨耳朵/练习页面调整
|
5
6
|
import 'package:wow_english/common/extension/string_extension.dart';
import 'package:wow_english/common/widgets/ow_image_widget.dart';
|
2eb67dd4
liangchengyou
feat:调整代码
|
7
|
import 'package:wow_english/models/course_process_entity.dart';
|
842b7132
liangchengyou
feat:磨耳朵/练习页面调整
|
8
9
10
11
12
13
14
15
16
17
|
import 'bloc/topic_picture_bloc.dart';
import 'widgets/practice_header_widget.dart';
class TopicPicturePage extends StatelessWidget {
const TopicPicturePage({super.key});
@override
Widget build(BuildContext context) {
return BlocProvider(
|
2eb67dd4
liangchengyou
feat:调整代码
|
18
19
20
21
22
|
create: (context) => TopicPictureBloc(
PageController(),
3
)
..add(RequestDataEvent())
|
e3c2820c
liangchengyou
feat:先声SDK逻辑调整
|
23
24
25
26
27
28
29
|
..add(XSVoiceInitEvent(
{
'appKey':'a418',
'secretKey':'1a16f31f2611bf32fb7b3fc38f5b2c81',
'userId':UserUtil.getUser()!.id
}
)),
|
842b7132
liangchengyou
feat:磨耳朵/练习页面调整
|
30
31
32
33
34
35
36
37
38
|
child: _TopicPicturePage(),
);
}
}
class _TopicPicturePage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return BlocListener<TopicPictureBloc,TopicPictureState>(
|
2eb67dd4
liangchengyou
feat:调整代码
|
39
40
|
listener: (context, state){
if (state is RequestDataState) {
|
e3c2820c
liangchengyou
feat:先声SDK逻辑调整
|
41
42
43
44
45
|
// context.read<TopicPictureBloc>().add(CurrentPageIndexChangeEvent(0));
}
if (state is XSVoiceTestState) {
|
2eb67dd4
liangchengyou
feat:调整代码
|
46
47
|
}
},
|
842b7132
liangchengyou
feat:磨耳朵/练习页面调整
|
48
49
50
51
52
|
child: _topicPictureView(),
);
}
Widget _topicPictureView() => BlocBuilder<TopicPictureBloc,TopicPictureState>(
|
842b7132
liangchengyou
feat:磨耳朵/练习页面调整
|
53
54
55
56
57
58
59
60
61
|
builder: (context,state){
final bloc = BlocProvider.of<TopicPictureBloc>(context);
return Container(
color: Colors.white,
child: Stack(
children: [
Column(
children: [
PracticeHeaderWidget(
|
2eb67dd4
liangchengyou
feat:调整代码
|
62
|
title: '${bloc.currentPage}/${bloc.entity?.topics?.length}',
|
e3c2820c
liangchengyou
feat:先声SDK逻辑调整
|
63
64
65
66
|
onTap: (){
bloc.add(XSVoiceTestEvent('Hello', 0,UserUtil.getUser()!.id));
// Navigator.pop(context);
},
|
842b7132
liangchengyou
feat:磨耳朵/练习页面调整
|
67
68
69
|
),
Expanded(
child: PageView.builder(
|
2eb67dd4
liangchengyou
feat:调整代码
|
70
|
itemCount: bloc.entity?.topics?.length,
|
842b7132
liangchengyou
feat:磨耳朵/练习页面调整
|
71
72
73
74
75
76
|
scrollDirection: Axis.horizontal,
controller: bloc.pageController,
onPageChanged: (int index) {
bloc.add(CurrentPageIndexChangeEvent(index));
},
itemBuilder: (BuildContext context,int index){
|
2eb67dd4
liangchengyou
feat:调整代码
|
77
78
79
80
81
82
83
84
85
86
87
|
CourseProcessTopics? topics = bloc.entity?.topics![index];
if (topics?.type == 1) {//听音选图
return _pageViewVoicePictureItemWidget(topics);
} else if (topics?.type == 2) {//听音选字
return _pageViewVoiceWordItemWidget(topics);
} else if (topics?.type == 3) {//看题选字
return _pageViewWordItemWidget(topics);
} else if (topics?.type == 4) {//看题选图
return _pageViewItemWidget(topics);
} else {//语音问答
return _voiceAnswerItem(topics);
|
842b7132
liangchengyou
feat:磨耳朵/练习页面调整
|
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
|
}
}),
)
],
),
Positioned(
left: 0,
right: 0,
bottom: 0,
child: Image.asset('bottom_grass'.assetPng)
)
],
),
);
});
///看题选图
|
2eb67dd4
liangchengyou
feat:调整代码
|
105
|
Widget _pageViewItemWidget(CourseProcessTopics? topics) => BlocBuilder<TopicPictureBloc,TopicPictureState>(
|
842b7132
liangchengyou
feat:磨耳朵/练习页面调整
|
106
|
builder: (context, state){
|
842b7132
liangchengyou
feat:磨耳朵/练习页面调整
|
107
108
109
110
111
112
113
114
115
116
117
118
|
return SafeArea(
child: Column(
children: [
Text(
'What to do when the sentence question is very long and needs a line break',
softWrap: true,
style: TextStyle(
fontSize: 21.sp,
color: const Color(0xFF333333)
)
),
26.verticalSpace,
|
2eb67dd4
liangchengyou
feat:调整代码
|
119
120
121
122
123
124
125
126
127
128
|
SizedBox(
height: 143.h,
width: 143.w * (topics?.topicAnswerList?.length??0),
child: ListView.builder(
itemCount: topics?.topicAnswerList?.length??0,
scrollDirection: Axis.horizontal,
itemBuilder: (context,index){
return _decodeImageWidget(index);
}),
),
|
842b7132
liangchengyou
feat:磨耳朵/练习页面调整
|
129
130
131
132
133
134
135
136
137
|
],
),
);
});
Widget _decodeImageWidget(int index) => BlocBuilder<TopicPictureBloc,TopicPictureState>(
buildWhen: (_, s) => s is SelectItemChangeState,
builder: (context,state){
final bloc = BlocProvider.of<TopicPictureBloc>(context);
|
2eb67dd4
liangchengyou
feat:调整代码
|
138
139
140
141
|
return Container(
padding: EdgeInsets.symmetric(horizontal: 10.w),
child: GestureDetector(
onTap: () => bloc.add(SelectItemEvent(index)),
|
842b7132
liangchengyou
feat:磨耳朵/练习页面调整
|
142
|
child: Container(
|
2eb67dd4
liangchengyou
feat:调整代码
|
143
|
padding: const EdgeInsets.all(4.5),
|
842b7132
liangchengyou
feat:磨耳朵/练习页面调整
|
144
|
decoration: BoxDecoration(
|
2eb67dd4
liangchengyou
feat:调整代码
|
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
|
color: bloc.selectItem == index?const Color(0xFF00B6F1):Colors.white,
borderRadius: BorderRadius.circular(15),
),
height: 143.h,
width: 143.w,
child: Container(
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(15),
border: Border.all(
width: 1.0,
color: const Color(0xFF140C10)
),
image: const DecorationImage(
fit: BoxFit.fitWidth,
image: NetworkImage('https://img1.baidu.com/it/u=3392591833,1640391553&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=714')
)
),
|
842b7132
liangchengyou
feat:磨耳朵/练习页面调整
|
163
164
165
166
167
168
169
|
),
),
),
);
});
///看题选字
|
2eb67dd4
liangchengyou
feat:调整代码
|
170
|
Widget _pageViewWordItemWidget(CourseProcessTopics? topics) => BlocBuilder<TopicPictureBloc,TopicPictureState>(
|
842b7132
liangchengyou
feat:磨耳朵/练习页面调整
|
171
172
173
174
175
176
177
178
179
180
181
182
183
184
|
builder: (context, state){
final bloc = BlocProvider.of<TopicPictureBloc>(context);
return SafeArea(
child: Column(
children: [
Text(
'What to do when the sentence question is very long and needs a line break',
softWrap: true,
style: TextStyle(
fontSize: 21.sp,
color: const Color(0xFF333333)
)
),
26.verticalSpace,
|
2eb67dd4
liangchengyou
feat:调整代码
|
185
186
187
188
189
190
191
192
193
194
|
SizedBox(
height: 143.h,
width: 143.w * (topics?.topicAnswerList?.length??0),
child: ListView.builder(
itemCount: topics?.topicAnswerList?.length??0,
scrollDirection: Axis.horizontal,
itemBuilder: (context,index){
return _decodeWordWidget(index);
}),
),
|
842b7132
liangchengyou
feat:磨耳朵/练习页面调整
|
195
196
197
198
199
200
201
202
203
|
],
),
);
});
Widget _decodeWordWidget(int index) => BlocBuilder<TopicPictureBloc,TopicPictureState>(
buildWhen: (_, s) => s is SelectItemChangeState,
builder: (context,state){
final bloc = BlocProvider.of<TopicPictureBloc>(context);
|
2eb67dd4
liangchengyou
feat:调整代码
|
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
|
return Container(
padding: EdgeInsets.symmetric(horizontal: 10.w),
child: GestureDetector(
onTap: () => bloc.add(SelectItemEvent(index)),
child: Container(
width: 143.w,
height: 143.h,
padding: EdgeInsets.only(left: 13.w,right: 13.w,top: 13.h,bottom: 13.h),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(15),
border: Border.all(
width: 1.0,
color: const Color(0xFF140C10)
),
|
842b7132
liangchengyou
feat:磨耳朵/练习页面调整
|
219
|
),
|
2eb67dd4
liangchengyou
feat:调整代码
|
220
221
222
223
224
225
226
227
228
229
230
231
232
|
child: Column(
mainAxisAlignment: MainAxisAlignment.end,
children: [
Expanded(
child: Container(
alignment: Alignment.center,
child: Text(
'yellow',
style: TextStyle(
fontSize: 20.sp,
color: const Color(0xFF333333)
)
),
|
842b7132
liangchengyou
feat:磨耳朵/练习页面调整
|
233
234
|
),
),
|
2eb67dd4
liangchengyou
feat:调整代码
|
235
236
237
238
239
240
241
242
243
244
|
Container(
height: 30.h,
width: double.infinity,
decoration: BoxDecoration(
color: bloc.selectItem == index?const Color(0xFF00B6F1):Colors.white,
borderRadius: BorderRadius.circular(15.r),
border: Border.all(
width: 1.5,
color: const Color(0xFF140C10)
),
|
842b7132
liangchengyou
feat:磨耳朵/练习页面调整
|
245
|
),
|
2eb67dd4
liangchengyou
feat:调整代码
|
246
247
248
249
250
|
alignment: Alignment.center,
child: Image.asset('choose'.assetPng),
)
],
),
|
842b7132
liangchengyou
feat:磨耳朵/练习页面调整
|
251
252
253
254
255
256
|
),
),
);
});
///听音选图
|
2eb67dd4
liangchengyou
feat:调整代码
|
257
|
Widget _pageViewVoicePictureItemWidget(CourseProcessTopics? topics) => BlocBuilder<TopicPictureBloc,TopicPictureState>(
|
842b7132
liangchengyou
feat:磨耳朵/练习页面调整
|
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
|
builder: (context, state){
final bloc = BlocProvider.of<TopicPictureBloc>(context);
return SafeArea(
child: Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Image.asset('voice'.assetPng,height: 33.h,width: 30.w,),
10.horizontalSpace,
Text(
'yellow',
style: TextStyle(
fontSize: 20.sp,
color: const Color(0xFF333333)
)
)
],
),
26.verticalSpace,
|
2eb67dd4
liangchengyou
feat:调整代码
|
278
279
280
281
282
283
284
285
286
287
|
SizedBox(
height: 143.h,
width: 163.w * (topics?.topicAnswerList?.length??0),
child: ListView.builder(
scrollDirection: Axis.horizontal,
itemCount: topics?.topicAnswerList?.length??0,
itemBuilder: (BuildContext context,int index){
return _decodeVoiceImageWidget(1,topics?.topicAnswerList?[index]);
})
,
|
842b7132
liangchengyou
feat:磨耳朵/练习页面调整
|
288
289
290
291
292
293
|
)
],
),
);
});
|
2eb67dd4
liangchengyou
feat:调整代码
|
294
|
Widget _decodeVoiceImageWidget(int index,CourseProcessTopicsTopicAnswerList? answerList) => BlocBuilder<TopicPictureBloc,TopicPictureState>(
|
842b7132
liangchengyou
feat:磨耳朵/练习页面调整
|
295
296
297
|
buildWhen: (_, s) => s is SelectItemChangeState,
builder: (context,state){
final bloc = BlocProvider.of<TopicPictureBloc>(context);
|
2eb67dd4
liangchengyou
feat:调整代码
|
298
299
300
301
|
return Container(
padding: EdgeInsets.symmetric(horizontal: 10.w),
child: GestureDetector(
onTap: () => bloc.add(SelectItemEvent(index)),
|
842b7132
liangchengyou
feat:磨耳朵/练习页面调整
|
302
|
child: Container(
|
2eb67dd4
liangchengyou
feat:调整代码
|
303
|
padding: const EdgeInsets.all(4.5),
|
842b7132
liangchengyou
feat:磨耳朵/练习页面调整
|
304
|
decoration: BoxDecoration(
|
2eb67dd4
liangchengyou
feat:调整代码
|
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
|
color: bloc.selectItem == index?const Color(0xFF00B6F1):Colors.white,
borderRadius: BorderRadius.circular(15),
),
height: 143.h,
width: 143.w,
child: Container(
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(15),
border: Border.all(
width: 1.0,
color: const Color(0xFF140C10)
),
image: const DecorationImage(
fit: BoxFit.fitWidth,
image: NetworkImage('https://img1.baidu.com/it/u=3392591833,1640391553&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=714')
)
),
|
842b7132
liangchengyou
feat:磨耳朵/练习页面调整
|
323
324
325
326
327
328
329
|
),
),
),
);
});
///听音选字
|
2eb67dd4
liangchengyou
feat:调整代码
|
330
|
Widget _pageViewVoiceWordItemWidget(CourseProcessTopics? topics) => BlocBuilder<TopicPictureBloc,TopicPictureState>(
|
842b7132
liangchengyou
feat:磨耳朵/练习页面调整
|
331
332
333
334
335
336
337
|
builder: (context, state){
final bloc = BlocProvider.of<TopicPictureBloc>(context);
return SafeArea(
child: Column(
children: [
Image.asset('voice'.assetPng,height: 33.h,width: 30.w,),
26.verticalSpace,
|
2eb67dd4
liangchengyou
feat:调整代码
|
338
339
340
341
342
343
344
345
346
347
|
SizedBox(
width: 163.w * (topics?.topicAnswerList?.length??0),
height: 143.h,
child: ListView.builder(
itemCount: topics?.topicAnswerList?.length,
scrollDirection: Axis.horizontal,
itemBuilder: (BuildContext context,int index){
return _decodeVoiceWordImageWidget(index, topics!.topicAnswerList![index]);
}),
),
|
842b7132
liangchengyou
feat:磨耳朵/练习页面调整
|
348
349
350
351
352
|
],
),
);
});
|
2eb67dd4
liangchengyou
feat:调整代码
|
353
|
Widget _decodeVoiceWordImageWidget(int index,CourseProcessTopicsTopicAnswerList answerList) => BlocBuilder<TopicPictureBloc,TopicPictureState>(
|
842b7132
liangchengyou
feat:磨耳朵/练习页面调整
|
354
355
356
357
358
359
|
buildWhen: (_, s) => s is SelectItemChangeState,
builder: (context,state){
final bloc = BlocProvider.of<TopicPictureBloc>(context);
return GestureDetector(
onTap: () => bloc.add(SelectItemEvent(index)),
child: Container(
|
2eb67dd4
liangchengyou
feat:调整代码
|
360
|
width: 163.w,
|
842b7132
liangchengyou
feat:磨耳朵/练习页面调整
|
361
|
height: 143.h,
|
2eb67dd4
liangchengyou
feat:调整代码
|
362
363
364
365
366
367
368
369
370
371
372
373
|
padding: EdgeInsets.symmetric(horizontal: 10.w),
child: Container(
width: 143.w,
height: 143.h,
padding: EdgeInsets.only(left: 13.w,right: 13.w,top: 13.h,bottom: 13.h),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(15),
border: Border.all(
width: 1.0,
color: const Color(0xFF140C10)
),
|
842b7132
liangchengyou
feat:磨耳朵/练习页面调整
|
374
|
),
|
2eb67dd4
liangchengyou
feat:调整代码
|
375
376
377
378
379
380
381
382
383
384
385
386
387
|
child: Column(
mainAxisAlignment: MainAxisAlignment.end,
children: [
Expanded(
child: Container(
alignment: Alignment.center,
child: Text(
answerList.word??'',
style: TextStyle(
fontSize: 20.sp,
color: const Color(0xFF333333)
)
),
|
842b7132
liangchengyou
feat:磨耳朵/练习页面调整
|
388
389
|
),
),
|
2eb67dd4
liangchengyou
feat:调整代码
|
390
391
392
393
394
395
396
397
398
399
|
Container(
height: 30.h,
width: double.infinity,
decoration: BoxDecoration(
color: bloc.selectItem == index?const Color(0xFF00B6F1):Colors.white,
borderRadius: BorderRadius.circular(15.r),
border: Border.all(
width: 1.5,
color: const Color(0xFF140C10)
),
|
842b7132
liangchengyou
feat:磨耳朵/练习页面调整
|
400
|
),
|
2eb67dd4
liangchengyou
feat:调整代码
|
401
402
403
404
405
|
alignment: Alignment.center,
child: Image.asset('choose'.assetPng),
)
],
),
|
842b7132
liangchengyou
feat:磨耳朵/练习页面调整
|
406
407
408
409
410
411
|
),
),
);
});
///语音问答
|
2eb67dd4
liangchengyou
feat:调整代码
|
412
|
Widget _voiceAnswerItem(CourseProcessTopics? topics) => BlocBuilder<TopicPictureBloc,TopicPictureState>(
|
842b7132
liangchengyou
feat:磨耳朵/练习页面调整
|
413
|
builder: (context, state) {
|
2eb67dd4
liangchengyou
feat:调整代码
|
414
|
final bloc = BlocProvider.of<TopicPictureBloc>(context);
|
842b7132
liangchengyou
feat:磨耳朵/练习页面调整
|
415
|
return Row(
|
842b7132
liangchengyou
feat:磨耳朵/练习页面调整
|
416
417
|
mainAxisAlignment: MainAxisAlignment.center,
children: [
|
2eb67dd4
liangchengyou
feat:调整代码
|
418
419
420
421
|
OwImageWidget(
name:'https://up.enterdesk.com/edpic_source/16/e7/0d/16e70d550daff77cbac31fae5e1651d4.jpg',
height: 186.h,
width: 186.w,
|
842b7132
liangchengyou
feat:磨耳朵/练习页面调整
|
422
|
),
|
2eb67dd4
liangchengyou
feat:调整代码
|
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
|
160.horizontalSpace,
Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Image.asset(
'voice'.assetPng,
height: 52.h,
width: 46.w,
),
70.verticalSpace,
GestureDetector(
onTap: () {
if (bloc.isVoicing) {
return;
}
|
e3c2820c
liangchengyou
feat:先声SDK逻辑调整
|
438
|
bloc.add(XSVoiceTestEvent('Hello', 0,UserUtil.getUser()!.id));
|
2eb67dd4
liangchengyou
feat:调整代码
|
439
440
441
442
443
444
445
446
|
},
child: Image.asset(
'micro_phone'.assetPng,
height: 75.w,
width: 75.w,
),
)
],
|
842b7132
liangchengyou
feat:磨耳朵/练习页面调整
|
447
448
|
)
],
|
2eb67dd4
liangchengyou
feat:调整代码
|
449
450
|
);
});
|
842b7132
liangchengyou
feat:磨耳朵/练习页面调整
|
451
|
}
|