From c79b191483d8ff8ba83ea0d814fd68fd5bd7ad00 Mon Sep 17 00:00:00 2001 From: mmc <1556375442@qq.com> Date: Mon, 20 Apr 2026 08:54:27 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=B8=80=E7=82=B9=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../auth/presentation/pages/login_page.dart | 7 ++- .../presentation/widgets/status_chip.dart | 56 +++---------------- 2 files changed, 14 insertions(+), 49 deletions(-) diff --git a/lib/features/auth/presentation/pages/login_page.dart b/lib/features/auth/presentation/pages/login_page.dart index cc2a4429..ab0695c0 100644 --- a/lib/features/auth/presentation/pages/login_page.dart +++ b/lib/features/auth/presentation/pages/login_page.dart @@ -105,7 +105,12 @@ class _LoginPageState extends State { ? null : () { if (!_isAgreed) { - ScaffoldMessenger.of(context).showSnackBar(const SnackBar(content: Text('请先阅读并同意用户协议'))); + ScaffoldMessenger.of(context).showSnackBar( + const SnackBar( + content: Text('请先阅读并同意用户协议'), + duration: Duration(seconds: 1), // 这里设置显示时长:2秒 + ), + ); return; } _handleLogin(); diff --git a/lib/features/remote_control/presentation/widgets/status_chip.dart b/lib/features/remote_control/presentation/widgets/status_chip.dart index 51e020d3..00d22aba 100644 --- a/lib/features/remote_control/presentation/widgets/status_chip.dart +++ b/lib/features/remote_control/presentation/widgets/status_chip.dart @@ -10,40 +10,25 @@ class StatusChip extends StatefulWidget { final bool breathing; final VoidCallback? onTap; - const StatusChip({ - super.key, - required this.text, - required this.color, - this.icon, - this.svgPath, - this.svgColor, - this.breathing = false, - this.onTap, - }) : assert(icon != null || svgPath != null, '必须提供 icon 或 svgPath 其中之一'); + const StatusChip({super.key, required this.text, required this.color, this.icon, this.svgPath, this.svgColor, this.breathing = false, this.onTap}) + : assert(icon != null || svgPath != null, '必须提供 icon 或 svgPath 其中之一'); @override State createState() => _StatusChipState(); } -class _StatusChipState extends State - with SingleTickerProviderStateMixin { +class _StatusChipState extends State with SingleTickerProviderStateMixin { late AnimationController _controller; late Animation _opacityAnimation; @override void initState() { super.initState(); - _controller = AnimationController( - vsync: this, - duration: const Duration(milliseconds: 1000), - ); + _controller = AnimationController(vsync: this, duration: const Duration(milliseconds: 1000)); if (widget.breathing) _controller.repeat(reverse: true); // 动画区间从 0.3 到 1.0 - _opacityAnimation = Tween( - begin: 0.3, - end: 1.0, - ).animate(CurvedAnimation(parent: _controller, curve: Curves.easeInOut)); + _opacityAnimation = Tween(begin: 0.3, end: 1.0).animate(CurvedAnimation(parent: _controller, curve: Curves.easeInOut)); } @override @@ -69,9 +54,7 @@ class _StatusChipState extends State animation: _opacityAnimation, builder: (context, child) { // 【关键】如果不呼吸,直接用 baseOpacity,不再强制给 1.0 - final currentAlpha = widget.breathing - ? _opacityAnimation.value * baseOpacity - : baseOpacity; + final currentAlpha = widget.breathing ? _opacityAnimation.value * baseOpacity : baseOpacity; return GestureDetector( onTap: widget.onTap, @@ -81,38 +64,15 @@ class _StatusChipState extends State // 这里应用计算后的透明度 color: widget.color.withOpacity(currentAlpha), borderRadius: BorderRadius.circular(12), - border: Border.all( - color: Colors.white.withOpacity(0.15), - width: 0.5, - ), + border: Border.all(color: Colors.white.withOpacity(0.15), width: 0.5), ), child: Row( mainAxisSize: MainAxisSize.min, children: [ - if (widget.svgPath != null) - SvgPicture.asset( - widget.svgPath!, - width: 14, - height: 14, - colorFilter: ColorFilter.mode( - widget.svgColor ?? Colors.white, - BlendMode.srcIn, - ), - ) - else - Icon( - widget.icon, - color: widget.svgColor ?? Colors.white, - size: 14, - ), const SizedBox(width: 5), Text( widget.text, - style: const TextStyle( - color: Colors.white, - fontSize: 10, - fontWeight: FontWeight.w600, - ), + style: const TextStyle(color: Colors.white, fontSize: 10, fontWeight: FontWeight.w600), ), ], ),