|
|
|
@ -48,6 +48,7 @@ class QuestionBloc extends Bloc<QuestionEvent, QuestionState> { |
|
|
|
_backgroundAudioService.dispose(); |
|
|
|
answerAnimationController.dispose(); |
|
|
|
imageAnimationController.dispose(); |
|
|
|
titleController.dispose(); |
|
|
|
return super.close(); |
|
|
|
} |
|
|
|
|
|
|
|
@ -79,6 +80,7 @@ class QuestionBloc extends Bloc<QuestionEvent, QuestionState> { |
|
|
|
final AudioService _effectAudioService; |
|
|
|
late final AnimationController answerAnimationController; |
|
|
|
late final AnimationController imageAnimationController; |
|
|
|
final ScrollController titleController = ScrollController(); |
|
|
|
|
|
|
|
/// ------------Functions------------ |
|
|
|
void registerShowCase() { |
|
|
|
@ -118,6 +120,15 @@ class QuestionBloc extends Bloc<QuestionEvent, QuestionState> { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
void startScrollTitle({Duration? audioDuration}) { |
|
|
|
if (audioDuration == null || audioDuration == Duration.zero) return; |
|
|
|
titleController.animateTo( |
|
|
|
titleController.position.maxScrollExtent, |
|
|
|
duration: audioDuration, |
|
|
|
curve: Curves.linear |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
void showHadith({required BuildContext context}) { |
|
|
|
showHadithDialog( |
|
|
|
context: context, |
|
|
|
@ -165,7 +176,11 @@ class QuestionBloc extends Bloc<QuestionEvent, QuestionState> { |
|
|
|
} |
|
|
|
|
|
|
|
Future<void> playQuestionAudio() async { |
|
|
|
await _mainAudioService.setAudio(filePath: state.currentQuestion?.audio); |
|
|
|
if(titleController.hasClients){ |
|
|
|
titleController.jumpTo(0); |
|
|
|
} |
|
|
|
Duration? duration = await _mainAudioService.setAudio(filePath: state.currentQuestion?.audio); |
|
|
|
startScrollTitle(audioDuration: duration); |
|
|
|
await _mainAudioService.play(); |
|
|
|
} |
|
|
|
|
|
|
|
|