fix: CustomTooltip fix

This commit is contained in:
PartyDonut 2025-07-31 16:30:14 +02:00
parent 013722fc96
commit b977bfc319
2 changed files with 83 additions and 50 deletions

View file

@ -125,7 +125,7 @@ class _SideNavigationBarState extends ConsumerState<SideNavigationBar> {
padding: const EdgeInsets.all(12),
child: Text(
destination.label,
style: Theme.of(context).textTheme.titleMedium,
style: Theme.of(context).textTheme.titleSmall,
),
),
),
@ -164,7 +164,7 @@ class _SideNavigationBarState extends ConsumerState<SideNavigationBar> {
padding: const EdgeInsets.all(12),
child: Text(
view.name,
style: Theme.of(context).textTheme.titleMedium,
style: Theme.of(context).textTheme.titleSmall,
),
),
),
@ -206,9 +206,23 @@ class _SideNavigationBarState extends ConsumerState<SideNavigationBar> {
},
).toList(),
builder: (context, remaining) {
return PopupMenuButton(
return CustomTooltip(
tooltipContent: expandedSideBar
? null
: Card(
child: Padding(
padding: const EdgeInsets.all(12),
child: Text(
context.localized.moreOptions,
style: Theme.of(context).textTheme.titleSmall,
),
),
),
position: TooltipPosition.right,
child: PopupMenuButton(
iconColor: Theme.of(context).colorScheme.onSurface.withValues(alpha: 0.45),
padding: EdgeInsets.zero,
tooltip: "",
icon: NavigationButton(
label: context.localized.other,
selectedIcon: const Icon(IconsaxPlusLinear.arrow_square_down),
@ -260,6 +274,7 @@ class _SideNavigationBarState extends ConsumerState<SideNavigationBar> {
),
)
.toList(),
),
);
},
),
@ -287,6 +302,7 @@ class _SideNavigationBarState extends ConsumerState<SideNavigationBar> {
),
),
),
if (AdaptiveLayout.of(context).inputDevice == InputDevice.pointer) const SizedBox(height: 16),
],
),
),

View file

@ -29,15 +29,31 @@ class CustomTooltipState extends State<CustomTooltip> {
Timer? _timer;
final GlobalKey _tooltipKey = GlobalKey();
Timer? _timeOut;
void _resetTimer() {
_timeOut?.cancel();
_timeOut = Timer(const Duration(seconds: 2), () {
_hideTooltip();
_timeOut = null;
});
}
void _showTooltip() {
_timer = Timer(widget.showDelay, () {
_overlayEntry = _createOverlayEntry();
Overlay.of(context).insert(_overlayEntry!);
});
_timeOut = Timer(const Duration(seconds: 2), () {
_hideTooltip();
_timeOut = null;
});
}
void _hideTooltip() {
_timer?.cancel();
_timeOut?.cancel();
_overlayEntry?.remove();
_overlayEntry = null;
}
@ -106,6 +122,7 @@ class CustomTooltipState extends State<CustomTooltip> {
return MouseRegion(
onEnter: (_) => _showTooltip(),
onExit: (_) => _hideTooltip(),
onHover: (_) => _resetTimer(),
child: Stack(
children: [
widget.child,