|
|
|
@ -76,8 +76,6 @@ class _QuestionScreenState extends State<QuestionScreen> with TickerProviderStat |
|
|
|
return Column( |
|
|
|
children: [ |
|
|
|
_stepper(), |
|
|
|
_titles(context), |
|
|
|
MySpaces.s20.gapHeight, |
|
|
|
Expanded( |
|
|
|
child: Stack( |
|
|
|
children: [ |
|
|
|
@ -95,11 +93,13 @@ class _QuestionScreenState extends State<QuestionScreen> with TickerProviderStat |
|
|
|
return Column( |
|
|
|
children: [ |
|
|
|
Spacer(), |
|
|
|
FadeAnimController( |
|
|
|
controller: context.read<QuestionBloc>().imageAnimationController, |
|
|
|
child: BlocBuilder<QuestionBloc, QuestionState>( |
|
|
|
builder: (context, state) => AnswerPictureBox( |
|
|
|
BlocBuilder<QuestionBloc, QuestionState>( |
|
|
|
builder: (context, state) => FadeAnimController( |
|
|
|
key: Key('${state.currentQuestion?.image}'), |
|
|
|
controller: context.read<QuestionBloc>().imageAnimationController, |
|
|
|
child: AnswerPictureBox( |
|
|
|
selected: false, |
|
|
|
showIndex: false, |
|
|
|
correctAnswer: 0, |
|
|
|
index: 0, |
|
|
|
image: state.currentQuestion?.image ?? '', |
|
|
|
@ -128,75 +128,73 @@ class _QuestionScreenState extends State<QuestionScreen> with TickerProviderStat |
|
|
|
Widget _titles(BuildContext context) { |
|
|
|
return BlocBuilder<QuestionBloc, QuestionState>( |
|
|
|
buildWhen: (previous, current) => |
|
|
|
previous.currentQuestion?.id != current.currentQuestion?.id, |
|
|
|
builder: (context, state) => |
|
|
|
FadeAnim( |
|
|
|
child: SizedBox( |
|
|
|
height: 100, |
|
|
|
child: ListView( |
|
|
|
controller: context.read<QuestionBloc>().titleController, |
|
|
|
children: [ |
|
|
|
Text( |
|
|
|
state.currentQuestion?.title ?? '', |
|
|
|
textAlign: TextAlign.center, |
|
|
|
style: MYTextStyle.titr1.copyWith( |
|
|
|
shadows: [ |
|
|
|
BoxShadow( |
|
|
|
offset: Offset(0, 2), |
|
|
|
color: MyColors.black.withValues(alpha: 0.25), |
|
|
|
), |
|
|
|
], |
|
|
|
), |
|
|
|
), |
|
|
|
], |
|
|
|
previous.currentQuestion?.id != current.currentQuestion?.id, |
|
|
|
builder: (context, state) => FadeAnimController( |
|
|
|
controller: context.read<QuestionBloc>().answerAnimationController, |
|
|
|
child: Text( |
|
|
|
state.currentQuestion?.title ?? '', |
|
|
|
textAlign: TextAlign.center, |
|
|
|
style: MYTextStyle.titr1.copyWith( |
|
|
|
shadows: [ |
|
|
|
BoxShadow( |
|
|
|
offset: Offset(0, 2), |
|
|
|
color: MyColors.black.withValues(alpha: 0.25), |
|
|
|
), |
|
|
|
), |
|
|
|
], |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
Widget _answers(BuildContext context) { |
|
|
|
return BlocBuilder<QuestionBloc, QuestionState>( |
|
|
|
buildWhen: (previous, current) => |
|
|
|
previous.currentQuestion?.id != current.currentQuestion?.id, |
|
|
|
builder: (context, state) => GridView.builder( |
|
|
|
itemCount: state.currentQuestion?.answers?.length ?? 0, |
|
|
|
physics: NeverScrollableScrollPhysics(), |
|
|
|
shrinkWrap: true, |
|
|
|
clipBehavior: Clip.none, |
|
|
|
padding: EdgeInsets.symmetric( |
|
|
|
horizontal: setSize(context: context, tablet: 70) ?? 0, |
|
|
|
), |
|
|
|
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( |
|
|
|
crossAxisCount: 2, |
|
|
|
crossAxisSpacing: MySpaces.s20, |
|
|
|
mainAxisSpacing: 20, |
|
|
|
childAspectRatio: 0.75, |
|
|
|
return ListView( |
|
|
|
children: [ |
|
|
|
_titles(context), |
|
|
|
30.0.gapHeight, |
|
|
|
BlocBuilder<QuestionBloc, QuestionState>( |
|
|
|
buildWhen: (previous, current) => |
|
|
|
previous.currentQuestion?.id != current.currentQuestion?.id, |
|
|
|
builder: (context, state) => GridView.builder( |
|
|
|
itemCount: state.currentQuestion?.answers?.length ?? 0, |
|
|
|
physics: NeverScrollableScrollPhysics(), |
|
|
|
shrinkWrap: true, |
|
|
|
clipBehavior: Clip.none, |
|
|
|
padding: EdgeInsets.symmetric( |
|
|
|
horizontal: setSize(context: context, tablet: 70) ?? 0, |
|
|
|
), |
|
|
|
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( |
|
|
|
crossAxisCount: 2, |
|
|
|
crossAxisSpacing: MySpaces.s20, |
|
|
|
mainAxisSpacing: 20, |
|
|
|
childAspectRatio: 0.75, |
|
|
|
), |
|
|
|
itemBuilder: (context, index) => |
|
|
|
state.currentQuestion?.answers?[index].imageId == null |
|
|
|
? SizedBox.shrink() |
|
|
|
: SlideAnim( |
|
|
|
key: Key('${state.currentQuestion?.id}'), |
|
|
|
controller: context.read<QuestionBloc>().answerAnimationController, |
|
|
|
index: index, |
|
|
|
child: AnswerBox( |
|
|
|
index: state.currentQuestion?.answers?[index].order ?? 1, |
|
|
|
answer: state.currentQuestion?.answers?[index] ?? 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), |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
itemBuilder: (context, index) => |
|
|
|
state.currentQuestion?.answers?[index].imageId == null |
|
|
|
? SizedBox.shrink() |
|
|
|
: SlideAnim( |
|
|
|
key: Key('${state.currentQuestion?.id}'), |
|
|
|
controller: context.read<QuestionBloc>().answerAnimationController, |
|
|
|
index: index, |
|
|
|
child: AnswerBox( |
|
|
|
index: state.currentQuestion?.answers?[index].order ?? 1, |
|
|
|
answer: state.currentQuestion?.answers?[index] ?? 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), |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
], |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
|