look_video_page.dart
1.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:wow_english/pages/section/subsection/base_section/state.dart';
import 'package:wow_english/pages/video/lookvideo/bloc/look_video_bloc.dart';
import 'package:wow_english/pages/video/lookvideo/widgets/video_widget.dart';
import 'package:wow_english/utils/log_util.dart';
class LookVideoPage extends StatelessWidget {
const LookVideoPage(
{super.key,
this.videoUrl,
this.typeTitle,
this.courseLessonId,
this.isTopic = false});
///暂时不删,留着以后扩展。目前的逻辑是null,进入后请求课程数据
final String? videoUrl;
final String? typeTitle;
final String? courseLessonId;
final bool isTopic;
@override
Widget build(BuildContext context) {
return BlocProvider(
create: (BuildContext context) =>
LookVideoBloc(videoUrl, typeTitle, courseLessonId, isTopic)
..add(RequestDataEvent()),
child: Builder(builder: (context) => _buildPage(context)),
);
}
}
Widget _buildPage(BuildContext context) {
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(),
),
);
});
}