|
|
@ -3,7 +3,6 @@ import 'package:flutter_bloc/flutter_bloc.dart'; |
|
|
import 'package:gif/gif.dart'; |
|
|
import 'package:gif/gif.dart'; |
|
|
import 'package:hadi_hoda_flutter/common_ui/resources/my_assets.dart'; |
|
|
import 'package:hadi_hoda_flutter/common_ui/resources/my_assets.dart'; |
|
|
import 'package:hadi_hoda_flutter/common_ui/resources/my_colors.dart'; |
|
|
import 'package:hadi_hoda_flutter/common_ui/resources/my_colors.dart'; |
|
|
import 'package:hadi_hoda_flutter/common_ui/resources/my_spaces.dart'; |
|
|
|
|
|
import 'package:hadi_hoda_flutter/common_ui/resources/my_text_style.dart'; |
|
|
import 'package:hadi_hoda_flutter/common_ui/resources/my_text_style.dart'; |
|
|
import 'package:hadi_hoda_flutter/core/constants/my_constants.dart'; |
|
|
import 'package:hadi_hoda_flutter/core/constants/my_constants.dart'; |
|
|
import 'package:hadi_hoda_flutter/core/utils/gap.dart'; |
|
|
import 'package:hadi_hoda_flutter/core/utils/gap.dart'; |
|
|
@ -161,46 +160,47 @@ class _QuestionScreenState extends State<QuestionScreen> with TickerProviderStat |
|
|
child: _titles(context), |
|
|
child: _titles(context), |
|
|
), |
|
|
), |
|
|
50.0.gapHeight, |
|
|
50.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: const NeverScrollableScrollPhysics(), |
|
|
|
|
|
shrinkWrap: true, |
|
|
|
|
|
clipBehavior: Clip.none, |
|
|
|
|
|
padding: EdgeInsets.symmetric( |
|
|
|
|
|
horizontal: setSize(context: context, tablet: 70) ?? 0, |
|
|
|
|
|
), |
|
|
|
|
|
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount( |
|
|
|
|
|
crossAxisCount: 2, |
|
|
|
|
|
crossAxisSpacing: MySpaces.s20, |
|
|
|
|
|
mainAxisSpacing: 20, |
|
|
|
|
|
childAspectRatio: 0.75, |
|
|
|
|
|
), |
|
|
|
|
|
itemBuilder: (context, index) => |
|
|
|
|
|
state.currentQuestion?.answers?[index].imageId == null |
|
|
|
|
|
? const 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), |
|
|
|
|
|
), |
|
|
|
|
|
|
|
|
SizedBox( |
|
|
|
|
|
width: context.widthScreen, |
|
|
|
|
|
child: BlocBuilder<QuestionBloc, QuestionState>( |
|
|
|
|
|
buildWhen: (previous, current) => |
|
|
|
|
|
previous.currentQuestion?.id != current.currentQuestion?.id, |
|
|
|
|
|
builder: (context, state) => |
|
|
|
|
|
Wrap( |
|
|
|
|
|
alignment: WrapAlignment.center, |
|
|
|
|
|
spacing: 10, |
|
|
|
|
|
runSpacing: 20, |
|
|
|
|
|
children: List.generate( |
|
|
|
|
|
state.currentQuestion?.answers?.length ?? 0, |
|
|
|
|
|
(index) => |
|
|
|
|
|
state.currentQuestion?.answers?[index].imageId == null |
|
|
|
|
|
? const SizedBox.shrink() |
|
|
|
|
|
: SizedBox( |
|
|
|
|
|
key: Key('${state.currentQuestion?.id}$index'), |
|
|
|
|
|
width: 180, |
|
|
|
|
|
height: 250, |
|
|
|
|
|
child: SlideAnim( |
|
|
|
|
|
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), |
|
|
|
|
|
), |
|
|
|
|
|
), |
|
|
|
|
|
), |
|
|
), |
|
|
), |
|
|
), |
|
|
), |
|
|
|
|
|
), |
|
|
), |
|
|
), |
|
|
), |
|
|
), |
|
|
], |
|
|
], |
|
|
|