|
|
|
@ -45,7 +45,6 @@ class QuestionBloc extends Bloc<QuestionEvent, QuestionState> { |
|
|
|
_backgroundAudioService.dispose(); |
|
|
|
answerAnimationController.dispose(); |
|
|
|
imageAnimationController.dispose(); |
|
|
|
titleController.dispose(); |
|
|
|
return super.close(); |
|
|
|
} |
|
|
|
|
|
|
|
@ -77,16 +76,20 @@ class QuestionBloc extends Bloc<QuestionEvent, QuestionState> { |
|
|
|
final AudioService _effectAudioService; |
|
|
|
late final AnimationController answerAnimationController; |
|
|
|
late final AnimationController imageAnimationController; |
|
|
|
final ScrollController titleController = ScrollController(); |
|
|
|
|
|
|
|
/// ------------Functions------------ |
|
|
|
void startScrollTitle({Duration? audioDuration}) { |
|
|
|
if (audioDuration == null || audioDuration == Duration.zero) return; |
|
|
|
titleController.animateTo( |
|
|
|
titleController.position.maxScrollExtent, |
|
|
|
duration: audioDuration, |
|
|
|
curve: Curves.linear |
|
|
|
); |
|
|
|
// void startScrollTitle({Duration? audioDuration}) { |
|
|
|
// if (audioDuration == null || audioDuration == Duration.zero) return; |
|
|
|
// titleController.animateTo( |
|
|
|
// titleController.position.maxScrollExtent, |
|
|
|
// duration: audioDuration, |
|
|
|
// curve: Curves.linear |
|
|
|
// ); |
|
|
|
// } |
|
|
|
|
|
|
|
Future<void> showImageWithDelayed() async { |
|
|
|
await Future.delayed(const Duration(milliseconds: 500)); |
|
|
|
imageAnimationController.forward(); |
|
|
|
} |
|
|
|
|
|
|
|
void showHadith({required BuildContext context}) { |
|
|
|
@ -136,11 +139,7 @@ class QuestionBloc extends Bloc<QuestionEvent, QuestionState> { |
|
|
|
} |
|
|
|
|
|
|
|
Future<void> playQuestionAudio() async { |
|
|
|
if(titleController.hasClients){ |
|
|
|
titleController.jumpTo(0); |
|
|
|
} |
|
|
|
Duration? duration = await _mainAudioService.setAudio(filePath: state.currentQuestion?.audio); |
|
|
|
startScrollTitle(audioDuration: duration); |
|
|
|
await _mainAudioService.setAudio(filePath: state.currentQuestion?.audio); |
|
|
|
await _mainAudioService.play(); |
|
|
|
} |
|
|
|
|
|
|
|
@ -262,7 +261,6 @@ class QuestionBloc extends Bloc<QuestionEvent, QuestionState> { |
|
|
|
emit(state.copyWith(correctAnswer: event.chooseCorrectAnswer)); |
|
|
|
|
|
|
|
if (event.chooseCorrectAnswer) { |
|
|
|
answerAnimationController.reverse(); |
|
|
|
await showAnswerDialog( |
|
|
|
context: MyContext.get, |
|
|
|
correctAudio: state.currentQuestion?.correctAudio, |
|
|
|
@ -292,6 +290,7 @@ class QuestionBloc extends Bloc<QuestionEvent, QuestionState> { |
|
|
|
} |
|
|
|
} else { |
|
|
|
showingAnswerSequence(show: true); |
|
|
|
answerAnimationController.reverse(); |
|
|
|
imageAnimationController.forward(); |
|
|
|
await playQuestionAudio(); |
|
|
|
imageAnimationController.reverse(); |
|
|
|
|