From 5455cd3dead1b84df5085010c158b9b3e99176fd Mon Sep 17 00:00:00 2001 From: rustdesk Date: Sat, 24 Jun 2023 18:27:47 +0800 Subject: [PATCH] better peer tab --- flutter/lib/common/widgets/peer_tab_page.dart | 62 +++++++++---------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/flutter/lib/common/widgets/peer_tab_page.dart b/flutter/lib/common/widgets/peer_tab_page.dart index 03feb5b9f..3882f866a 100644 --- a/flutter/lib/common/widgets/peer_tab_page.dart +++ b/flutter/lib/common/widgets/peer_tab_page.dart @@ -86,7 +86,7 @@ class _PeerTabPageState extends State crossAxisAlignment: CrossAxisAlignment.start, children: [ SizedBox( - height: 28, + height: 32, child: Container( padding: isDesktop ? null : EdgeInsets.symmetric(horizontal: 2), child: Row( @@ -114,40 +114,40 @@ class _PeerTabPageState extends State Widget _createSwitchBar(BuildContext context) { final model = Provider.of(context); - getTabChild(int t) { - final color = model.currentTab == t - ? MyTheme.tabbar(context).selectedTextColor - : MyTheme.tabbar(context).unSelectedTextColor - ?..withOpacity(0.5); - return Obx(() => Tooltip( - message: model.tabTooltip(t, gFFI.groupModel.groupName.value), - child: Icon(model.tabIcon(t), color: color), - )); - } - return ListView( scrollDirection: Axis.horizontal, physics: NeverScrollableScrollPhysics(), children: model.indexs.map((t) { - return InkWell( - child: Container( - padding: const EdgeInsets.symmetric(horizontal: 8), - decoration: BoxDecoration( - color: model.currentTab == t - ? Theme.of(context).colorScheme.background - : null, - borderRadius: BorderRadius.circular(6), - ), - child: Align( - alignment: Alignment.center, - child: getTabChild(t), - )), - onTap: () async { - await handleTabSelection(t); - await bind.setLocalFlutterConfig( - k: 'peer-tab-index', v: t.toString()); - }, - ); + final selected = model.currentTab == t; + final color = selected + ? MyTheme.tabbar(context).selectedTextColor + : MyTheme.tabbar(context).unSelectedTextColor + ?..withOpacity(0.5); + final hover = false.obs; + final deco = BoxDecoration( + color: Theme.of(context).colorScheme.background, + borderRadius: BorderRadius.circular(6)); + final decoBorder = BoxDecoration( + border: Border( + bottom: BorderSide(width: 2, color: color!), + )); + return Obx(() => InkWell( + child: Container( + decoration: + selected ? decoBorder : (hover.value ? deco : null), + child: Tooltip( + message: + model.tabTooltip(t, gFFI.groupModel.groupName.value), + child: Icon(model.tabIcon(t), color: color), + ).paddingSymmetric(horizontal: 4), + ).paddingSymmetric(horizontal: 4), + onTap: () async { + await handleTabSelection(t); + await bind.setLocalFlutterConfig( + k: 'peer-tab-index', v: t.toString()); + }, + onHover: (value) => hover.value = value, + )); }).toList()); }