fix peer tab Tooltip persist via move it up (#7510)

Signed-off-by: 21pages <pages21@163.com>
This commit is contained in:
21pages 2024-03-25 20:58:55 +08:00 committed by GitHub
parent c0c110fe7e
commit 376bcefc14
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -153,17 +153,17 @@ class _PeerTabPageState extends State<PeerTabPage>
border: Border(
bottom: BorderSide(width: 2, color: color!),
));
return Obx(() => InkWell(
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: Tooltip(
preferBelow: false,
message: model.tabTooltip(t),
onTriggered: isMobile ? mobileShowTabVisibilityMenu : null,
child: Icon(model.tabIcon(t), color: color),
).paddingSymmetric(horizontal: 4),
child: Icon(model.tabIcon(t), color: color)
.paddingSymmetric(horizontal: 4),
).paddingSymmetric(horizontal: 4),
onTap: () async {
await handleTabSelection(t);
@ -171,6 +171,7 @@ class _PeerTabPageState extends State<PeerTabPage>
k: 'peer-tab-index', v: t.toString());
},
onHover: (value) => hover.value = value,
),
));
}).toList());
}
@ -203,6 +204,8 @@ class _PeerTabPageState extends State<PeerTabPage>
final textColor = Theme.of(context).textTheme.titleLarge?.color;
return Offstage(
offstage: model.currentTab != index.index,
child: Tooltip(
message: translate('Refresh'),
child: RefreshWidget(
onPressed: () {
if (gFFI.peerTabModel.currentTab < entries.length) {
@ -212,13 +215,12 @@ class _PeerTabPageState extends State<PeerTabPage>
spinning: loading,
child: RotatedBox(
quarterTurns: 2,
child: Tooltip(
message: translate('Refresh'),
child: Icon(
Icons.refresh,
size: 18,
color: textColor,
)))),
))),
),
);
}
@ -230,6 +232,7 @@ class _PeerTabPageState extends State<PeerTabPage>
final textColor = Theme.of(context).textTheme.titleLarge?.color;
final model = Provider.of<PeerTabModel>(context);
return _hoverAction(
toolTip: translate('Select'),
context: context,
onTap: () {
model.setMultiSelectionMode(true);
@ -237,14 +240,12 @@ class _PeerTabPageState extends State<PeerTabPage>
Navigator.pop(context);
}
},
child: Tooltip(
message: translate('Select'),
child: SvgPicture.asset(
"assets/checkbox-outline.svg",
width: 18,
height: 18,
colorFilter: svgColor(textColor),
)),
),
);
}
@ -370,6 +371,7 @@ class _PeerTabPageState extends State<PeerTabPage>
}
return _hoverAction(
context: context,
toolTip: translate('Delete'),
onTap: () {
onSubmit() async {
final peers = model.selectedPeers;
@ -406,9 +408,7 @@ class _PeerTabPageState extends State<PeerTabPage>
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<PeerTabPage>
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<PeerTabPage>
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<PeerTabPage>
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<PeerTabPage>
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<PeerTabPage>
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<PeerTabPage>
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<PeerTabPage>
final model = Provider.of<PeerTabModel>(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,
)),
),
onTap: () async {
await bind.mainSetLocalOption(
key: "hideAbTagsPanel", value: hideAbTagsPanel.value ? "" : "Y");
@ -576,14 +573,13 @@ class _PeerTabPageState extends State<PeerTabPage>
(BuildContext context, Future<void> Function() showMenu) {
return _hoverAction(
context: context,
child: Tooltip(
message: translate('More'),
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<PeerSearchBar> {
? _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,
)));
));
}
Widget _buildSearchBar() {
@ -810,8 +805,7 @@ class _PeerViewDropdownState extends State<PeerViewDropdown> {
var menuPos = RelativeRect.fromLTRB(0, 0, 0, 0);
return _hoverAction(
context: context,
child: Tooltip(
message: translate('Change view'),
toolTip: translate('Change view'),
child: Icon(
peerCardUiType.value == PeerUiType.grid
? Icons.grid_view_rounded
@ -819,7 +813,7 @@ class _PeerViewDropdownState extends State<PeerViewDropdown> {
? 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<PeerSortDropdown> {
var menuPos = RelativeRect.fromLTRB(0, 0, 0, 0);
return _hoverAction(
context: context,
child: Tooltip(
message: translate('Sort by'),
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,7 +978,9 @@ Widget _hoverAction(
color: Theme.of(context).colorScheme.background,
borderRadius: BorderRadius.circular(6),
);
return Obx(
return Tooltip(
message: toolTip,
child: Obx(
() => Container(
margin: EdgeInsets.symmetric(horizontal: 1),
decoration:
@ -994,6 +990,7 @@ Widget _hoverAction(
onTap: onTap,
onTapDown: onTapDown,
child: Container(padding: padding, child: child))),
),
);
}