From 88d43508e4122285180d694c1dc14b93946cc42d Mon Sep 17 00:00:00 2001 From: tanlongsheng <252620078@qq.com> Date: Tue, 5 Aug 2025 10:46:44 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=94=A4=E9=86=92=E8=80=B3?= =?UTF-8?q?=E6=9C=BA=E5=8A=A8=E7=94=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/core/widgets/intro_overlay_builder.dart | 70 +++++++++++++++++++-- 1 file changed, 65 insertions(+), 5 deletions(-) diff --git a/lib/core/widgets/intro_overlay_builder.dart b/lib/core/widgets/intro_overlay_builder.dart index 5b64fc8c1..bab8412b0 100644 --- a/lib/core/widgets/intro_overlay_builder.dart +++ b/lib/core/widgets/intro_overlay_builder.dart @@ -11,11 +11,13 @@ class IntroOverlayBuilder { }) { return Column( children: [ - SizedBox( - width: 200.w, - height: 200.w, - child: Lottie.asset('assets/lottie/intro_foriday.json'), - ), + isWakeup + ? _AnimatedLottieWidget() + : SizedBox( + width: 200.w, + height: 200.w, + child: Lottie.asset('assets/lottie/intro_foriday.json'), + ), Padding( padding: EdgeInsets.only(bottom: 20.w), child: Text( @@ -106,3 +108,61 @@ class IntroOverlayBuilder { ); } } + +// 新增的动画Widget +class _AnimatedLottieWidget extends StatefulWidget { + @override + _AnimatedLottieWidgetState createState() => _AnimatedLottieWidgetState(); +} + +class _AnimatedLottieWidgetState extends State<_AnimatedLottieWidget> + with SingleTickerProviderStateMixin { + late AnimationController _animationController; + late Animation _scaleAnimation; + + @override + void initState() { + super.initState(); + + // 创建动画控制器,持续时间1.5秒 + _animationController = AnimationController( + duration: const Duration(milliseconds: 1000), + vsync: this, + ); + + // 创建缩放动画,从0.8到1.2再回到1.0 + _scaleAnimation = Tween( + begin: 0.8, + end: 1.2, + ).animate(CurvedAnimation( + parent: _animationController, + curve: Curves.elasticInOut, + )); + + // 启动动画并设置为循环 + _animationController.repeat(reverse: true); + } + + @override + void dispose() { + _animationController.dispose(); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + return AnimatedBuilder( + animation: _scaleAnimation, + builder: (context, child) { + return Transform.scale( + scale: _scaleAnimation.value, + child: SizedBox( + width: 200.w, + height: 200.w, + child: Lottie.asset('assets/lottie/intro_foriday.json'), + ), + ); + }, + ); + } +}