From ee59df75d4f5db583027d54138c47e932942f536 Mon Sep 17 00:00:00 2001 From: longer Date: Thu, 14 Oct 2021 17:26:47 +0800 Subject: [PATCH] =?UTF-8?q?perf:=E6=8A=96=E9=9F=B3=E3=80=81=E5=B0=8F?= =?UTF-8?q?=E7=BA=A2=E4=B9=A6=20=E8=8F=9C=E5=8D=95=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/bottom/bottom9/bottom_app_bar_9.dart | 53 ++++-------------------- 1 file changed, 7 insertions(+), 46 deletions(-) diff --git a/lib/bottom/bottom9/bottom_app_bar_9.dart b/lib/bottom/bottom9/bottom_app_bar_9.dart index 3654e67..6bbbb94 100644 --- a/lib/bottom/bottom9/bottom_app_bar_9.dart +++ b/lib/bottom/bottom9/bottom_app_bar_9.dart @@ -31,12 +31,8 @@ class _BottomBar9State extends State with TickerProviderStateMixin { late AnimationController animationController; /// 中间按钮 点击之后动画 - late AnimationController centerBtnAnimationController; late AnimationController centerBtnScaleAnimationController; - /// 底部子菜单动画 - late Animation animation; - @override void initState() { animationController = AnimationController( @@ -52,30 +48,18 @@ class _BottomBar9State extends State with TickerProviderStateMixin { centerBtnScaleAnimationController.addStatusListener((status) { if (status == AnimationStatus.completed) { centerBtnScaleAnimationController.reverse(); + } else if (status == AnimationStatus.dismissed) { + /// 中间动画执行完毕,执行点击事件回调 + widget.addClick(); } }); - centerBtnAnimationController = AnimationController( - vsync: this, - duration: const Duration(milliseconds: 100 * 2), - ); - centerBtnAnimationController.addStatusListener((status) { - debugPrint('longer >>> $status'); - if (status == AnimationStatus.dismissed) { - if (!mounted) return; - } - }); - - animation = Tween(begin: 0.0, end: 1.0).animate(CurvedAnimation( - parent: centerBtnAnimationController, curve: Curves.fastOutSlowIn)); - super.initState(); } @override void dispose() { animationController.dispose(); - centerBtnAnimationController.dispose(); super.dispose(); } @@ -144,30 +128,6 @@ class _BottomBar9State extends State with TickerProviderStateMixin { ); } - Widget line() => Container(height: 20, width: 0.4, color: Colors.grey[400]); - - Widget menuItem(String title, IconData iconData) { - return GestureDetector( - onTap: () { - debugPrint('点击了 >>> $title'); - centerBtnAnimationController.reverse(); - }, - behavior: HitTestBehavior.opaque, - child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 10), - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - Icon(iconData, size: 28, color: Color(0xff2b292b)), - const SizedBox(height: 4), - Text(title, - style: TextStyle(fontSize: 12, color: Color(0xff2b292b))) - ], - ), - ), - ); - } - /// 中间的按钮 Widget centerButton() { return Container( @@ -180,10 +140,11 @@ class _BottomBar9State extends State with TickerProviderStateMixin { highlightColor: Colors.transparent, focusColor: Colors.transparent, onTap: () { - widget.addClick(); - // 执行旋转动画 && 缩放动画 - centerBtnAnimationController.forward(); + /// 缩放动画 centerBtnScaleAnimationController.forward(); + + /// 振动 + HapticFeedback.mediumImpact(); }, child: SizedBox( width: 40,