From 6baa39bd83252c1989cce9463ae316e311f755a2 Mon Sep 17 00:00:00 2001 From: wuqifeng <540416539@qq.com> Date: Fri, 26 Jul 2024 00:38:10 +0800 Subject: [PATCH] feat:儿歌/视频保留url传参,留作日后扩展 --- lib/pages/section/section_page.dart | 4 ++-- lib/pages/video/lookvideo/bloc/look_video_bloc.dart | 2 +- lib/pages/video/lookvideo/look_video_page.dart | 1 + lib/route/route.dart | 10 ++++++---- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/lib/pages/section/section_page.dart b/lib/pages/section/section_page.dart index 78b5429..5d3ba0f 100644 --- a/lib/pages/section/section_page.dart +++ b/lib/pages/section/section_page.dart @@ -61,7 +61,7 @@ class _SectionPageView extends StatelessWidget { return BlocListener( listener: (context, state) async { if (state is RequestEnterClassState) { - if (state.courseType == SectionType.song.value && + if (state.courseType == SectionType.song.value || state.courseType == SectionType.video.value) { var title = state.courseType == SectionType.song.value ? 'song' : 'video'; @@ -75,7 +75,7 @@ class _SectionPageView extends StatelessWidget { .playAudio(AudioPlayerUtilType.videoTime); } pushNamed(AppRouteName.lookVideo, arguments: { - 'videoUrl': "", + 'videoUrl': null, 'title': title, 'courseLessonId': state.courseLessonId, 'isTopic': true diff --git a/lib/pages/video/lookvideo/bloc/look_video_bloc.dart b/lib/pages/video/lookvideo/bloc/look_video_bloc.dart index 1e67c1d..afdeb74 100644 --- a/lib/pages/video/lookvideo/bloc/look_video_bloc.dart +++ b/lib/pages/video/lookvideo/bloc/look_video_bloc.dart @@ -17,7 +17,7 @@ part 'look_video_state.dart'; class LookVideoBloc extends BaseSectionBloc { final String? _videoUrl; - String? get videoUrl => _videoUrl ?? _entity?.videos?.videoUrl ?? ''; + String? get videoUrl => (_videoUrl?.isNotEmpty == true) ? _videoUrl : _entity?.videos?.videoUrl ?? ''; final String? _typeTitle; String? get typeTitle => _typeTitle; final String? _courseLessonId; diff --git a/lib/pages/video/lookvideo/look_video_page.dart b/lib/pages/video/lookvideo/look_video_page.dart index cd21c93..85e5523 100644 --- a/lib/pages/video/lookvideo/look_video_page.dart +++ b/lib/pages/video/lookvideo/look_video_page.dart @@ -13,6 +13,7 @@ class LookVideoPage extends StatelessWidget { this.courseLessonId, this.isTopic = false}); + ///暂时不删,留着以后扩展。目前的逻辑是null,进入后请求课程数据 final String? videoUrl; final String? typeTitle; final String? courseLessonId; diff --git a/lib/route/route.dart b/lib/route/route.dart index 0bc1908..cc1254b 100644 --- a/lib/route/route.dart +++ b/lib/route/route.dart @@ -132,8 +132,8 @@ class AppRouter { if (settings.arguments != null) { courseUnitEntity = (settings.arguments as Map) .getOrNull('courseUnitEntity') as CourseUnitEntity; - courseUnitDetail = (settings.arguments as Map) - .getOrNull('courseUnitId'); + courseUnitDetail = + (settings.arguments as Map).getOrNull('courseUnitId'); } return CupertinoPageRoute( builder: (_) => SectionPage( @@ -190,12 +190,14 @@ class AppRouter { return CupertinoPageRoute( builder: (_) => TopicPicturePage(courseLessonId: courseLessonId)); case AppRouteName.lookVideo: - final videoUrl = (settings.arguments as Map)['videoUrl'] as String; + final videoUrl = (settings.arguments as Map)['videoUrl'] as String?; final title = (settings.arguments as Map)['title'] as String?; final courseLessonId = (settings.arguments as Map)['courseLessonId'] as String?; + ///是否是课程内的视频环节,用于播放结束判断要不要再来一次以及下一环节用 - final isTopic = (settings.arguments as Map)['isTopic'] as bool? ?? false; + final isTopic = + (settings.arguments as Map)['isTopic'] as bool? ?? false; return CupertinoPageRoute( builder: (_) => LookVideoPage( videoUrl: videoUrl, -- libgit2 0.22.2