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