|
|
|
@ -50,6 +50,7 @@ class QuestionBloc extends Bloc<QuestionEvent, QuestionState> { |
|
|
|
imageAnimationController?.dispose(); |
|
|
|
globeAnimationController?.dispose(); |
|
|
|
scrollController.dispose(); |
|
|
|
questionsScrollController.dispose(); |
|
|
|
PaintingBinding.instance.imageCache.clear(); |
|
|
|
PaintingBinding.instance.imageCache.clearLiveImages(); |
|
|
|
return super.close(); |
|
|
|
@ -100,6 +101,7 @@ class QuestionBloc extends Bloc<QuestionEvent, QuestionState> { |
|
|
|
AnimationController? imageAnimationController; |
|
|
|
AnimationController? globeAnimationController; |
|
|
|
final ScrollController scrollController = ScrollController(); |
|
|
|
final ScrollController questionsScrollController = ScrollController(); |
|
|
|
|
|
|
|
int _nextSequenceToken() => ++_sequenceToken; |
|
|
|
|
|
|
|
@ -193,8 +195,20 @@ class QuestionBloc extends Bloc<QuestionEvent, QuestionState> { |
|
|
|
if (answers.isNotEmpty) { |
|
|
|
answers.removeWhere((e) => e.imageId == null); |
|
|
|
} |
|
|
|
for (final answer in answers) { |
|
|
|
for (int i = 0;i < answers.length; i++) { |
|
|
|
if (!_isActiveSequence(token)) return; |
|
|
|
final answer = answers[i]; |
|
|
|
// scroll to bottom to see answers better |
|
|
|
final currentPixelsPosition = questionsScrollController.position.pixels; |
|
|
|
final maxScrollExtent = questionsScrollController.position.maxScrollExtent; |
|
|
|
if(i > 1 && currentPixelsPosition < |
|
|
|
maxScrollExtent) { |
|
|
|
questionsScrollController.animateTo( |
|
|
|
maxScrollExtent, |
|
|
|
duration: const Duration(milliseconds: 300), |
|
|
|
curve: Curves.easeOut, |
|
|
|
); |
|
|
|
} |
|
|
|
await Future.delayed(const Duration(milliseconds: 350), () async { |
|
|
|
if (_isActiveSequence(token) && MyContext.get.mounted) { |
|
|
|
await showAnswerDialog( |
|
|
|
@ -347,6 +361,7 @@ class QuestionBloc extends Bloc<QuestionEvent, QuestionState> { |
|
|
|
await Future.delayed(const Duration(milliseconds: 30)); |
|
|
|
if (!_isActiveSequence(token)) return; |
|
|
|
scrollController.jumpTo(0); |
|
|
|
questionsScrollController.jumpTo(0); |
|
|
|
answerAnimationController?.reverse(); |
|
|
|
await Future.delayed(const Duration(seconds: 1), () async { |
|
|
|
if (!_isActiveSequence(token)) return; |
|
|
|
@ -383,6 +398,7 @@ class QuestionBloc extends Bloc<QuestionEvent, QuestionState> { |
|
|
|
if (!_isActiveSequence(token)) return; |
|
|
|
imageAnimationController?.forward(); |
|
|
|
scrollController.jumpTo(0); |
|
|
|
questionsScrollController.jumpTo(0); |
|
|
|
changeGlobeState(key: MyAnimations.globeStateSpeaking); |
|
|
|
await playQuestionAudio(); |
|
|
|
if (!_isActiveSequence(token)) return; |
|
|
|
|