From e389933d0d4a723a68b784e16fea948e1a1a5769 Mon Sep 17 00:00:00 2001 From: AmirrezaChegini Date: Tue, 23 Dec 2025 23:40:48 +0330 Subject: [PATCH 1/3] fix: globe animation and image show with delay --- lib/core/widgets/animations/globe_animation.dart | 4 ++-- .../question/presentation/bloc/question_bloc.dart | 11 ++++++----- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/lib/core/widgets/animations/globe_animation.dart b/lib/core/widgets/animations/globe_animation.dart index 779d265..d37f6d8 100644 --- a/lib/core/widgets/animations/globe_animation.dart +++ b/lib/core/widgets/animations/globe_animation.dart @@ -25,8 +25,8 @@ class _GlobeAnimationState extends State super.initState(); _controller = AnimationController( vsync: this, - duration: const Duration(seconds: 1), - reverseDuration: const Duration(seconds: 1), + duration: const Duration(hours: 1), + reverseDuration: const Duration(hours: 1), ); _animation = Tween( begin: 1, diff --git a/lib/features/question/presentation/bloc/question_bloc.dart b/lib/features/question/presentation/bloc/question_bloc.dart index 3eeecc7..c69d300 100644 --- a/lib/features/question/presentation/bloc/question_bloc.dart +++ b/lib/features/question/presentation/bloc/question_bloc.dart @@ -87,10 +87,10 @@ class QuestionBloc extends Bloc { // ); // } - // Future showImageWithDelayed() async { - // await Future.delayed(const Duration(milliseconds: 500)); - // imageAnimationController?.forward(); - // } + Future showImageWithDelayed() async { + await Future.delayed(const Duration(milliseconds: 500)); + imageAnimationController?.forward(); + } void showHadith({required BuildContext context}) { showHadithDialog( @@ -240,6 +240,7 @@ class QuestionBloc extends Bloc { showAnswers: false, correctAnswer: false, )); + showImageWithDelayed(); await playQuestionAudio(); imageAnimationController?.reverse(); answerAnimationController?.forward().then((value) { @@ -290,7 +291,7 @@ class QuestionBloc extends Bloc { } else { showingAnswerSequence(show: true); await Future.delayed(const Duration(seconds: 1)); - imageAnimationController?.forward(); + showImageWithDelayed(); scrollController.jumpTo(0); await playQuestionAudio(); imageAnimationController?.reverse(); From ded978359bffe423eb6b619259cd06be54d56c79 Mon Sep 17 00:00:00 2001 From: AmirrezaChegini Date: Wed, 24 Dec 2025 00:09:24 +0330 Subject: [PATCH 2/3] fix: skip button --- .../presentation/ui/screens/question_screen.dart | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/features/question/presentation/ui/screens/question_screen.dart b/lib/features/question/presentation/ui/screens/question_screen.dart index 66a0d7f..b15a7d3 100644 --- a/lib/features/question/presentation/ui/screens/question_screen.dart +++ b/lib/features/question/presentation/ui/screens/question_screen.dart @@ -403,10 +403,12 @@ class _QuestionScreenState extends State controller: context.read().imageAnimationController!, child: TextButton( onPressed: () async { - context.read().imageAnimationController?.reverse(); - context.read().answerAnimationController?.forward(); - context.read().showingAnswerSequence(show: false); - context.read().pausePlaying(); + if(context.read().imageAnimationController?.isForwardOrCompleted ?? false){ + context.read().imageAnimationController?.reverse(); + context.read().answerAnimationController?.forward(); + context.read().showingAnswerSequence(show: false); + context.read().pausePlaying(); + } }, style: TextButton.styleFrom( foregroundColor: MyColors.white.withValues(alpha: 0.7), From 4d68dcf2f78e3cac1836f1a0ee5bcff755c4a50f Mon Sep 17 00:00:00 2001 From: AmirrezaChegini Date: Wed, 24 Dec 2025 00:13:51 +0330 Subject: [PATCH 3/3] fix: globe animation --- .../widgets/animations/globe_animation.dart | 64 ++++++------------- .../ui/screens/question_screen.dart | 1 - 2 files changed, 21 insertions(+), 44 deletions(-) diff --git a/lib/core/widgets/animations/globe_animation.dart b/lib/core/widgets/animations/globe_animation.dart index d37f6d8..6585db9 100644 --- a/lib/core/widgets/animations/globe_animation.dart +++ b/lib/core/widgets/animations/globe_animation.dart @@ -4,10 +4,9 @@ import 'package:flutter/material.dart'; import 'package:hadi_hoda_flutter/common_ui/resources/my_spaces.dart'; class GlobeAnimation extends StatefulWidget { - const GlobeAnimation({super.key, required this.child, this.state = true}); + const GlobeAnimation({super.key, required this.child}); final Widget child; - final bool state; @override State createState() => _GlobeAnimationState(); @@ -32,48 +31,27 @@ class _GlobeAnimationState extends State begin: 1, end: 1.05, ).animate(CurvedAnimation(parent: _controller, curve: Curves.linear)); - } - @override - void didUpdateWidget(covariant GlobeAnimation oldWidget) { - super.didUpdateWidget(oldWidget); - if (widget.state) { - _controller.repeat(reverse: true); - _timer = Timer.periodic(const Duration(seconds: 1), (timer) { - if (_gradient == null) { - if (!mounted) return; - setState(() { - _gradient = RadialGradient( - colors: [ - const Color(0XFFDFCD00), - const Color(0XFFDFCD00).withValues(alpha: 0.35), - const Color(0XFFDFCD00).withValues(alpha: 0), - ], - center: Alignment.center, - ); - }); - } else { - setState(() { - _gradient = null; - }); - } - }); - } else { - _timer?.cancel(); - _timer = null; - _controller.stop(); - if (!mounted) return; - setState(() { - _gradient = RadialGradient( - colors: [ - const Color(0XFFDFCD00).withValues(alpha: 0), - const Color(0XFFDFCD00).withValues(alpha: 0), - const Color(0XFFDFCD00).withValues(alpha: 0), - ], - center: Alignment.center, - ); - }); - } + _controller.repeat(reverse: true); + _timer = Timer.periodic(const Duration(seconds: 1), (timer) { + if (_gradient == null) { + if (!mounted) return; + setState(() { + _gradient = RadialGradient( + colors: [ + const Color(0XFFDFCD00), + const Color(0XFFDFCD00).withValues(alpha: 0.35), + const Color(0XFFDFCD00).withValues(alpha: 0), + ], + center: Alignment.center, + ); + }); + } else { + setState(() { + _gradient = null; + }); + } + }); } @override diff --git a/lib/features/question/presentation/ui/screens/question_screen.dart b/lib/features/question/presentation/ui/screens/question_screen.dart index b15a7d3..9fc09aa 100644 --- a/lib/features/question/presentation/ui/screens/question_screen.dart +++ b/lib/features/question/presentation/ui/screens/question_screen.dart @@ -389,7 +389,6 @@ class _QuestionScreenState extends State alignment: AlignmentDirectional.centerStart, children: [ GlobeAnimation( - state: true, child: MyImage( image: MyAssets.globe, fit: BoxFit.cover,