|
|
|
@ -39,7 +39,9 @@ class _QuestionScreenState extends State<QuestionScreen> |
|
|
|
void initState() { |
|
|
|
super.initState(); |
|
|
|
WidgetsBinding.instance.addObserver(this); |
|
|
|
context.read<QuestionBloc>().answerAnimationController = AnimationController( |
|
|
|
context |
|
|
|
.read<QuestionBloc>() |
|
|
|
.answerAnimationController = AnimationController( |
|
|
|
vsync: this, |
|
|
|
duration: const Duration(milliseconds: 500), |
|
|
|
reverseDuration: const Duration(milliseconds: 500), |
|
|
|
@ -78,12 +80,7 @@ class _QuestionScreenState extends State<QuestionScreen> |
|
|
|
children: [ |
|
|
|
_stepper(), |
|
|
|
Expanded( |
|
|
|
child: Stack( |
|
|
|
children: [ |
|
|
|
_questionImage(context), |
|
|
|
_answers(context), |
|
|
|
], |
|
|
|
), |
|
|
|
child: Stack(children: [_questionImage(context), _answers(context)]), |
|
|
|
), |
|
|
|
_bottom(context), |
|
|
|
], |
|
|
|
@ -166,9 +163,10 @@ class _QuestionScreenState extends State<QuestionScreen> |
|
|
|
children: [ |
|
|
|
Row( |
|
|
|
key: Key('${state.currentQuestion?.id}answer0'), |
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween, |
|
|
|
spacing: 20, |
|
|
|
children: [ |
|
|
|
Builder( |
|
|
|
Expanded( |
|
|
|
child: Builder( |
|
|
|
key: Key('${state.currentQuestion?.id}0'), |
|
|
|
builder: (context) { |
|
|
|
if (state.currentQuestion?.answers?[0].imageId == |
|
|
|
@ -185,7 +183,10 @@ class _QuestionScreenState extends State<QuestionScreen> |
|
|
|
index: 0, |
|
|
|
child: AnswerBox( |
|
|
|
index: |
|
|
|
state.currentQuestion?.answers?[0].order ?? |
|
|
|
state |
|
|
|
.currentQuestion |
|
|
|
?.answers?[0] |
|
|
|
.order ?? |
|
|
|
1, |
|
|
|
answer: |
|
|
|
state.currentQuestion?.answers?[0] ?? |
|
|
|
@ -193,7 +194,9 @@ class _QuestionScreenState extends State<QuestionScreen> |
|
|
|
correctAnswer: |
|
|
|
state.currentQuestion?.correctAnswer ?? 0, |
|
|
|
onNotifTap: (AnswerEntity answer) { |
|
|
|
context.read<QuestionBloc>().showAnswerDialog( |
|
|
|
context |
|
|
|
.read<QuestionBloc>() |
|
|
|
.showAnswerDialog( |
|
|
|
context: context, |
|
|
|
answerEntity: answer, |
|
|
|
); |
|
|
|
@ -212,7 +215,9 @@ class _QuestionScreenState extends State<QuestionScreen> |
|
|
|
} |
|
|
|
}, |
|
|
|
), |
|
|
|
Builder( |
|
|
|
), |
|
|
|
Expanded( |
|
|
|
child: Builder( |
|
|
|
key: Key('${state.currentQuestion?.id}1'), |
|
|
|
builder: (context) { |
|
|
|
if (state.currentQuestion?.answers?[1].imageId == |
|
|
|
@ -229,7 +234,10 @@ class _QuestionScreenState extends State<QuestionScreen> |
|
|
|
index: 1, |
|
|
|
child: AnswerBox( |
|
|
|
index: |
|
|
|
state.currentQuestion?.answers?[1].order ?? |
|
|
|
state |
|
|
|
.currentQuestion |
|
|
|
?.answers?[1] |
|
|
|
.order ?? |
|
|
|
1, |
|
|
|
answer: |
|
|
|
state.currentQuestion?.answers?[1] ?? |
|
|
|
@ -237,7 +245,9 @@ class _QuestionScreenState extends State<QuestionScreen> |
|
|
|
correctAnswer: |
|
|
|
state.currentQuestion?.correctAnswer ?? 0, |
|
|
|
onNotifTap: (AnswerEntity answer) { |
|
|
|
context.read<QuestionBloc>().showAnswerDialog( |
|
|
|
context |
|
|
|
.read<QuestionBloc>() |
|
|
|
.showAnswerDialog( |
|
|
|
context: context, |
|
|
|
answerEntity: answer, |
|
|
|
); |
|
|
|
@ -256,16 +266,14 @@ class _QuestionScreenState extends State<QuestionScreen> |
|
|
|
} |
|
|
|
}, |
|
|
|
), |
|
|
|
), |
|
|
|
], |
|
|
|
), |
|
|
|
if ((state.currentQuestion?.answers?.length ?? 0) == 3) |
|
|
|
Row( |
|
|
|
key: Key('${state.currentQuestion?.id}answer1'), |
|
|
|
mainAxisAlignment: |
|
|
|
(state.currentQuestion?.answers?.length ?? 0) > 3 |
|
|
|
? MainAxisAlignment.spaceBetween |
|
|
|
: MainAxisAlignment.center, |
|
|
|
mainAxisAlignment: MainAxisAlignment.center, |
|
|
|
children: [ |
|
|
|
if ((state.currentQuestion?.answers?.length ?? 0) > 2) |
|
|
|
Builder( |
|
|
|
key: Key('${state.currentQuestion?.id}2'), |
|
|
|
builder: (context) { |
|
|
|
@ -315,9 +323,68 @@ class _QuestionScreenState extends State<QuestionScreen> |
|
|
|
} |
|
|
|
}, |
|
|
|
), |
|
|
|
if ((state.currentQuestion?.answers?.length ?? 0) > 3) |
|
|
|
Builder( |
|
|
|
key: Key('${state.currentQuestion?.id}1'), |
|
|
|
], |
|
|
|
), |
|
|
|
if ((state.currentQuestion?.answers?.length ?? 0) == 4) |
|
|
|
Row( |
|
|
|
key: Key('${state.currentQuestion?.id}answer2'), |
|
|
|
spacing: 20, |
|
|
|
children: [ |
|
|
|
Expanded( |
|
|
|
child: Builder( |
|
|
|
key: Key('${state.currentQuestion?.id}2'), |
|
|
|
builder: (context) { |
|
|
|
if (state.currentQuestion?.answers?[2].imageId == |
|
|
|
null) { |
|
|
|
return const SizedBox.shrink(); |
|
|
|
} else { |
|
|
|
return SizedBox( |
|
|
|
width: 180, |
|
|
|
height: 250, |
|
|
|
child: SlideAnim( |
|
|
|
controller: context |
|
|
|
.read<QuestionBloc>() |
|
|
|
.answerAnimationController!, |
|
|
|
index: 2, |
|
|
|
child: AnswerBox( |
|
|
|
index: |
|
|
|
state |
|
|
|
.currentQuestion |
|
|
|
?.answers?[2] |
|
|
|
.order ?? |
|
|
|
1, |
|
|
|
answer: |
|
|
|
state.currentQuestion?.answers?[2] ?? |
|
|
|
AnswerEntity(), |
|
|
|
correctAnswer: |
|
|
|
state.currentQuestion?.correctAnswer ?? |
|
|
|
0, |
|
|
|
onNotifTap: (AnswerEntity answer) { |
|
|
|
context |
|
|
|
.read<QuestionBloc>() |
|
|
|
.showAnswerDialog( |
|
|
|
context: context, |
|
|
|
answerEntity: answer, |
|
|
|
); |
|
|
|
}, |
|
|
|
onTap: (isCorrect, correctAnswer) => |
|
|
|
context.read<QuestionBloc>().add( |
|
|
|
ChooseAnswerEvent( |
|
|
|
isCorrect, |
|
|
|
correctAnswer, |
|
|
|
context, |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
); |
|
|
|
} |
|
|
|
}, |
|
|
|
), |
|
|
|
), |
|
|
|
Expanded( |
|
|
|
child: Builder( |
|
|
|
key: Key('${state.currentQuestion?.id}3'), |
|
|
|
builder: (context) { |
|
|
|
if (state.currentQuestion?.answers?[3].imageId == |
|
|
|
null) { |
|
|
|
@ -342,7 +409,8 @@ class _QuestionScreenState extends State<QuestionScreen> |
|
|
|
state.currentQuestion?.answers?[3] ?? |
|
|
|
AnswerEntity(), |
|
|
|
correctAnswer: |
|
|
|
state.currentQuestion?.correctAnswer ?? 0, |
|
|
|
state.currentQuestion?.correctAnswer ?? |
|
|
|
0, |
|
|
|
onNotifTap: (AnswerEntity answer) { |
|
|
|
context |
|
|
|
.read<QuestionBloc>() |
|
|
|
@ -365,6 +433,7 @@ class _QuestionScreenState extends State<QuestionScreen> |
|
|
|
} |
|
|
|
}, |
|
|
|
), |
|
|
|
), |
|
|
|
], |
|
|
|
), |
|
|
|
], |
|
|
|
@ -393,13 +462,27 @@ class _QuestionScreenState extends State<QuestionScreen> |
|
|
|
left: 90, |
|
|
|
right: 90, |
|
|
|
child: FadeAnimController( |
|
|
|
controller: context.read<QuestionBloc>().imageAnimationController!, |
|
|
|
controller: context |
|
|
|
.read<QuestionBloc>() |
|
|
|
.imageAnimationController!, |
|
|
|
child: TextButton( |
|
|
|
onPressed: () async { |
|
|
|
if(context.read<QuestionBloc>().imageAnimationController?.isForwardOrCompleted ?? false){ |
|
|
|
context.read<QuestionBloc>().imageAnimationController?.reverse(); |
|
|
|
context.read<QuestionBloc>().answerAnimationController?.forward(); |
|
|
|
context.read<QuestionBloc>().showingAnswerSequence(show: false); |
|
|
|
if (context |
|
|
|
.read<QuestionBloc>() |
|
|
|
.imageAnimationController |
|
|
|
?.isForwardOrCompleted ?? |
|
|
|
false) { |
|
|
|
context |
|
|
|
.read<QuestionBloc>() |
|
|
|
.imageAnimationController |
|
|
|
?.reverse(); |
|
|
|
context |
|
|
|
.read<QuestionBloc>() |
|
|
|
.answerAnimationController |
|
|
|
?.forward(); |
|
|
|
context.read<QuestionBloc>().showingAnswerSequence( |
|
|
|
show: false, |
|
|
|
); |
|
|
|
context.read<QuestionBloc>().pausePlaying(); |
|
|
|
} |
|
|
|
}, |
|
|
|
@ -412,7 +495,7 @@ class _QuestionScreenState extends State<QuestionScreen> |
|
|
|
style: MYTextStyle.button2, |
|
|
|
), |
|
|
|
), |
|
|
|
) |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
PositionedDirectional( |
|
|
|
@ -429,4 +512,3 @@ class _QuestionScreenState extends State<QuestionScreen> |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|