Blame view

lib/pages/video/lookvideo/look_video_page.dart 1.77 KB
119ba920   liangchengyou   feat:视频播放器
1
  import 'package:flutter/material.dart';
46675a89   吴启风   feat:过渡页-视频环节
2
  import 'package:flutter_bloc/flutter_bloc.dart';
aa0d2360   吴启风   feat:过渡页-视频环节(再来一次)
3
  import 'package:wow_english/pages/section/subsection/base_section/state.dart';
46675a89   吴启风   feat:过渡页-视频环节
4
  import 'package:wow_english/pages/video/lookvideo/bloc/look_video_bloc.dart';
4b358e22   liangchengyou   feat:调整文件结构
5
  import 'package:wow_english/pages/video/lookvideo/widgets/video_widget.dart';
1e22b7d1   吴启风   feat:儿歌/视频环节接口请求时机优化
6
  import 'package:wow_english/utils/log_util.dart';
4b358e22   liangchengyou   feat:调整文件结构
7
  
46675a89   吴启风   feat:过渡页-视频环节
8
9
  class LookVideoPage extends StatelessWidget {
    const LookVideoPage(
1e22b7d1   吴启风   feat:儿歌/视频环节接口请求时机优化
10
11
12
13
14
        {super.key,
        this.videoUrl,
        this.typeTitle,
        this.courseLessonId,
        this.isTopic = false});
993c1a04   liangchengyou   feat:添加数据模型
15
16
  
    final String? videoUrl;
842b7132   liangchengyou   feat:磨耳朵/练习页面调整
17
    final String? typeTitle;
934e2b47   liangchengyou   feat:权限调整+课程进度接口对接
18
    final String? courseLessonId;
46675a89   吴启风   feat:过渡页-视频环节
19
    final bool isTopic;
119ba920   liangchengyou   feat:视频播放器
20
21
  
    @override
119ba920   liangchengyou   feat:视频播放器
22
    Widget build(BuildContext context) {
46675a89   吴启风   feat:过渡页-视频环节
23
      return BlocProvider(
1e22b7d1   吴启风   feat:儿歌/视频环节接口请求时机优化
24
25
26
        create: (BuildContext context) =>
            LookVideoBloc(videoUrl, typeTitle, courseLessonId, isTopic)
              ..add(RequestDataEvent()),
46675a89   吴启风   feat:过渡页-视频环节
27
        child: Builder(builder: (context) => _buildPage(context)),
119ba920   liangchengyou   feat:视频播放器
28
29
      );
    }
46675a89   吴启风   feat:过渡页-视频环节
30
31
32
  }
  
  Widget _buildPage(BuildContext context) {
1e22b7d1   吴启风   feat:儿歌/视频环节接口请求时机优化
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
    return BlocBuilder<LookVideoBloc, BaseSectionState>(
        builder: (context, state) {
      final bloc = BlocProvider.of<LookVideoBloc>(context);
      Log.d("WQF lookvideo BlocBuilder bloc.videoUr=${bloc.videoUrl}");
      return Center(
        child: bloc.videoUrl?.isNotEmpty == true
            ? Container(
                color: Colors.white,
                child: VideoWidget(
                  videoUrl: bloc.videoUrl ?? '',
                  typeTitle: bloc.typeTitle ?? '',
                  courseLessonId: bloc.courseLessonId ?? '',
                  isTopic: bloc.isTopic,
                ))
            //todo 空了需要抽一个通用的loading组件
            : Container(
                color: Colors.white,
                child: const CircularProgressIndicator(),
              ),
      );
    });
46675a89   吴启风   feat:过渡页-视频环节
54
  }