Browse Source

مشکلات انیمیشن هادی و هدی

pull/60/head
AmirrezaChegini 1 week ago
parent
commit
5514e8510c
  1. 2
      lib/core/widgets/answer_box/answer_box_show.dart
  2. 4
      lib/core/widgets/answer_box/styles/picture_box.dart
  3. 4
      lib/features/question/presentation/bloc/question_bloc.dart
  4. 35
      lib/features/question/presentation/ui/screens/question_screen.dart

2
lib/core/widgets/answer_box/answer_box_show.dart

@ -34,7 +34,7 @@ class AnswerBoxShow extends StatelessWidget {
selected: false,
index: index,
image: answer.image ?? '',
autostart: Autostart.once,
autostart: Autostart.loop,
correctAnswer: 0,
),
Positioned(

4
lib/core/widgets/answer_box/styles/picture_box.dart

@ -52,7 +52,7 @@ class AnswerPictureBox extends StatelessWidget {
width: context.widthScreen,
height: context.heightScreen,
image: FileImage(File(image)),
fps: 30,
fps: 25,
autostart: autostart,
fit: BoxFit.cover,
color: MyColors.black,
@ -63,7 +63,7 @@ class AnswerPictureBox extends StatelessWidget {
width: context.widthScreen,
height: context.heightScreen,
image: FileImage(File(image)),
fps: 30,
fps: 25,
autostart: autostart,
fit: BoxFit.cover,
),

4
lib/features/question/presentation/bloc/question_bloc.dart

@ -45,6 +45,7 @@ class QuestionBloc extends Bloc<QuestionEvent, QuestionState> {
_backgroundAudioService.dispose();
answerAnimationController.dispose();
imageAnimationController.dispose();
scrollController.dispose();
return super.close();
}
@ -76,6 +77,7 @@ class QuestionBloc extends Bloc<QuestionEvent, QuestionState> {
final AudioService _effectAudioService;
late final AnimationController answerAnimationController;
late final AnimationController imageAnimationController;
final ScrollController scrollController = ScrollController();
/// ------------Functions------------
// void startScrollTitle({Duration? audioDuration}) {
@ -192,6 +194,7 @@ class QuestionBloc extends Bloc<QuestionEvent, QuestionState> {
}
Future<void> getNextLevelEvent({required BuildContext context}) async {
_backgroundAudioService.dispose();
await _getNextLevelUseCase(QuestionParams()).then((value) => value.fold(
(data) {
context.pushNamed(
@ -293,6 +296,7 @@ class QuestionBloc extends Bloc<QuestionEvent, QuestionState> {
answerAnimationController.reverse();
await Future.delayed(const Duration(seconds: 1));
imageAnimationController.forward();
scrollController.jumpTo(0);
await playQuestionAudio();
imageAnimationController.reverse();
answerAnimationController.forward().then((value) {

35
lib/features/question/presentation/ui/screens/question_screen.dart

@ -91,28 +91,30 @@ class _QuestionScreenState extends State<QuestionScreen> with TickerProviderStat
}
Widget _questionImage(BuildContext context) {
return Column(
return FadeAnimDelayed(
duration: const Duration(seconds: 1),
child: FadeAnimController(
controller: context.read<QuestionBloc>().imageAnimationController,
child: Column(
children: [
10.0.gapHeight,
_titles(context),
const Spacer(),
BlocBuilder<QuestionBloc, QuestionState>(
builder: (context, state) => FadeAnimDelayed(
duration: const Duration(seconds: 1),
child: FadeAnimController(
builder: (context, state) => AnswerPictureBox(
key: Key('${state.currentQuestion?.image}'),
controller: context.read<QuestionBloc>().imageAnimationController,
child: AnswerPictureBox(
selected: false,
showIndex: false,
correctAnswer: 0,
index: 0,
image: state.currentQuestion?.image ?? '',
autostart: Autostart.once,
),
),
autostart: Autostart.loop,
),
),
const Spacer(),
],
),
),
);
}
@ -133,9 +135,8 @@ class _QuestionScreenState extends State<QuestionScreen> with TickerProviderStat
return BlocBuilder<QuestionBloc, QuestionState>(
buildWhen: (previous, current) =>
previous.currentQuestion?.id != current.currentQuestion?.id,
builder: (context, state) => FadeAnimController(
controller: context.read<QuestionBloc>().answerAnimationController,
child: Text(
builder: (context, state) =>
Text(
state.currentQuestion?.title ?? '',
textAlign: TextAlign.center,
style: MYTextStyle.titr1.copyWith(
@ -147,15 +148,19 @@ class _QuestionScreenState extends State<QuestionScreen> with TickerProviderStat
],
),
),
),
);
}
Widget _answers(BuildContext context) {
return ListView(
controller: context.read<QuestionBloc>().scrollController,
padding: const EdgeInsets.only(top: 10),
children: [
_titles(context),
30.0.gapHeight,
FadeAnimController(
controller: context.read<QuestionBloc>().answerAnimationController,
child: _titles(context),
),
50.0.gapHeight,
BlocBuilder<QuestionBloc, QuestionState>(
buildWhen: (previous, current) =>
previous.currentQuestion?.id != current.currentQuestion?.id,

Loading…
Cancel
Save