Commit 5989d2509d1e2369f53134da92ac875c0ddeb5e1
1 parent
1de82c6c
feat:体验优化-选择题选中边框及时重置
Showing
3 changed files
with
20 additions
and
1 deletions
lib/pages/practice/bloc/topic_picture_bloc.dart
@@ -85,6 +85,7 @@ class TopicPictureBloc | @@ -85,6 +85,7 @@ class TopicPictureBloc | ||
85 | on<XSVoiceResultEvent>(_voiceXsResult); | 85 | on<XSVoiceResultEvent>(_voiceXsResult); |
86 | on<XSVoiceInitEvent>(_initVoiceSdk); | 86 | on<XSVoiceInitEvent>(_initVoiceSdk); |
87 | on<SelectItemEvent>(_selectItemLoad); | 87 | on<SelectItemEvent>(_selectItemLoad); |
88 | + on<SelectItemResetEvent>(_selectItemReset); | ||
88 | on<RequestDataEvent>(_requestData); | 89 | on<RequestDataEvent>(_requestData); |
89 | on<XSVoiceStartEvent>(_voiceXsStart); | 90 | on<XSVoiceStartEvent>(_voiceXsStart); |
90 | on<XSVoiceStopEvent>(_voiceXsStop); | 91 | on<XSVoiceStopEvent>(_voiceXsStop); |
@@ -210,13 +211,22 @@ class TopicPictureBloc | @@ -210,13 +211,22 @@ class TopicPictureBloc | ||
210 | /// right音频长度比动效短,所以等动效完了再翻页 | 211 | /// right音频长度比动效短,所以等动效完了再翻页 |
211 | AudioPlayerUtil.getInstance().playAudio(AudioPlayerUtilType.right); | 212 | AudioPlayerUtil.getInstance().playAudio(AudioPlayerUtilType.right); |
212 | await showStarRewardDialog(context, onDismiss: () { | 213 | await showStarRewardDialog(context, onDismiss: () { |
214 | + _resetSelectItem(); | ||
213 | autoFlipPage(); | 215 | autoFlipPage(); |
214 | }); | 216 | }); |
215 | } else { | 217 | } else { |
216 | await AudioPlayerUtil.getInstance().playAudio(AudioPlayerUtilType.wrong); | 218 | await AudioPlayerUtil.getInstance().playAudio(AudioPlayerUtilType.wrong); |
219 | + _resetSelectItem(); | ||
217 | } | 220 | } |
218 | } | 221 | } |
219 | 222 | ||
223 | + ///重置选择 | ||
224 | + void _selectItemReset( | ||
225 | + SelectItemResetEvent event, Emitter<TopicPictureState> emitter) async { | ||
226 | + ///用于一次完整的选择后重置视图 | ||
227 | + emitter(SelectItemResetState()); | ||
228 | + } | ||
229 | + | ||
220 | ///为空则数据异常,用于是否晃动时需要 | 230 | ///为空则数据异常,用于是否晃动时需要 |
221 | bool? checkAnswerRight(int selectIndex) { | 231 | bool? checkAnswerRight(int selectIndex) { |
222 | CourseProcessTopics? topics = _entity?.topics?[_currentPage]; | 232 | CourseProcessTopics? topics = _entity?.topics?[_currentPage]; |
@@ -319,11 +329,15 @@ class TopicPictureBloc | @@ -319,11 +329,15 @@ class TopicPictureBloc | ||
319 | await _voiceXsCancel(); | 329 | await _voiceXsCancel(); |
320 | } | 330 | } |
321 | 331 | ||
332 | + void _resetSelectItem() { | ||
333 | + _optionSelectItem = -1; | ||
334 | + add(SelectItemResetEvent()); | ||
335 | + } | ||
336 | + | ||
322 | Future<void> closePlayerResource() async { | 337 | Future<void> closePlayerResource() async { |
323 | if (voicePlayState == VoicePlayState.playing) { | 338 | if (voicePlayState == VoicePlayState.playing) { |
324 | await audioPlayer.stop(); | 339 | await audioPlayer.stop(); |
325 | } | 340 | } |
326 | - await ClickWithMusicController.instance.reset(); | ||
327 | } | 341 | } |
328 | 342 | ||
329 | ///是否是最后一页 | 343 | ///是否是最后一页 |
lib/pages/practice/bloc/topic_picture_event.dart
@@ -45,6 +45,9 @@ class SelectItemEvent extends TopicPictureEvent { | @@ -45,6 +45,9 @@ class SelectItemEvent extends TopicPictureEvent { | ||
45 | SelectItemEvent(this.selectIndex); | 45 | SelectItemEvent(this.selectIndex); |
46 | } | 46 | } |
47 | 47 | ||
48 | +///选项重置,用于播放作答动效后重置(边框等) | ||
49 | +class SelectItemResetEvent extends TopicPictureEvent {} | ||
50 | + | ||
48 | ///音频播放事件 | 51 | ///音频播放事件 |
49 | class VoicePlayChangeEvent extends TopicPictureEvent {} | 52 | class VoicePlayChangeEvent extends TopicPictureEvent {} |
50 | 53 |
lib/pages/practice/bloc/topic_picture_state.dart
@@ -13,4 +13,6 @@ class CurrentPageIndexState extends TopicPictureState {} | @@ -13,4 +13,6 @@ class CurrentPageIndexState extends TopicPictureState {} | ||
13 | 13 | ||
14 | class SelectItemChangeState extends TopicPictureState {} | 14 | class SelectItemChangeState extends TopicPictureState {} |
15 | 15 | ||
16 | +class SelectItemResetState extends TopicPictureState {} | ||
17 | + | ||
16 | class VoicePlayStateChange extends TopicPictureState {} | 18 | class VoicePlayStateChange extends TopicPictureState {} |