diff --git a/flutter/lib/common/widgets/peer_tab_page.dart b/flutter/lib/common/widgets/peer_tab_page.dart index 11cf92dea..1d53e8c62 100644 --- a/flutter/lib/common/widgets/peer_tab_page.dart +++ b/flutter/lib/common/widgets/peer_tab_page.dart @@ -153,24 +153,25 @@ class _PeerTabPageState extends State border: Border( bottom: BorderSide(width: 2, color: color!), )); - return Obx(() => InkWell( - child: Container( - decoration: (hover.value - ? (selected ? decoBorder : deco) - : (selected ? decoBorder : null)), - child: Tooltip( - preferBelow: false, - message: model.tabTooltip(t), - onTriggered: isMobile ? mobileShowTabVisibilityMenu : null, - child: Icon(model.tabIcon(t), color: color), + return Obx(() => Tooltip( + preferBelow: false, + message: model.tabTooltip(t), + onTriggered: isMobile ? mobileShowTabVisibilityMenu : null, + child: InkWell( + child: Container( + decoration: (hover.value + ? (selected ? decoBorder : deco) + : (selected ? decoBorder : null)), + child: Icon(model.tabIcon(t), color: color) + .paddingSymmetric(horizontal: 4), ).paddingSymmetric(horizontal: 4), - ).paddingSymmetric(horizontal: 4), - onTap: () async { - await handleTabSelection(t); - await bind.setLocalFlutterOption( - k: 'peer-tab-index', v: t.toString()); - }, - onHover: (value) => hover.value = value, + onTap: () async { + await handleTabSelection(t); + await bind.setLocalFlutterOption( + k: 'peer-tab-index', v: t.toString()); + }, + onHover: (value) => hover.value = value, + ), )); }).toList()); } @@ -203,22 +204,23 @@ class _PeerTabPageState extends State final textColor = Theme.of(context).textTheme.titleLarge?.color; return Offstage( offstage: model.currentTab != index.index, - child: RefreshWidget( - onPressed: () { - if (gFFI.peerTabModel.currentTab < entries.length) { - entries[gFFI.peerTabModel.currentTab].load(); - } - }, - spinning: loading, - child: RotatedBox( - quarterTurns: 2, - child: Tooltip( - message: translate('Refresh'), - child: Icon( - Icons.refresh, - size: 18, - color: textColor, - )))), + child: Tooltip( + message: translate('Refresh'), + child: RefreshWidget( + onPressed: () { + if (gFFI.peerTabModel.currentTab < entries.length) { + entries[gFFI.peerTabModel.currentTab].load(); + } + }, + spinning: loading, + child: RotatedBox( + quarterTurns: 2, + child: Icon( + Icons.refresh, + size: 18, + color: textColor, + ))), + ), ); } @@ -230,6 +232,7 @@ class _PeerTabPageState extends State final textColor = Theme.of(context).textTheme.titleLarge?.color; final model = Provider.of(context); return _hoverAction( + toolTip: translate('Select'), context: context, onTap: () { model.setMultiSelectionMode(true); @@ -237,14 +240,12 @@ class _PeerTabPageState extends State Navigator.pop(context); } }, - child: Tooltip( - message: translate('Select'), - child: SvgPicture.asset( - "assets/checkbox-outline.svg", - width: 18, - height: 18, - colorFilter: svgColor(textColor), - )), + child: SvgPicture.asset( + "assets/checkbox-outline.svg", + width: 18, + height: 18, + colorFilter: svgColor(textColor), + ), ); } @@ -370,6 +371,7 @@ class _PeerTabPageState extends State } return _hoverAction( context: context, + toolTip: translate('Delete'), onTap: () { onSubmit() async { final peers = model.selectedPeers; @@ -406,9 +408,7 @@ class _PeerTabPageState extends State deleteConfirmDialog(onSubmit, translate('Delete')); }, - child: Tooltip( - message: translate('Delete'), - child: Icon(Icons.delete, color: Colors.red))); + child: Icon(Icons.delete, color: Colors.red)); } Widget addSelectionToFav() { @@ -418,6 +418,7 @@ class _PeerTabPageState extends State model.currentTab != PeerTabIndex.recent.index, // show based on recent child: _hoverAction( context: context, + toolTip: translate('Add to Favorites'), onTap: () async { final peers = model.selectedPeers; final favs = (await bind.mainGetFav()).toList(); @@ -430,9 +431,7 @@ class _PeerTabPageState extends State model.setMultiSelectionMode(false); showToast(translate('Successful')); }, - child: Tooltip( - message: translate('Add to Favorites'), - child: Icon(model.icons[PeerTabIndex.fav.index])), + child: Icon(model.icons[PeerTabIndex.fav.index]), ).marginOnly(left: isMobile ? 11 : 6), ); } @@ -447,14 +446,13 @@ class _PeerTabPageState extends State offstage: !gFFI.userModel.isLogin || addressbooks.isEmpty, child: _hoverAction( context: context, + toolTip: translate('Add to address book'), onTap: () { final peers = model.selectedPeers.map((e) => Peer.copy(e)).toList(); addPeersToAbDialog(peers); model.setMultiSelectionMode(false); }, - child: Tooltip( - message: translate('Add to address book'), - child: Icon(model.icons[PeerTabIndex.ab.index])), + child: Icon(model.icons[PeerTabIndex.ab.index]), ).marginOnly(left: isMobile ? 11 : 6), ); } @@ -467,6 +465,7 @@ class _PeerTabPageState extends State gFFI.abModel.currentAbTags.isEmpty, child: _hoverAction( context: context, + toolTip: translate('Edit Tag'), onTap: () { editAbTagDialog(List.empty(), (selectedTags) async { final peers = model.selectedPeers; @@ -476,8 +475,7 @@ class _PeerTabPageState extends State showToast(translate('Successful')); }); }, - child: Tooltip( - message: translate('Edit Tag'), child: Icon(Icons.tag))) + child: Icon(Icons.tag)) .marginOnly(left: isMobile ? 11 : 6), ); } @@ -496,11 +494,11 @@ class _PeerTabPageState extends State model.selectedPeers.length >= model.currentTabCachedPeers.length, child: _hoverAction( context: context, + toolTip: translate('Select All'), onTap: () { model.selectAll(); }, - child: Tooltip( - message: translate('Select All'), child: Icon(Icons.select_all)), + child: Icon(Icons.select_all), ).marginOnly(left: 6), ); } @@ -509,24 +507,23 @@ class _PeerTabPageState extends State final model = Provider.of(context); return _hoverAction( context: context, + toolTip: translate('Close'), onTap: () { model.setMultiSelectionMode(false); }, - child: - Tooltip(message: translate('Close'), child: Icon(Icons.clear))) + child: Icon(Icons.clear)) .marginOnly(left: 6); } Widget _toggleTags() { return _hoverAction( context: context, + toolTip: translate('Close'), hoverableWhenfalse: hideAbTagsPanel, - child: Tooltip( - message: translate('Toggle Tags'), - child: Icon( - Icons.tag_rounded, - size: 18, - )), + child: Icon( + Icons.tag_rounded, + size: 18, + ), onTap: () async { await bind.mainSetLocalOption( key: "hideAbTagsPanel", value: hideAbTagsPanel.value ? "" : "Y"); @@ -576,14 +573,13 @@ class _PeerTabPageState extends State (BuildContext context, Future Function() showMenu) { return _hoverAction( context: context, - child: Tooltip( - message: translate('More'), - child: SvgPicture.asset( - "assets/chevron_up_chevron_down.svg", - width: 18, - height: 18, - colorFilter: svgColor(textColor), - )), + toolTip: translate('More'), + child: SvgPicture.asset( + "assets/chevron_up_chevron_down.svg", + width: 18, + height: 18, + colorFilter: svgColor(textColor), + ), onTap: showMenu, ); }, @@ -658,18 +654,17 @@ class _PeerSearchBarState extends State { ? _buildSearchBar() : _hoverAction( context: context, + toolTip: translate('Search'), padding: const EdgeInsets.only(right: 2), onTap: () { setState(() { drawer = true; }); }, - child: Tooltip( - message: translate('Search'), - child: Icon( - Icons.search_rounded, - color: Theme.of(context).hintColor, - ))); + child: Icon( + Icons.search_rounded, + color: Theme.of(context).hintColor, + )); } Widget _buildSearchBar() { @@ -810,16 +805,15 @@ class _PeerViewDropdownState extends State { var menuPos = RelativeRect.fromLTRB(0, 0, 0, 0); return _hoverAction( context: context, - child: Tooltip( - message: translate('Change view'), - child: Icon( - peerCardUiType.value == PeerUiType.grid - ? Icons.grid_view_rounded - : peerCardUiType.value == PeerUiType.tile - ? Icons.view_list_rounded - : Icons.view_agenda_rounded, - size: 18, - )), + toolTip: translate('Change view'), + child: Icon( + peerCardUiType.value == PeerUiType.grid + ? Icons.grid_view_rounded + : peerCardUiType.value == PeerUiType.tile + ? Icons.view_list_rounded + : Icons.view_agenda_rounded, + size: 18, + ), onTapDown: (details) { final x = details.globalPosition.dx; final y = details.globalPosition.dy; @@ -889,12 +883,11 @@ class _PeerSortDropdownState extends State { var menuPos = RelativeRect.fromLTRB(0, 0, 0, 0); return _hoverAction( context: context, - child: Tooltip( - message: translate('Sort by'), - child: Icon( - Icons.sort_rounded, - size: 18, - )), + toolTip: translate('Sort by'), + child: Icon( + Icons.sort_rounded, + size: 18, + ), onTapDown: (details) { final x = details.globalPosition.dx; final y = details.globalPosition.dy; @@ -976,6 +969,7 @@ Widget _hoverAction( {required BuildContext context, required Widget child, required Function() onTap, + required String toolTip, GestureTapDownCallback? onTapDown, RxBool? hoverableWhenfalse, EdgeInsetsGeometry padding = const EdgeInsets.all(4.0)}) { @@ -984,16 +978,19 @@ Widget _hoverAction( color: Theme.of(context).colorScheme.background, borderRadius: BorderRadius.circular(6), ); - return Obx( - () => Container( - margin: EdgeInsets.symmetric(horizontal: 1), - decoration: - (hover.value || hoverableWhenfalse?.value == false) ? deco : null, - child: InkWell( - onHover: (value) => hover.value = value, - onTap: onTap, - onTapDown: onTapDown, - child: Container(padding: padding, child: child))), + return Tooltip( + message: toolTip, + child: Obx( + () => Container( + margin: EdgeInsets.symmetric(horizontal: 1), + decoration: + (hover.value || hoverableWhenfalse?.value == false) ? deco : null, + child: InkWell( + onHover: (value) => hover.value = value, + onTap: onTap, + onTapDown: onTapDown, + child: Container(padding: padding, child: child))), + ), ); }