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
30
|
'appKey':AppConsts.xsAppKey,
'service':AppConsts.xsAppService,
'secretKey':AppConsts.xsAppSecretKey,
'userId':UserUtil.getUser()!.id.toString(),
|
cb38bc90
liangchengyou
feat:视频跟读逻辑处理
|
31
32
33
34
35
36
37
38
39
40
41
42
|
}
)),
child: _RepeatAfterContentPage(),
);
}
}
class _RepeatAfterContentPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return BlocListener<RepeatAfterContentBloc,RepeatAfterContentState>(
listener: (context,state){
|
9efff6ae
liangchengyou
feat:视频跟读逻辑修改
|
43
44
45
46
47
48
49
50
|
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:视频跟读逻辑处理
|
51
52
53
54
55
56
57
58
59
|
},
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:路由方式更新
|
60
61
62
63
64
|
return Container(
color: Colors.white,
child: SafeArea(
child: Stack(
children: [
|
cb38bc90
liangchengyou
feat:视频跟读逻辑处理
|
65
|
///返回
|
08a0f5a8
liangchengyou
feat:路由方式更新
|
66
|
Positioned(
|
08a0f5a8
liangchengyou
feat:路由方式更新
|
67
68
69
70
71
72
73
74
|
child: GestureDetector(
onTap: () => popPage(),
child: Image.asset(
'back_around'.assetPng,
height: 40.h,
width: 40.w,
),
),
|
cb38bc90
liangchengyou
feat:视频跟读逻辑处理
|
75
76
77
|
),
///左侧视频区
Positioned(
|
1e7094e3
liangchengyou
feat:适配ipad
|
78
|
top: 40.h,
|
cb38bc90
liangchengyou
feat:视频跟读逻辑处理
|
79
80
81
82
83
84
85
86
87
88
89
|
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优化
|
90
|
child: videoUrl.isEmpty?Container(): RepeatVideoWidget(videoUrl: bloc.entityList?.first?.videoUrl,videoUrls: bloc.entityList??[],),
|
cb38bc90
liangchengyou
feat:视频跟读逻辑处理
|
91
92
93
94
|
),
),
///右侧操作区
Positioned(
|
1e7094e3
liangchengyou
feat:适配ipad
|
95
96
|
top: 40.h,
left: 331.w,
|
cb38bc90
liangchengyou
feat:视频跟读逻辑处理
|
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
|
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
|
113
|
///连接
|
cb38bc90
liangchengyou
feat:视频跟读逻辑处理
|
114
|
Positioned(
|
1e7094e3
liangchengyou
feat:适配ipad
|
115
|
top: 59.h,
|
cb38bc90
liangchengyou
feat:视频跟读逻辑处理
|
116
117
118
119
120
121
122
123
124
125
126
127
128
129
|
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
|
130
|
top: 16.h,
|
cb38bc90
liangchengyou
feat:视频跟读逻辑处理
|
131
132
133
134
135
136
137
138
139
140
|
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
|
141
|
alignment: Alignment.center,
|
cb38bc90
liangchengyou
feat:视频跟读逻辑处理
|
142
143
144
145
146
147
148
149
150
151
|
child: Text(
'read title',
textAlign: TextAlign.center,
style: TextStyle(
color: Colors.white,
fontSize: 21.sp
),
),
),
),
|
08a0f5a8
liangchengyou
feat:路由方式更新
|
152
153
154
155
|
],
),
),
);
|
cb38bc90
liangchengyou
feat:视频跟读逻辑处理
|
156
157
158
159
160
161
162
163
164
165
166
167
|
});
///播放中
Widget _buildPlayVideoWidget() {
return BlocBuilder<RepeatAfterContentBloc,RepeatAfterContentState>(
builder: (context,state){
final bloc = BlocProvider.of<RepeatAfterContentBloc>(context);
return Column(
mainAxisAlignment: MainAxisAlignment.end,
children: [
Row(
children: [
|
7d6a6ddc
liangchengyou
feat:1.0.1优化
|
168
169
170
171
172
173
174
|
IconButton(
onPressed: () => bloc.add(ChangeVideoPlayIndexEvent(false)),
icon: Image.asset(
'previous'.assetPng,
height: 23.h,
width: 23.w,
)
|
cb38bc90
liangchengyou
feat:视频跟读逻辑处理
|
175
|
),
|
cb38bc90
liangchengyou
feat:视频跟读逻辑处理
|
176
177
178
179
180
|
IconButton(
onPressed:() => bloc.add(VideoPlayChangeEvent()),
icon: Image.asset(
'video_pause'.assetPng,
height: 50.h,
|
7d6a6ddc
liangchengyou
feat:1.0.1优化
|
181
|
width: 50.h,
|
cb38bc90
liangchengyou
feat:视频跟读逻辑处理
|
182
183
|
)
),
|
7d6a6ddc
liangchengyou
feat:1.0.1优化
|
184
185
186
187
188
189
190
191
|
IconButton(
onPressed: () => bloc.add(ChangeVideoPlayIndexEvent(true)),
icon: Image.asset(
'next'.assetPng,
height: 23.h,
width: 23.w,
)
)
|
cb38bc90
liangchengyou
feat:视频跟读逻辑处理
|
192
193
194
195
196
197
198
199
200
201
202
203
204
|
],
),
Row(
children: [
SizedBox(
height: 23.h,
width: 23.w,
),
10.horizontalSpace,
Column(
children: [
20.verticalSpace,
IconButton(
|
d4a7dfc4
liangchengyou
feat:逻辑调整
|
205
206
207
208
209
210
211
|
onPressed: () {
if (bloc.videoPlaying) {
showToast('视频正在播放中');
return;
}
bloc.add(VoiceRecordEvent());
},
|
cb38bc90
liangchengyou
feat:视频跟读逻辑处理
|
212
213
214
215
216
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
|
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:路由方式更新
|
248
|
}
|
cb38bc90
liangchengyou
feat:视频跟读逻辑处理
|
249
250
251
252
253
254
255
256
257
258
|
///长按录音
Widget _buildLongPressWidget() => BlocBuilder<RepeatAfterContentBloc,RepeatAfterContentState>(
builder: (context,state){
final bloc = BlocProvider.of<RepeatAfterContentBloc>(context);
final voiceResult = bloc.voiceTestResult;
return Column(
mainAxisAlignment: MainAxisAlignment.end,
children: [
Offstage(
|
cacfac41
liangchengyou
feat:修复视频跟读页无法录音问题
|
259
|
// offstage: false,
|
9efff6ae
liangchengyou
feat:视频跟读逻辑修改
|
260
|
offstage:!(bloc.voiceRecordState == VoiceRecordState.voiceRecordEnd && bloc.xSCheckState == XSVoiceCheckState.stop),
|
cb38bc90
liangchengyou
feat:视频跟读逻辑处理
|
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
|
child: Column(
children: [
Container(
height: 45.h,
width: 45.h,
alignment: Alignment.center,
decoration: BoxDecoration(
color: const Color(0xFF40E04B),
borderRadius: BorderRadius.circular(22.5.r)
),
child: Text(
voiceResult?['overall'].toString()??'0',
textAlign: TextAlign.center,
style: TextStyle(
color: Colors.white,
fontSize: 17.sp
),
),
),
IconButton(
onPressed: (){
|
9efff6ae
liangchengyou
feat:视频跟读逻辑修改
|
282
|
bloc.add(RecordeVoicePlayEvent());
|
cb38bc90
liangchengyou
feat:视频跟读逻辑处理
|
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
|
},
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:视频跟读逻辑修改
|
301
|
Offstage(
|
cacfac41
liangchengyou
feat:修复视频跟读页无法录音问题
|
302
|
// offstage: true,
|
9efff6ae
liangchengyou
feat:视频跟读逻辑修改
|
303
304
305
306
307
308
309
310
311
312
313
314
315
|
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:视频跟读逻辑处理
|
316
317
|
GestureDetector(
onTap: () => bloc.add(VoiceRecordEvent()),
|
cb38bc90
liangchengyou
feat:视频跟读逻辑处理
|
318
|
onLongPressStart: (LongPressStartDetails details) {
|
9efff6ae
liangchengyou
feat:视频跟读逻辑修改
|
319
320
|
///开始录音
bloc.add(StarRecordVoiceEvent());
|
cb38bc90
liangchengyou
feat:视频跟读逻辑处理
|
321
322
|
},
onLongPressEnd: (LongPressEndDetails details) {
|
9efff6ae
liangchengyou
feat:视频跟读逻辑修改
|
323
324
|
///结束录音
bloc.add(StopRecordVoiceEvent());
|
cb38bc90
liangchengyou
feat:视频跟读逻辑处理
|
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
|
},
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:路由方式更新
|
343
|
}
|