Commit b81332cac9a883de284377a729048504a8c873c2
1 parent
c623c7b2
feat:喇叭组件替换
Showing
2 changed files
with
32 additions
and
35 deletions
lib/pages/practice/topic_picture_page.dart
| @@ -295,17 +295,16 @@ class _TopicPicturePage extends StatelessWidget { | @@ -295,17 +295,16 @@ class _TopicPicturePage extends StatelessWidget { | ||
| 295 | Row( | 295 | Row( |
| 296 | mainAxisAlignment: MainAxisAlignment.center, | 296 | mainAxisAlignment: MainAxisAlignment.center, |
| 297 | children: [ | 297 | children: [ |
| 298 | - GestureDetector( | 298 | + SpeakerWidget( |
| 299 | + isPlaying: bloc.voicePlayState == VoicePlayState.playing, | ||
| 300 | + // 控制动画播放 | ||
| 301 | + isClickable: true, | ||
| 302 | + // 控制是否可点击 | ||
| 303 | + width: 32.w, | ||
| 304 | + height: 32.w, | ||
| 299 | onTap: () { | 305 | onTap: () { |
| 300 | bloc.add(VoicePlayEvent()); | 306 | bloc.add(VoicePlayEvent()); |
| 301 | }, | 307 | }, |
| 302 | - child: Image.asset( | ||
| 303 | - bloc.voicePlayState == VoicePlayState.playing | ||
| 304 | - ? 'reade_answer'.assetGif | ||
| 305 | - : 'voice'.assetPng, | ||
| 306 | - height: 33.h, | ||
| 307 | - width: 30.w, | ||
| 308 | - ), | ||
| 309 | ), | 308 | ), |
| 310 | 10.horizontalSpace, | 309 | 10.horizontalSpace, |
| 311 | Text(topics?.word ?? '', | 310 | Text(topics?.word ?? '', |
| @@ -376,16 +375,17 @@ class _TopicPicturePage extends StatelessWidget { | @@ -376,16 +375,17 @@ class _TopicPicturePage extends StatelessWidget { | ||
| 376 | return SafeArea( | 375 | return SafeArea( |
| 377 | child: Column( | 376 | child: Column( |
| 378 | children: [ | 377 | children: [ |
| 379 | - GestureDetector( | ||
| 380 | - onTap: () { | ||
| 381 | - bloc.add(VoicePlayEvent()); | ||
| 382 | - }, | ||
| 383 | - child: Image.asset( | ||
| 384 | - bloc.voicePlayState == VoicePlayState.playing | ||
| 385 | - ? 'reade_answer'.assetGif | ||
| 386 | - : 'voice'.assetPng, | ||
| 387 | - height: 33.h, | ||
| 388 | - width: 30.w)), | 378 | + SpeakerWidget( |
| 379 | + isPlaying: bloc.voicePlayState == VoicePlayState.playing, | ||
| 380 | + // 控制动画播放 | ||
| 381 | + isClickable: true, | ||
| 382 | + // 控制是否可点击 | ||
| 383 | + width: 32.w, | ||
| 384 | + height: 32.w, | ||
| 385 | + onTap: () { | ||
| 386 | + bloc.add(VoicePlayEvent()); | ||
| 387 | + }, | ||
| 388 | + ), | ||
| 389 | 26.verticalSpace, | 389 | 26.verticalSpace, |
| 390 | SizedBox( | 390 | SizedBox( |
| 391 | width: 163.w * (topics?.topicAnswerList?.length ?? 0), | 391 | width: 163.w * (topics?.topicAnswerList?.length ?? 0), |
lib/pages/reading/reading_page.dart
| @@ -9,6 +9,7 @@ import 'package:wow_english/route/route.dart'; | @@ -9,6 +9,7 @@ import 'package:wow_english/route/route.dart'; | ||
| 9 | import '../../common/core/app_consts.dart'; | 9 | import '../../common/core/app_consts.dart'; |
| 10 | import '../../common/core/user_util.dart'; | 10 | import '../../common/core/user_util.dart'; |
| 11 | import '../../common/widgets/recorder_widget.dart'; | 11 | import '../../common/widgets/recorder_widget.dart'; |
| 12 | +import '../../common/widgets/speaker_widget.dart'; | ||
| 12 | import '../../models/course_process_entity.dart'; | 13 | import '../../models/course_process_entity.dart'; |
| 13 | import '../../utils/log_util.dart'; | 14 | import '../../utils/log_util.dart'; |
| 14 | import 'bloc/reading_bloc.dart'; | 15 | import 'bloc/reading_bloc.dart'; |
| @@ -156,21 +157,18 @@ class _ReadingPage extends StatelessWidget { | @@ -156,21 +157,18 @@ class _ReadingPage extends StatelessWidget { | ||
| 156 | child: Row( | 157 | child: Row( |
| 157 | children: [ | 158 | children: [ |
| 158 | 5.horizontalSpace, | 159 | 5.horizontalSpace, |
| 159 | - GestureDetector( | 160 | + SpeakerWidget( |
| 161 | + isPlaying: | ||
| 162 | + bloc.voicePlayState == VoicePlayState.playing && | ||
| 163 | + bloc.isOriginAudioPlaying, | ||
| 164 | + // 控制动画播放 | ||
| 165 | + isClickable: !bloc.isRecording, | ||
| 166 | + // 控制是否可点击 | ||
| 167 | + width: 42.w, | ||
| 168 | + height: 42.w, | ||
| 160 | onTap: () { | 169 | onTap: () { |
| 161 | - if (bloc.isRecording) { | ||
| 162 | - return; | ||
| 163 | - } | ||
| 164 | bloc.add(PlayOriginalAudioEvent(null)); | 170 | bloc.add(PlayOriginalAudioEvent(null)); |
| 165 | }, | 171 | }, |
| 166 | - child: Image.asset( | ||
| 167 | - bloc.voicePlayState == VoicePlayState.playing && | ||
| 168 | - bloc.isOriginAudioPlaying | ||
| 169 | - ? 'reade_answer'.assetGif | ||
| 170 | - : 'voice'.assetPng, | ||
| 171 | - height: 40.h, | ||
| 172 | - width: 45.w, | ||
| 173 | - ), | ||
| 174 | ), | 172 | ), |
| 175 | SizedBox( | 173 | SizedBox( |
| 176 | width: 10.w, | 174 | width: 10.w, |
| @@ -188,17 +186,16 @@ class _ReadingPage extends StatelessWidget { | @@ -188,17 +186,16 @@ class _ReadingPage extends StatelessWidget { | ||
| 188 | ), | 186 | ), |
| 189 | RecorderWidget( | 187 | RecorderWidget( |
| 190 | isPlaying: bloc.isRecording, | 188 | isPlaying: bloc.isRecording, |
| 191 | - isClickable: bloc.voicePlayState != VoicePlayState.playing, | 189 | + isClickable: |
| 190 | + bloc.voicePlayState != VoicePlayState.playing, | ||
| 192 | width: 60.w, | 191 | width: 60.w, |
| 193 | height: 60.w, | 192 | height: 60.w, |
| 194 | onTap: () { | 193 | onTap: () { |
| 195 | if (bloc.isRecording) { | 194 | if (bloc.isRecording) { |
| 196 | bloc.add(XSVoiceStopEvent()); | 195 | bloc.add(XSVoiceStopEvent()); |
| 197 | } else { | 196 | } else { |
| 198 | - bloc.add(XSVoiceStartEvent( | ||
| 199 | - bloc.readingContent(), | ||
| 200 | - '0', | ||
| 201 | - UserUtil.getUser()?.id.toString())); | 197 | + bloc.add(XSVoiceStartEvent(bloc.readingContent(), |
| 198 | + '0', UserUtil.getUser()?.id.toString())); | ||
| 202 | } | 199 | } |
| 203 | }, | 200 | }, |
| 204 | ), | 201 | ), |