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(
child: MyInkwell(
onTap: () {
ShowcaseView.get().unregister();
ShowcaseView.get().dismiss();
},
splashColor: 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()) {
volumeStream = _mainAudioService.volumeStream();
playingStream = _mainAudioService.playingStream();
// LocalStorage.saveData(key: MyConstants.firstShowcase, value: 'false');
initAudios();
registerShowCase();
on<GetLevelEvent>(_getLevelEvent);
@ -82,6 +83,12 @@ class QuestionBloc extends Bloc<QuestionEvent, QuestionState> {
onStart: (showcaseIndex, key) {
LocalStorage.saveData(key: MyConstants.firstShowcase, value: 'true');
},
onDismiss: (onDismiss) async {
await playQuestionAudio();
},
onFinish: () async {
await playQuestionAudio();
},
);
} catch (_) {}
}
@ -237,10 +244,15 @@ class QuestionBloc extends Bloc<QuestionEvent, QuestionState> {
currentQuestion: data.questions?.first,
showAnswers: true
));
await playQuestionAudio();
if(LocalStorage.readData(key: MyConstants.firstShowcase) != 'true'){
await Future.delayed(Duration(milliseconds: 500));
animationController.forward().then((value) {
startShowcase();
});
} else {
await playQuestionAudio();
animationController.forward();
}
},
(error) {
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();
}
@override
void dispose() {
audioService.pause();
super.dispose();
}
@override
Widget build(BuildContext context) {
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(
bottom: setPlatform<double>(android: MySpaces.s30, iOS: MySpaces.s12),
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