|
|
@ -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'; |
|
|
@ -91,28 +90,30 @@ class _QuestionScreenState extends State<QuestionScreen> with TickerProviderStat |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
Widget _questionImage(BuildContext context) { |
|
|
Widget _questionImage(BuildContext context) { |
|
|
return Column( |
|
|
|
|
|
|
|
|
return FadeAnimDelayed( |
|
|
|
|
|
duration: const Duration(seconds: 1), |
|
|
|
|
|
child: FadeAnimController( |
|
|
|
|
|
controller: context.read<QuestionBloc>().imageAnimationController, |
|
|
|
|
|
child: Column( |
|
|
children: [ |
|
|
children: [ |
|
|
|
|
|
10.0.gapHeight, |
|
|
|
|
|
_titles(context), |
|
|
const Spacer(), |
|
|
const Spacer(), |
|
|
BlocBuilder<QuestionBloc, QuestionState>( |
|
|
BlocBuilder<QuestionBloc, QuestionState>( |
|
|
builder: (context, state) => FadeAnimDelayed( |
|
|
|
|
|
duration: const Duration(seconds: 1), |
|
|
|
|
|
child: FadeAnimController( |
|
|
|
|
|
|
|
|
builder: (context, state) => AnswerPictureBox( |
|
|
key: Key('${state.currentQuestion?.image}'), |
|
|
key: Key('${state.currentQuestion?.image}'), |
|
|
controller: context.read<QuestionBloc>().imageAnimationController, |
|
|
|
|
|
child: AnswerPictureBox( |
|
|
|
|
|
selected: false, |
|
|
selected: false, |
|
|
showIndex: false, |
|
|
showIndex: false, |
|
|
correctAnswer: 0, |
|
|
correctAnswer: 0, |
|
|
index: 0, |
|
|
index: 0, |
|
|
image: state.currentQuestion?.image ?? '', |
|
|
image: state.currentQuestion?.image ?? '', |
|
|
autostart: Autostart.once, |
|
|
|
|
|
), |
|
|
|
|
|
), |
|
|
|
|
|
|
|
|
autostart: Autostart.loop, |
|
|
), |
|
|
), |
|
|
), |
|
|
), |
|
|
const Spacer(), |
|
|
const Spacer(), |
|
|
], |
|
|
], |
|
|
|
|
|
), |
|
|
|
|
|
), |
|
|
); |
|
|
); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -133,9 +134,8 @@ class _QuestionScreenState extends State<QuestionScreen> with TickerProviderStat |
|
|
return BlocBuilder<QuestionBloc, QuestionState>( |
|
|
return BlocBuilder<QuestionBloc, QuestionState>( |
|
|
buildWhen: (previous, current) => |
|
|
buildWhen: (previous, current) => |
|
|
previous.currentQuestion?.id != current.currentQuestion?.id, |
|
|
previous.currentQuestion?.id != current.currentQuestion?.id, |
|
|
builder: (context, state) => FadeAnimController( |
|
|
|
|
|
controller: context.read<QuestionBloc>().answerAnimationController, |
|
|
|
|
|
child: Text( |
|
|
|
|
|
|
|
|
builder: (context, state) => |
|
|
|
|
|
Text( |
|
|
state.currentQuestion?.title ?? '', |
|
|
state.currentQuestion?.title ?? '', |
|
|
textAlign: TextAlign.center, |
|
|
textAlign: TextAlign.center, |
|
|
style: MYTextStyle.titr1.copyWith( |
|
|
style: MYTextStyle.titr1.copyWith( |
|
|
@ -147,37 +147,39 @@ class _QuestionScreenState extends State<QuestionScreen> with TickerProviderStat |
|
|
], |
|
|
], |
|
|
), |
|
|
), |
|
|
), |
|
|
), |
|
|
), |
|
|
|
|
|
); |
|
|
); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
Widget _answers(BuildContext context) { |
|
|
Widget _answers(BuildContext context) { |
|
|
return ListView( |
|
|
return ListView( |
|
|
|
|
|
controller: context.read<QuestionBloc>().scrollController, |
|
|
|
|
|
padding: const EdgeInsets.only(top: 10), |
|
|
children: [ |
|
|
children: [ |
|
|
_titles(context), |
|
|
|
|
|
30.0.gapHeight, |
|
|
|
|
|
BlocBuilder<QuestionBloc, QuestionState>( |
|
|
|
|
|
|
|
|
FadeAnimController( |
|
|
|
|
|
controller: context.read<QuestionBloc>().answerAnimationController, |
|
|
|
|
|
child: _titles(context), |
|
|
|
|
|
), |
|
|
|
|
|
50.0.gapHeight, |
|
|
|
|
|
SizedBox( |
|
|
|
|
|
width: context.widthScreen, |
|
|
|
|
|
child: BlocBuilder<QuestionBloc, QuestionState>( |
|
|
buildWhen: (previous, current) => |
|
|
buildWhen: (previous, current) => |
|
|
previous.currentQuestion?.id != current.currentQuestion?.id, |
|
|
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) => |
|
|
|
|
|
|
|
|
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 |
|
|
state.currentQuestion?.answers?[index].imageId == null |
|
|
? const SizedBox.shrink() |
|
|
? const SizedBox.shrink() |
|
|
: SlideAnim( |
|
|
|
|
|
key: Key('${state.currentQuestion?.id}'), |
|
|
|
|
|
|
|
|
: SizedBox( |
|
|
|
|
|
key: Key('${state.currentQuestion?.id}$index'), |
|
|
|
|
|
width: 180, |
|
|
|
|
|
height: 250, |
|
|
|
|
|
child: SlideAnim( |
|
|
controller: context.read<QuestionBloc>().answerAnimationController, |
|
|
controller: context.read<QuestionBloc>().answerAnimationController, |
|
|
index: index, |
|
|
index: index, |
|
|
child: AnswerBox( |
|
|
child: AnswerBox( |
|
|
@ -198,6 +200,9 @@ class _QuestionScreenState extends State<QuestionScreen> with TickerProviderStat |
|
|
), |
|
|
), |
|
|
), |
|
|
), |
|
|
), |
|
|
), |
|
|
|
|
|
), |
|
|
|
|
|
), |
|
|
|
|
|
), |
|
|
], |
|
|
], |
|
|
); |
|
|
); |
|
|
} |
|
|
} |
|
|
@ -222,8 +227,8 @@ class _QuestionScreenState extends State<QuestionScreen> with TickerProviderStat |
|
|
), |
|
|
), |
|
|
), |
|
|
), |
|
|
Positioned( |
|
|
Positioned( |
|
|
left: 120, |
|
|
|
|
|
right: 120, |
|
|
|
|
|
|
|
|
left: 90, |
|
|
|
|
|
right: 90, |
|
|
child: FadeAnimController( |
|
|
child: FadeAnimController( |
|
|
controller: context.read<QuestionBloc>().imageAnimationController, |
|
|
controller: context.read<QuestionBloc>().imageAnimationController, |
|
|
child: TextButton( |
|
|
child: TextButton( |
|
|
@ -236,6 +241,7 @@ class _QuestionScreenState extends State<QuestionScreen> with TickerProviderStat |
|
|
style: TextButton.styleFrom( |
|
|
style: TextButton.styleFrom( |
|
|
foregroundColor: MyColors.white.withValues(alpha: 0.7), |
|
|
foregroundColor: MyColors.white.withValues(alpha: 0.7), |
|
|
), |
|
|
), |
|
|
|
|
|
child: FittedBox( |
|
|
child: Text( |
|
|
child: Text( |
|
|
context.translate.skip, |
|
|
context.translate.skip, |
|
|
style: MYTextStyle.button2 |
|
|
style: MYTextStyle.button2 |
|
|
@ -243,6 +249,7 @@ class _QuestionScreenState extends State<QuestionScreen> with TickerProviderStat |
|
|
), |
|
|
), |
|
|
), |
|
|
), |
|
|
), |
|
|
), |
|
|
|
|
|
), |
|
|
PositionedDirectional( |
|
|
PositionedDirectional( |
|
|
end: 0, |
|
|
end: 0, |
|
|
child: GlassyButton( |
|
|
child: GlassyButton( |
|
|
|