08a0f5a8
liangchengyou
feat:路由方式更新
|
1
|
import 'package:flutter/material.dart';
|
cb38bc90
liangchengyou
feat:视频跟读逻辑处理
|
2
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
08a0f5a8
liangchengyou
feat:路由方式更新
|
3
4
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:wow_english/common/extension/string_extension.dart';
|
cb38bc90
liangchengyou
feat:视频跟读逻辑处理
|
5
|
import 'package:wow_english/pages/repeataftercontent/bloc/repeat_after_content_bloc.dart';
|
68dd7ba8
liangchengyou
feat:首页主题颜色+已知问题修改
|
6
|
import 'package:wow_english/pages/repeataftercontent/widgets/repeat_after_content_dialog.dart';
|
08a0f5a8
liangchengyou
feat:路由方式更新
|
7
8
|
import 'package:wow_english/route/route.dart';
|
cb38bc90
liangchengyou
feat:视频跟读逻辑处理
|
9
|
import '../../common/core/user_util.dart';
|
9efff6ae
liangchengyou
feat:视频跟读逻辑修改
|
10
|
import '../../models/read_content_entity.dart';
|
d4a7dfc4
liangchengyou
feat:逻辑调整
|
11
|
import '../../utils/toast_util.dart';
|
cb38bc90
liangchengyou
feat:视频跟读逻辑处理
|
12
13
|
import 'widgets/repeat_video_widget.dart';
|
08a0f5a8
liangchengyou
feat:路由方式更新
|
14
|
class RepeatAfterContentPage extends StatelessWidget {
|
cb38bc90
liangchengyou
feat:视频跟读逻辑处理
|
15
16
17
|
const RepeatAfterContentPage({super.key, this.videoFollowReadId});
final String? videoFollowReadId;
|
08a0f5a8
liangchengyou
feat:路由方式更新
|
18
19
20
|
@override
Widget build(BuildContext context) {
|
cb38bc90
liangchengyou
feat:视频跟读逻辑处理
|
21
|
return BlocProvider(
|
0fa4e405
吴启风
feat: 将语音评测从先声迁移至驰声
|
22
|
create: (context) => RepeatAfterContentBloc(videoFollowReadId ?? '')
|
cb38bc90
liangchengyou
feat:视频跟读逻辑处理
|
23
|
..add(InitBlocEvent())
|
0fa4e405
吴启风
feat: 将语音评测从先声迁移至驰声
|
24
|
..add(RequestDataEvent()),
|
cb38bc90
liangchengyou
feat:视频跟读逻辑处理
|
25
26
27
28
29
30
31
32
|
child: _RepeatAfterContentPage(),
);
}
}
class _RepeatAfterContentPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
|
0fa4e405
吴启风
feat: 将语音评测从先声迁移至驰声
|
33
34
|
return BlocListener<RepeatAfterContentBloc, RepeatAfterContentState>(
listener: (context, state) {
|
9efff6ae
liangchengyou
feat:视频跟读逻辑修改
|
35
|
final bloc = BlocProvider.of<RepeatAfterContentBloc>(context);
|
0fa4e405
吴启风
feat: 将语音评测从先声迁移至驰声
|
36
37
38
39
40
41
42
43
|
if (state is VoiceRecordStateChange) {
//录音状态回调
if (bloc.voiceRecordState == VoiceRecordState.voiceRecordEnd) {
//声音录制结束
ReadContentEntity? readContentEntity =
bloc.entityList?[bloc.currentPlayIndex];
bloc.add(XSVoiceTestEvent(readContentEntity?.word ?? '', '0',
UserUtil.getUser()!.id.toString()));
|
9efff6ae
liangchengyou
feat:视频跟读逻辑修改
|
44
45
46
|
}
return;
}
|
cb38bc90
liangchengyou
feat:视频跟读逻辑处理
|
47
48
49
50
51
|
},
child: _repeatAfterContentView(),
);
}
|
0fa4e405
吴启风
feat: 将语音评测从先声迁移至驰声
|
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
Widget _repeatAfterContentView() =>
BlocBuilder<RepeatAfterContentBloc, RepeatAfterContentState>(
builder: (context, state) {
final bloc = BlocProvider.of<RepeatAfterContentBloc>(context);
final String videoUrl = bloc.entityList?.first?.videoUrl ?? '';
return Container(
color: Colors.white,
child: SafeArea(
child: Stack(
children: [
///返回
Positioned(
child: GestureDetector(
onTap: () {
showDialog<RepeatAfterContentDialog>(
context: context,
builder: (context) {
return RepeatAfterContentDialog(() {
popPage();
});
});
// popPage();
},
child: Image.asset(
'back_around'.assetPng,
height: 40.h,
width: 40.w,
),
|
cb38bc90
liangchengyou
feat:视频跟读逻辑处理
|
80
81
|
),
),
|
0fa4e405
吴启风
feat: 将语音评测从先声迁移至驰声
|
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
///左侧视频区
Positioned(
top: 40.h,
left: 20.w,
child: Container(
width: 285.w,
height: 299.h,
padding:
EdgeInsets.symmetric(horizontal: 50.w, vertical: 50.h),
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage('video_background'.assetPng),
fit: BoxFit.fill),
),
child: videoUrl.isEmpty
? Container()
: RepeatVideoWidget(
videoUrl: bloc.entityList?.first?.videoUrl,
videoUrls: bloc.entityList ?? [],
),
|
cb38bc90
liangchengyou
feat:视频跟读逻辑处理
|
103
104
|
),
),
|
0fa4e405
吴启风
feat: 将语音评测从先声迁移至驰声
|
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
|
///右侧操作区
Positioned(
top: 40.h,
left: 331.w,
child: Container(
width: 240.w,
height: 299.h,
padding: EdgeInsets.only(left: 67.w, bottom: 40.h),
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage('light_ground'.assetPng),
fit: BoxFit.fill),
),
child: bloc.isRecord
? _buildLongPressWidget()
: _buildPlayVideoWidget(),
|
cb38bc90
liangchengyou
feat:视频跟读逻辑处理
|
122
123
|
),
),
|
0fa4e405
吴启风
feat: 将语音评测从先声迁移至驰声
|
124
125
126
127
128
129
130
131
132
133
134
135
136
|
///连接
Positioned(
top: 59.h,
left: 274.w,
child: Container(
width: 87.w,
height: 240.h,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage('and_book'.assetPng),
fit: BoxFit.fill),
),
|
cb38bc90
liangchengyou
feat:视频跟读逻辑处理
|
137
138
|
),
),
|
0fa4e405
吴启风
feat: 将语音评测从先声迁移至驰声
|
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
|
///跟读
Positioned(
top: 16.h,
left: 65.w,
child: Container(
width: 185.w,
height: 48.h,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage('title_ground'.assetPng),
fit: BoxFit.fill),
),
alignment: Alignment.center,
child: Text(
'read title',
textAlign: TextAlign.center,
style: TextStyle(color: Colors.white, fontSize: 21.sp),
),
|
cb38bc90
liangchengyou
feat:视频跟读逻辑处理
|
158
159
|
),
),
|
0fa4e405
吴启风
feat: 将语音评测从先声迁移至驰声
|
160
|
],
|
cb38bc90
liangchengyou
feat:视频跟读逻辑处理
|
161
|
),
|
0fa4e405
吴启风
feat: 将语音评测从先声迁移至驰声
|
162
163
164
|
),
);
});
|
cb38bc90
liangchengyou
feat:视频跟读逻辑处理
|
165
166
167
|
///播放中
Widget _buildPlayVideoWidget() {
|
0fa4e405
吴启风
feat: 将语音评测从先声迁移至驰声
|
168
|
return BlocBuilder<RepeatAfterContentBloc, RepeatAfterContentState>(
|
31d42f06
liangchengyou
feat:视频跟读录音修改
|
169
|
buildWhen: (previous, current) {
|
0fa4e405
吴启风
feat: 将语音评测从先声迁移至驰声
|
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
|
if (current is ChangeVideoPlayIndexEvent) {
return true;
}
return false;
}, builder: (context, state) {
final bloc = BlocProvider.of<RepeatAfterContentBloc>(context);
return Column(
mainAxisAlignment: MainAxisAlignment.end,
children: [
Row(
children: [
IconButton(
onPressed: () => bloc.add(ChangeVideoPlayIndexEvent(false)),
icon: Image.asset(
'previous'.assetPng,
height: 23.h,
width: 23.w,
)),
IconButton(
onPressed: () => bloc.add(VideoPlayChangeEvent()),
icon: Image.asset(
'video_pause'.assetPng,
height: 50.h,
width: 50.h,
)),
IconButton(
onPressed: () => bloc.add(ChangeVideoPlayIndexEvent(true)),
icon: Image.asset(
'next'.assetPng,
height: 23.h,
width: 23.w,
))
],
),
Row(
|
cb38bc90
liangchengyou
feat:视频跟读逻辑处理
|
205
|
children: [
|
0fa4e405
吴启风
feat: 将语音评测从先声迁移至驰声
|
206
207
208
209
210
211
|
SizedBox(
height: 23.h,
width: 23.w,
),
10.horizontalSpace,
Column(
|
cb38bc90
liangchengyou
feat:视频跟读逻辑处理
|
212
|
children: [
|
0fa4e405
吴启风
feat: 将语音评测从先声迁移至驰声
|
213
|
20.verticalSpace,
|
7d6a6ddc
liangchengyou
feat:1.0.1优化
|
214
|
IconButton(
|
0fa4e405
吴启风
feat: 将语音评测从先声迁移至驰声
|
215
216
217
218
219
220
221
|
onPressed: () {
if (bloc.videoPlaying) {
showToast('视频正在播放中');
return;
}
bloc.add(VoiceRecordEvent());
},
|
7d6a6ddc
liangchengyou
feat:1.0.1优化
|
222
|
icon: Image.asset(
|
0fa4e405
吴启风
feat: 将语音评测从先声迁移至驰声
|
223
224
225
226
227
228
229
230
|
'video_record'.assetPng,
height: 53.h,
width: 53.w,
)),
Text(
'录音',
style: TextStyle(
color: const Color(0xFF333333), fontSize: 14.sp),
|
7d6a6ddc
liangchengyou
feat:1.0.1优化
|
231
|
)
|
cb38bc90
liangchengyou
feat:视频跟读逻辑处理
|
232
233
|
],
),
|
0fa4e405
吴启风
feat: 将语音评测从先声迁移至驰声
|
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
|
// Container(
// height: 22.h,
// width: 37.w,
// decoration: BoxDecoration(
// color: const Color(0xFF56CE5F),
// borderRadius: BorderRadius.circular(10.r)
// ),
// child: Text(
// '1.0x',
// textAlign: TextAlign.center,
// style: TextStyle(
// color: Colors.white,
// fontSize: 12.sp
// ),
// ),
// )
|
cb38bc90
liangchengyou
feat:视频跟读逻辑处理
|
250
|
],
|
0fa4e405
吴启风
feat: 将语音评测从先声迁移至驰声
|
251
252
253
254
|
)
],
);
});
|
08a0f5a8
liangchengyou
feat:路由方式更新
|
255
|
}
|
cb38bc90
liangchengyou
feat:视频跟读逻辑处理
|
256
257
|
///长按录音
|
0fa4e405
吴启风
feat: 将语音评测从先声迁移至驰声
|
258
259
260
|
Widget _buildLongPressWidget() =>
BlocBuilder<RepeatAfterContentBloc, RepeatAfterContentState>(
builder: (context, state) {
|
cb38bc90
liangchengyou
feat:视频跟读逻辑处理
|
261
262
|
final bloc = BlocProvider.of<RepeatAfterContentBloc>(context);
final voiceResult = bloc.voiceTestResult;
|
31d42f06
liangchengyou
feat:视频跟读录音修改
|
263
|
Color color;
|
0fa4e405
吴启风
feat: 将语音评测从先声迁移至驰声
|
264
265
|
if (int.parse(voiceResult?['overall'].toString() ?? '0') >= 60 ||
int.parse(voiceResult?['overall'].toString() ?? '0') <= 75) {
|
31d42f06
liangchengyou
feat:视频跟读录音修改
|
266
|
color = const Color(0xFFFF0000);
|
0fa4e405
吴启风
feat: 将语音评测从先声迁移至驰声
|
267
268
|
} else if (int.parse(voiceResult?['overall'].toString() ?? '0') > 75 ||
int.parse(voiceResult?['overall'].toString() ?? '0') <= 85) {
|
31d42f06
liangchengyou
feat:视频跟读录音修改
|
269
270
271
272
|
color = const Color(0xFFFFCC00);
} else {
color = const Color(0xFF40E04B);
}
|
cb38bc90
liangchengyou
feat:视频跟读逻辑处理
|
273
274
275
276
|
return Column(
mainAxisAlignment: MainAxisAlignment.end,
children: [
Offstage(
|
0fa4e405
吴启风
feat: 将语音评测从先声迁移至驰声
|
277
278
279
|
offstage:
!(bloc.voiceRecordState == VoiceRecordState.voiceRecordEnd &&
bloc.xSCheckState == XSVoiceCheckState.result),
|
cb38bc90
liangchengyou
feat:视频跟读逻辑处理
|
280
281
|
child: Column(
children: [
|
31d42f06
liangchengyou
feat:视频跟读录音修改
|
282
|
Offstage(
|
0fa4e405
吴启风
feat: 将语音评测从先声迁移至驰声
|
283
284
285
|
offstage:
int.parse(voiceResult?['overall'].toString() ?? '0') >
60,
|
31d42f06
liangchengyou
feat:视频跟读录音修改
|
286
287
288
289
|
child: Image.asset(
'sorrow_face'.assetPng,
height: 46.h,
width: 46.w,
|
cb38bc90
liangchengyou
feat:视频跟读逻辑处理
|
290
|
),
|
31d42f06
liangchengyou
feat:视频跟读录音修改
|
291
292
|
),
Offstage(
|
0fa4e405
吴启风
feat: 将语音评测从先声迁移至驰声
|
293
294
295
|
offstage:
int.parse(voiceResult?['overall'].toString() ?? '0') <
60,
|
31d42f06
liangchengyou
feat:视频跟读录音修改
|
296
297
298
299
300
301
|
child: Container(
height: 45.h,
width: 45.h,
alignment: Alignment.center,
decoration: BoxDecoration(
color: color,
|
0fa4e405
吴启风
feat: 将语音评测从先声迁移至驰声
|
302
|
borderRadius: BorderRadius.circular(22.5.r)),
|
31d42f06
liangchengyou
feat:视频跟读录音修改
|
303
|
child: Text(
|
0fa4e405
吴启风
feat: 将语音评测从先声迁移至驰声
|
304
|
voiceResult?['overall'].toString() ?? '0',
|
31d42f06
liangchengyou
feat:视频跟读录音修改
|
305
|
textAlign: TextAlign.center,
|
0fa4e405
吴启风
feat: 将语音评测从先声迁移至驰声
|
306
|
style: TextStyle(color: Colors.white, fontSize: 17.sp),
|
cb38bc90
liangchengyou
feat:视频跟读逻辑处理
|
307
308
309
310
|
),
),
),
IconButton(
|
0fa4e405
吴启风
feat: 将语音评测从先声迁移至驰声
|
311
|
onPressed: () {
|
9efff6ae
liangchengyou
feat:视频跟读逻辑修改
|
312
|
bloc.add(RecordeVoicePlayEvent());
|
cb38bc90
liangchengyou
feat:视频跟读逻辑处理
|
313
314
315
316
317
|
},
icon: Image.asset(
'voice_record_play'.assetPng,
height: 30.h,
width: 30.w,
|
0fa4e405
吴启风
feat: 将语音评测从先声迁移至驰声
|
318
|
)),
|
cb38bc90
liangchengyou
feat:视频跟读逻辑处理
|
319
320
321
322
|
Text(
'录音',
textAlign: TextAlign.center,
style: TextStyle(
|
0fa4e405
吴启风
feat: 将语音评测从先声迁移至驰声
|
323
|
color: const Color(0xFF666666), fontSize: 11.sp),
|
cb38bc90
liangchengyou
feat:视频跟读逻辑处理
|
324
325
326
327
|
),
],
),
),
|
9efff6ae
liangchengyou
feat:视频跟读逻辑修改
|
328
|
Offstage(
|
0fa4e405
吴启风
feat: 将语音评测从先声迁移至驰声
|
329
330
331
|
offstage:
bloc.voiceRecordState == VoiceRecordState.voiceRecordUnkonw ||
bloc.xSCheckState != XSVoiceCheckState.unKnow,
|
9efff6ae
liangchengyou
feat:视频跟读逻辑修改
|
332
333
|
child: Container(
color: Colors.grey,
|
0fa4e405
吴启风
feat: 将语音评测从先声迁移至驰声
|
334
|
padding: EdgeInsets.symmetric(vertical: 50.h, horizontal: 50.w),
|
9efff6ae
liangchengyou
feat:视频跟读逻辑修改
|
335
|
child: Text(
|
0fa4e405
吴启风
feat: 将语音评测从先声迁移至驰声
|
336
337
338
|
bloc.voiceRecordState == VoiceRecordState.voiceRecording
? '正在录音'
: '录音结束'),
|
9efff6ae
liangchengyou
feat:视频跟读逻辑修改
|
339
340
341
|
),
),
10.verticalSpace,
|
cb38bc90
liangchengyou
feat:视频跟读逻辑处理
|
342
343
|
GestureDetector(
onTap: () => bloc.add(VoiceRecordEvent()),
|
cb38bc90
liangchengyou
feat:视频跟读逻辑处理
|
344
|
onLongPressStart: (LongPressStartDetails details) {
|
9efff6ae
liangchengyou
feat:视频跟读逻辑修改
|
345
346
|
///开始录音
bloc.add(StarRecordVoiceEvent());
|
cb38bc90
liangchengyou
feat:视频跟读逻辑处理
|
347
348
|
},
onLongPressEnd: (LongPressEndDetails details) {
|
9efff6ae
liangchengyou
feat:视频跟读逻辑修改
|
349
350
|
///结束录音
bloc.add(StopRecordVoiceEvent());
|
cb38bc90
liangchengyou
feat:视频跟读逻辑处理
|
351
352
353
354
355
356
357
358
359
360
|
},
child: Image.asset(
'video_record'.assetPng,
height: 78.h,
width: 78.w,
),
),
Text(
'按住录音',
textAlign: TextAlign.center,
|
0fa4e405
吴启风
feat: 将语音评测从先声迁移至驰声
|
361
|
style: TextStyle(color: const Color(0xFF333333), fontSize: 16.sp),
|
cb38bc90
liangchengyou
feat:视频跟读逻辑处理
|
362
363
364
365
|
),
],
);
});
|
08a0f5a8
liangchengyou
feat:路由方式更新
|
366
|
}
|