Blame view

lib/pages/repeataftercontent/repeat_after_content_page.dart 11.1 KB
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';
d4a7dfc4   liangchengyou   feat:逻辑调整
10
  import '../../utils/toast_util.dart';
cb38bc90   liangchengyou   feat:视频跟读逻辑处理
11
12
  import 'widgets/repeat_video_widget.dart';
  
08a0f5a8   liangchengyou   feat:路由方式更新
13
  class RepeatAfterContentPage extends StatelessWidget {
cb38bc90   liangchengyou   feat:视频跟读逻辑处理
14
15
16
    const RepeatAfterContentPage({super.key, this.videoFollowReadId});
  
    final String? videoFollowReadId;
08a0f5a8   liangchengyou   feat:路由方式更新
17
18
19
  
    @override
    Widget build(BuildContext context) {
cb38bc90   liangchengyou   feat:视频跟读逻辑处理
20
21
22
23
24
25
      return BlocProvider(
        create: (context) => RepeatAfterContentBloc(videoFollowReadId ??'')
          ..add(InitBlocEvent())
          ..add(RequestDataEvent())
          ..add(XSVoiceInitEvent(
              {
997ea0d6   liangchengyou   feat:绘本闪退问题修复
26
27
28
29
                'appKey':AppConsts.xsAppKey,
                'service':AppConsts.xsAppService,
                'secretKey':AppConsts.xsAppSecretKey,
                'userId':UserUtil.getUser()!.id.toString(),
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){
1e7094e3   liangchengyou   feat:适配ipad
42
  
cb38bc90   liangchengyou   feat:视频跟读逻辑处理
43
44
45
46
47
48
49
50
51
        },
        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:路由方式更新
52
53
54
55
56
      return Container(
        color: Colors.white,
        child: SafeArea(
          child: Stack(
            children: [
cb38bc90   liangchengyou   feat:视频跟读逻辑处理
57
              ///返回
08a0f5a8   liangchengyou   feat:路由方式更新
58
              Positioned(
08a0f5a8   liangchengyou   feat:路由方式更新
59
60
61
62
63
64
65
66
                child: GestureDetector(
                  onTap: () => popPage(),
                  child: Image.asset(
                    'back_around'.assetPng,
                    height: 40.h,
                    width: 40.w,
                  ),
                ),
cb38bc90   liangchengyou   feat:视频跟读逻辑处理
67
68
69
              ),
              ///左侧视频区
              Positioned(
1e7094e3   liangchengyou   feat:适配ipad
70
                top: 40.h,
cb38bc90   liangchengyou   feat:视频跟读逻辑处理
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
                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,),
                ),
              ),
              ///右侧操作区
              Positioned(
1e7094e3   liangchengyou   feat:适配ipad
87
88
                top: 40.h,
                left: 331.w,
cb38bc90   liangchengyou   feat:视频跟读逻辑处理
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
                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
105
              ///连接
cb38bc90   liangchengyou   feat:视频跟读逻辑处理
106
              Positioned(
1e7094e3   liangchengyou   feat:适配ipad
107
                top: 59.h,
cb38bc90   liangchengyou   feat:视频跟读逻辑处理
108
109
110
111
112
113
114
115
116
117
118
119
120
121
                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
122
                top: 16.h,
cb38bc90   liangchengyou   feat:视频跟读逻辑处理
123
124
125
126
127
128
129
130
131
132
                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
133
                  alignment: Alignment.center,
cb38bc90   liangchengyou   feat:视频跟读逻辑处理
134
135
136
137
138
139
140
141
142
143
                  child: Text(
                    'read title',
                    textAlign: TextAlign.center,
                    style: TextStyle(
                        color: Colors.white,
                        fontSize: 21.sp
                    ),
                  ),
                ),
              ),
08a0f5a8   liangchengyou   feat:路由方式更新
144
145
146
147
            ],
          ),
        ),
      );
cb38bc90   liangchengyou   feat:视频跟读逻辑处理
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
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
    });
  
    ///播放中
    Widget _buildPlayVideoWidget() {
      return BlocBuilder<RepeatAfterContentBloc,RepeatAfterContentState>(
          builder: (context,state){
            final bloc = BlocProvider.of<RepeatAfterContentBloc>(context);
            return Column(
              mainAxisAlignment: MainAxisAlignment.end,
              children: [
                Row(
                  children: [
                    SizedBox(
                      height: 23.h,
                      width: 33.w,
                    ),
                    // IconButton(
                    //     onPressed: (){},
                    //     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.w,
                        )
                    ),
                    SizedBox(
                      height: 23.h,
                      width: 23.w,
                    ),
                    // IconButton(
                    //     onPressed: (){},
                    //     icon: Image.asset(
                    //       'next'.assetPng,
                    //       height: 23.h,
                    //       width: 23.w,
                    //     )
                    // )
                  ],
                ),
                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
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
  
    ///长按录音
    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(
                offstage: bloc.voiceRecordState != VoiceRecordState.voiceRecordEnd && voiceResult == null,
                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: (){
                          if(voiceResult != null) {
                            bloc.add(RecordeVoicePlayEvent(voiceResult['audioUrl']??''));
                          }
                        },
                        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
                      ),
                    ),
                  ],
                ),
              ),
              GestureDetector(
                onTap: () => bloc.add(VoiceRecordEvent()),
                onLongPress: () {
                  bloc.add(XSVoiceTestEvent(bloc.entityList?.first?.word??'', '0', UserUtil.getUser()!.id.toString()));
                },
                onLongPressStart: (LongPressStartDetails details) {
                  bloc.add(VoiceRecordStateChangeEvent(VoiceRecordState.voiceRecordStat));
                },
                onLongPressEnd: (LongPressEndDetails details) {
                  bloc.add(VoiceRecordStateChangeEvent(VoiceRecordState.voiceRecordEnd));
                },
                onLongPressUp: () {
  
                },
                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:路由方式更新
333
  }