Browse Source

fix: skip audio

pull/46/head
AmirrezaChegini 7 days ago
parent
commit
be29096faf
  1. 2
      lib/core/widgets/showcase/my_showcase_widget.dart
  2. 14
      lib/features/question/presentation/bloc/question_bloc.dart
  3. 20
      lib/features/question/presentation/ui/screens/answer_screen.dart

2
lib/core/widgets/showcase/my_showcase_widget.dart

@ -128,7 +128,7 @@ class MyShowcaseWidget extends StatelessWidget {
Expanded( Expanded(
child: MyInkwell( child: MyInkwell(
onTap: () { onTap: () {
ShowcaseView.get().unregister();
ShowcaseView.get().dismiss();
}, },
splashColor: MyColors.transparent, splashColor: MyColors.transparent,
highlightColor: MyColors.transparent, highlightColor: MyColors.transparent,

14
lib/features/question/presentation/bloc/question_bloc.dart

@ -33,6 +33,7 @@ class QuestionBloc extends Bloc<QuestionEvent, QuestionState> {
) : super(QuestionState()) { ) : super(QuestionState()) {
volumeStream = _mainAudioService.volumeStream(); volumeStream = _mainAudioService.volumeStream();
playingStream = _mainAudioService.playingStream(); playingStream = _mainAudioService.playingStream();
// LocalStorage.saveData(key: MyConstants.firstShowcase, value: 'false');
initAudios(); initAudios();
registerShowCase(); registerShowCase();
on<GetLevelEvent>(_getLevelEvent); on<GetLevelEvent>(_getLevelEvent);
@ -82,6 +83,12 @@ class QuestionBloc extends Bloc<QuestionEvent, QuestionState> {
onStart: (showcaseIndex, key) { onStart: (showcaseIndex, key) {
LocalStorage.saveData(key: MyConstants.firstShowcase, value: 'true'); LocalStorage.saveData(key: MyConstants.firstShowcase, value: 'true');
}, },
onDismiss: (onDismiss) async {
await playQuestionAudio();
},
onFinish: () async {
await playQuestionAudio();
},
); );
} catch (_) {} } catch (_) {}
} }
@ -237,10 +244,15 @@ class QuestionBloc extends Bloc<QuestionEvent, QuestionState> {
currentQuestion: data.questions?.first, currentQuestion: data.questions?.first,
showAnswers: true showAnswers: true
)); ));
await playQuestionAudio();
if(LocalStorage.readData(key: MyConstants.firstShowcase) != 'true'){
await Future.delayed(Duration(milliseconds: 500));
animationController.forward().then((value) { animationController.forward().then((value) {
startShowcase(); startShowcase();
}); });
} else {
await playQuestionAudio();
animationController.forward();
}
}, },
(error) { (error) {
emit(state.copyWith(getQuestionStatus: BaseError(error.errorMessage))); emit(state.copyWith(getQuestionStatus: BaseError(error.errorMessage)));

20
lib/features/question/presentation/ui/screens/answer_screen.dart

@ -71,6 +71,12 @@ class _AnswerScreenState extends State<AnswerScreen> {
await audioService.play(); await audioService.play();
} }
@override
void dispose() {
audioService.pause();
super.dispose();
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Stack( return Stack(
@ -90,6 +96,13 @@ class _AnswerScreenState extends State<AnswerScreen> {
), ),
), ),
), ),
if (widget.showConfetti) ...{
Lottie.asset(
MyAnimations.confetti,
height: context.heightScreen,
fit: BoxFit.cover,
),
},
Positioned( Positioned(
bottom: setPlatform<double>(android: MySpaces.s30, iOS: MySpaces.s12), bottom: setPlatform<double>(android: MySpaces.s30, iOS: MySpaces.s12),
child: TextButton( child: TextButton(
@ -105,13 +118,6 @@ class _AnswerScreenState extends State<AnswerScreen> {
), ),
), ),
), ),
if (widget.showConfetti) ...{
Lottie.asset(
MyAnimations.confetti,
height: context.heightScreen,
fit: BoxFit.cover,
),
},
], ],
); );
} }

Loading…
Cancel
Save