mirror of
https://github.com/gabehf/Fladder.git
synced 2026-03-13 01:10:31 -07:00
fix: CustomTooltip fix
This commit is contained in:
parent
013722fc96
commit
b977bfc319
2 changed files with 83 additions and 50 deletions
|
|
@ -125,7 +125,7 @@ class _SideNavigationBarState extends ConsumerState<SideNavigationBar> {
|
||||||
padding: const EdgeInsets.all(12),
|
padding: const EdgeInsets.all(12),
|
||||||
child: Text(
|
child: Text(
|
||||||
destination.label,
|
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),
|
padding: const EdgeInsets.all(12),
|
||||||
child: Text(
|
child: Text(
|
||||||
view.name,
|
view.name,
|
||||||
style: Theme.of(context).textTheme.titleMedium,
|
style: Theme.of(context).textTheme.titleSmall,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
@ -206,60 +206,75 @@ class _SideNavigationBarState extends ConsumerState<SideNavigationBar> {
|
||||||
},
|
},
|
||||||
).toList(),
|
).toList(),
|
||||||
builder: (context, remaining) {
|
builder: (context, remaining) {
|
||||||
return PopupMenuButton(
|
return CustomTooltip(
|
||||||
iconColor: Theme.of(context).colorScheme.onSurface.withValues(alpha: 0.45),
|
tooltipContent: expandedSideBar
|
||||||
padding: EdgeInsets.zero,
|
? null
|
||||||
icon: NavigationButton(
|
: Card(
|
||||||
label: context.localized.other,
|
child: Padding(
|
||||||
selectedIcon: const Icon(IconsaxPlusLinear.arrow_square_down),
|
padding: const EdgeInsets.all(12),
|
||||||
icon: const Icon(IconsaxPlusLinear.arrow_square_down),
|
child: Text(
|
||||||
expanded: shouldExpand,
|
context.localized.moreOptions,
|
||||||
customIcon: usePostersForLibrary
|
style: Theme.of(context).textTheme.titleSmall,
|
||||||
? ClipRRect(
|
|
||||||
borderRadius: FladderTheme.smallShape.borderRadius,
|
|
||||||
child: const SizedBox.square(
|
|
||||||
dimension: 50,
|
|
||||||
child: Card(
|
|
||||||
child: Icon(IconsaxPlusLinear.arrow_square_down),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
)
|
),
|
||||||
: null,
|
),
|
||||||
horizontal: true,
|
position: TooltipPosition.right,
|
||||||
),
|
child: PopupMenuButton(
|
||||||
itemBuilder: (context) => views
|
iconColor: Theme.of(context).colorScheme.onSurface.withValues(alpha: 0.45),
|
||||||
.sublist(views.length - remaining)
|
padding: EdgeInsets.zero,
|
||||||
.map(
|
tooltip: "",
|
||||||
(e) => PopupMenuItem(
|
icon: NavigationButton(
|
||||||
onTap: () => context.pushRoute(LibrarySearchRoute(viewModelId: e.id)),
|
label: context.localized.other,
|
||||||
child: Row(
|
selectedIcon: const Icon(IconsaxPlusLinear.arrow_square_down),
|
||||||
spacing: 8,
|
icon: const Icon(IconsaxPlusLinear.arrow_square_down),
|
||||||
children: [
|
expanded: shouldExpand,
|
||||||
usePostersForLibrary
|
customIcon: usePostersForLibrary
|
||||||
? Padding(
|
? ClipRRect(
|
||||||
padding: const EdgeInsets.symmetric(vertical: 4),
|
borderRadius: FladderTheme.smallShape.borderRadius,
|
||||||
child: ClipRRect(
|
child: const SizedBox.square(
|
||||||
borderRadius: FladderTheme.smallShape.borderRadius,
|
dimension: 50,
|
||||||
child: SizedBox.square(
|
child: Card(
|
||||||
dimension: 45,
|
child: Icon(IconsaxPlusLinear.arrow_square_down),
|
||||||
child: FladderImage(
|
),
|
||||||
image: e.imageData?.primary,
|
),
|
||||||
placeHolder: Card(
|
)
|
||||||
child: Icon(
|
: null,
|
||||||
e.collectionType.iconOutlined,
|
horizontal: true,
|
||||||
|
),
|
||||||
|
itemBuilder: (context) => views
|
||||||
|
.sublist(views.length - remaining)
|
||||||
|
.map(
|
||||||
|
(e) => PopupMenuItem(
|
||||||
|
onTap: () => context.pushRoute(LibrarySearchRoute(viewModelId: e.id)),
|
||||||
|
child: Row(
|
||||||
|
spacing: 8,
|
||||||
|
children: [
|
||||||
|
usePostersForLibrary
|
||||||
|
? Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(vertical: 4),
|
||||||
|
child: ClipRRect(
|
||||||
|
borderRadius: FladderTheme.smallShape.borderRadius,
|
||||||
|
child: SizedBox.square(
|
||||||
|
dimension: 45,
|
||||||
|
child: FladderImage(
|
||||||
|
image: e.imageData?.primary,
|
||||||
|
placeHolder: Card(
|
||||||
|
child: Icon(
|
||||||
|
e.collectionType.iconOutlined,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
)
|
||||||
)
|
: Icon(e.collectionType.iconOutlined),
|
||||||
: Icon(e.collectionType.iconOutlined),
|
Text(e.name),
|
||||||
Text(e.name),
|
],
|
||||||
],
|
),
|
||||||
),
|
),
|
||||||
),
|
)
|
||||||
)
|
.toList(),
|
||||||
.toList(),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
|
@ -287,6 +302,7 @@ class _SideNavigationBarState extends ConsumerState<SideNavigationBar> {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
if (AdaptiveLayout.of(context).inputDevice == InputDevice.pointer) const SizedBox(height: 16),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
|
||||||
|
|
@ -29,15 +29,31 @@ class CustomTooltipState extends State<CustomTooltip> {
|
||||||
Timer? _timer;
|
Timer? _timer;
|
||||||
final GlobalKey _tooltipKey = GlobalKey();
|
final GlobalKey _tooltipKey = GlobalKey();
|
||||||
|
|
||||||
|
Timer? _timeOut;
|
||||||
|
|
||||||
|
void _resetTimer() {
|
||||||
|
_timeOut?.cancel();
|
||||||
|
_timeOut = Timer(const Duration(seconds: 2), () {
|
||||||
|
_hideTooltip();
|
||||||
|
_timeOut = null;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
void _showTooltip() {
|
void _showTooltip() {
|
||||||
_timer = Timer(widget.showDelay, () {
|
_timer = Timer(widget.showDelay, () {
|
||||||
_overlayEntry = _createOverlayEntry();
|
_overlayEntry = _createOverlayEntry();
|
||||||
Overlay.of(context).insert(_overlayEntry!);
|
Overlay.of(context).insert(_overlayEntry!);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
_timeOut = Timer(const Duration(seconds: 2), () {
|
||||||
|
_hideTooltip();
|
||||||
|
_timeOut = null;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void _hideTooltip() {
|
void _hideTooltip() {
|
||||||
_timer?.cancel();
|
_timer?.cancel();
|
||||||
|
_timeOut?.cancel();
|
||||||
_overlayEntry?.remove();
|
_overlayEntry?.remove();
|
||||||
_overlayEntry = null;
|
_overlayEntry = null;
|
||||||
}
|
}
|
||||||
|
|
@ -106,6 +122,7 @@ class CustomTooltipState extends State<CustomTooltip> {
|
||||||
return MouseRegion(
|
return MouseRegion(
|
||||||
onEnter: (_) => _showTooltip(),
|
onEnter: (_) => _showTooltip(),
|
||||||
onExit: (_) => _hideTooltip(),
|
onExit: (_) => _hideTooltip(),
|
||||||
|
onHover: (_) => _resetTimer(),
|
||||||
child: Stack(
|
child: Stack(
|
||||||
children: [
|
children: [
|
||||||
widget.child,
|
widget.child,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue