Commit 37063ced5d50765d55c4414cd225d45ba8ff0c22
1 parent
7b87c05c
feat:阶段选择指示器与阶段色联动;阶段选择点击增加音效(音频文件待提供)
Showing
4 changed files
with
27 additions
and
9 deletions
lib/common/utils/click_with_music_controller.dart
... | ... | @@ -17,8 +17,9 @@ class ClickWithMusicController { |
17 | 17 | |
18 | 18 | bool _isPlaying = false; |
19 | 19 | |
20 | + ///@param context 暂时没用到,先可空预留 | |
20 | 21 | ///@param action 可以是同步函数也可以是异步函数 |
21 | - Future<void> playMusicAndPerformAction(BuildContext context, | |
22 | + Future<void> playMusicAndPerformAction(BuildContext? context, | |
22 | 23 | AudioPlayerUtilType audioType, FutureOr<void> Function() action) async { |
23 | 24 | if (_isPlaying) return; |
24 | 25 | ... | ... |
lib/pages/module/course_module_page.dart
... | ... | @@ -5,6 +5,9 @@ import 'package:wow_english/common/widgets/we_app_bar.dart'; |
5 | 5 | import 'package:wow_english/models/course_module_entity.dart'; |
6 | 6 | import 'package:wow_english/route/route.dart'; |
7 | 7 | |
8 | +import '../../common/utils/click_with_music_controller.dart'; | |
9 | +import '../../utils/audio_player_util.dart'; | |
10 | +import '../section/courese_module_model.dart'; | |
8 | 11 | import 'bloc/module_bloc.dart'; |
9 | 12 | import 'widgets/module_item_widget.dart'; |
10 | 13 | |
... | ... | @@ -67,6 +70,7 @@ class _LessonPageView extends StatelessWidget { |
67 | 70 | itemCount: bloc.listData.length, |
68 | 71 | scrollDirection: Axis.horizontal, |
69 | 72 | itemBuilder: (BuildContext context, int index) { |
73 | + CourseModuleEntity? model = bloc.listData[index]; | |
70 | 74 | return Container( |
71 | 75 | height: 32.h, |
72 | 76 | width: 66.w, |
... | ... | @@ -86,9 +90,16 @@ class _LessonPageView extends StatelessWidget { |
86 | 90 | child: Container( |
87 | 91 | height: bloc.currentPageIndex == index ? 32 : 20, |
88 | 92 | decoration: BoxDecoration( |
89 | - color: bloc.currentPageIndex == index | |
90 | - ? Colors.red | |
91 | - : Colors.white, | |
93 | + // color: bloc.currentPageIndex == index | |
94 | + // ? Colors.red | |
95 | + // : Colors.white, | |
96 | + color: | |
97 | + CourseModuleModel(model?.code ?? 'Phase-1') | |
98 | + .color | |
99 | + .withOpacity( | |
100 | + bloc.currentPageIndex == index | |
101 | + ? 1 | |
102 | + : 0.35), | |
92 | 103 | borderRadius: BorderRadius.circular(5.r), |
93 | 104 | border: Border.all( |
94 | 105 | width: 0.5, |
... | ... | @@ -156,9 +167,13 @@ class _LessonPageView extends StatelessWidget { |
156 | 167 | model: model, |
157 | 168 | isSelected: bloc.currentPageIndex == index, |
158 | 169 | onClickEvent: () { |
159 | - pushNamedAndRemoveUntil( | |
160 | - AppRouteName.courseUnit, (route) => route.isFirst, | |
161 | - arguments: {'courseModuleEntity': model}); | |
170 | + ///todo 不同阶段音乐文件待提供 | |
171 | + ClickWithMusicController.instance.playMusicAndPerformAction( | |
172 | + context, | |
173 | + AudioPlayerUtilType.welcomeToWow, | |
174 | + () => pushNamedAndRemoveUntil( | |
175 | + AppRouteName.courseUnit, (route) => route.isFirst, | |
176 | + arguments: {'courseModuleEntity': model})); | |
162 | 177 | }, |
163 | 178 | ), |
164 | 179 | ), | ... | ... |
lib/pages/section/section_page.dart
... | ... | @@ -19,7 +19,7 @@ import '../../utils/log_util.dart'; |
19 | 19 | import 'bloc/section_bloc.dart'; |
20 | 20 | import 'courese_module_model.dart'; |
21 | 21 | |
22 | -/// 环节列表页 | |
22 | +/// 环节(课程)列表页 | |
23 | 23 | class SectionPage extends StatelessWidget { |
24 | 24 | const SectionPage( |
25 | 25 | {super.key, required this.courseUnitEntity, required this.courseUnitId}); | ... | ... |
lib/pages/section/widgets/section_header_widget.dart
... | ... | @@ -6,8 +6,10 @@ import 'package:wow_english/pages/user/bloc/user_bloc.dart'; |
6 | 6 | |
7 | 7 | import '../courese_module_model.dart'; |
8 | 8 | |
9 | +/// 环节(课程)列表页标题栏 | |
9 | 10 | class SectionHeaderWidget extends StatelessWidget { |
10 | - const SectionHeaderWidget({super.key, this.title, this.courseModuleCode, this.onBack}); | |
11 | + const SectionHeaderWidget( | |
12 | + {super.key, this.title, this.courseModuleCode, this.onBack}); | |
11 | 13 | |
12 | 14 | final String? title; |
13 | 15 | ... | ... |