From 5d28338ed8aeacd96e7d57db6a78181ab52ea55a Mon Sep 17 00:00:00 2001 From: Songzex <2402265378@qq.com> Date: Wed, 25 Mar 2026 15:24:52 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=80=A5=E5=81=9C=E6=B8=90?= =?UTF-8?q?=E5=8F=98=E5=91=BC=E5=90=B8=E6=95=88=E6=9E=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../widgets/emergency_overlay.dart | 191 ++++++++++++++++-- 1 file changed, 170 insertions(+), 21 deletions(-) diff --git a/lib/features/remote_control/presentation/widgets/emergency_overlay.dart b/lib/features/remote_control/presentation/widgets/emergency_overlay.dart index 3235736d..197f1fa9 100644 --- a/lib/features/remote_control/presentation/widgets/emergency_overlay.dart +++ b/lib/features/remote_control/presentation/widgets/emergency_overlay.dart @@ -15,16 +15,18 @@ class _EmergencyOverlayState extends State @override void initState() { super.initState(); - // 设置动画循环时间,例如 600ms 闪烁一次 _controller = AnimationController( vsync: this, - duration: const Duration(milliseconds: 600), - )..repeat(reverse: true); // 反转运行实现呼吸效果 + duration: const Duration(milliseconds: 1500), + )..repeat(reverse: true); _opacityAnimation = Tween( - begin: 0.0, - end: 0.5, - ).animate(CurvedAnimation(parent: _controller, curve: Curves.easeInOut)); + begin: 0.3, + end: 0.6, + ).animate(CurvedAnimation( + parent: _controller, + curve: Curves.easeInOut, + )); } @override @@ -39,22 +41,169 @@ class _EmergencyOverlayState extends State animation: _opacityAnimation, builder: (context, child) { return IgnorePointer( - // 极其重要:确保光晕不遮挡下方的点击事件 - child: Container( - decoration: BoxDecoration( - // 使用径向渐变,让四周红,中间透明 - border: Border.all( - color: Colors.red.withOpacity(_opacityAnimation.value), - width: 20, // 边框宽度决定了红边的厚度 - ), - boxShadow: [ - BoxShadow( - color: Colors.red.withOpacity(_opacityAnimation.value), - blurRadius: 40, - spreadRadius: 10, + child: Stack( + children: [ + // 顶部渐变 + Positioned( + top: 0, + left: 0, + right: 0, + child: Container( + height: 60, + decoration: BoxDecoration( + gradient: LinearGradient( + begin: Alignment.topCenter, + end: Alignment.bottomCenter, + colors: [ + Colors.red.withOpacity(_opacityAnimation.value), + Colors.transparent, + ], + stops: const [0.0, 1.0], + ), + ), ), - ], - ), + ), + // 底部渐变 + Positioned( + bottom: 0, + left: 0, + right: 0, + child: Container( + height: 60, + decoration: BoxDecoration( + gradient: LinearGradient( + begin: Alignment.bottomCenter, + end: Alignment.topCenter, + colors: [ + Colors.red.withOpacity(_opacityAnimation.value), + Colors.transparent, + ], + stops: const [0.0, 1.0], + ), + ), + ), + ), + // 左侧渐变 + Positioned( + top: 0, + bottom: 0, + left: 0, + child: Container( + width: 60, + decoration: BoxDecoration( + gradient: LinearGradient( + begin: Alignment.centerLeft, + end: Alignment.centerRight, + colors: [ + Colors.red.withOpacity(_opacityAnimation.value), + Colors.transparent, + ], + stops: const [0.0, 1.0], + ), + ), + ), + ), + // 右侧渐变 + Positioned( + top: 0, + bottom: 0, + right: 0, + child: Container( + width: 60, + decoration: BoxDecoration( + gradient: LinearGradient( + begin: Alignment.centerRight, + end: Alignment.centerLeft, + colors: [ + Colors.red.withOpacity(_opacityAnimation.value), + Colors.transparent, + ], + stops: const [0.0, 1.0], + ), + ), + ), + ), + // 左上角渐变 + Positioned( + top: 0, + left: 0, + child: Container( + width: 80, + height: 80, + decoration: BoxDecoration( + gradient: RadialGradient( + center: Alignment.topLeft, + radius: 1.2, + colors: [ + Colors.red.withOpacity(_opacityAnimation.value), + Colors.transparent, + ], + stops: const [0.0, 1.0], + ), + ), + ), + ), + // 右上角渐变 + Positioned( + top: 0, + right: 0, + child: Container( + width: 80, + height: 80, + decoration: BoxDecoration( + gradient: RadialGradient( + center: Alignment.topRight, + radius: 1.2, + colors: [ + Colors.red.withOpacity(_opacityAnimation.value), + Colors.transparent, + ], + stops: const [0.0, 1.0], + ), + ), + ), + ), + // 左下角渐变 + Positioned( + bottom: 0, + left: 0, + child: Container( + width: 80, + height: 80, + decoration: BoxDecoration( + gradient: RadialGradient( + center: Alignment.bottomLeft, + radius: 1.2, + colors: [ + Colors.red.withOpacity(_opacityAnimation.value), + Colors.transparent, + ], + stops: const [0.0, 1.0], + ), + ), + ), + ), + // 右下角渐变 + Positioned( + bottom: 0, + right: 0, + child: Container( + width: 80, + height: 80, + decoration: BoxDecoration( + gradient: RadialGradient( + center: Alignment.bottomRight, + radius: 1.2, + colors: [ + Colors.red.withOpacity(_opacityAnimation.value), + Colors.transparent, + ], + stops: const [0.0, 1.0], + ), + ), + ), + ), + ], ), ); },