vibetunnel/VibeTunnel/Presentation/Utilities/View+Cursor.swift
Peter Steinberger 70a8da5235 feat: enhance UI and automatic update handling
- Fix session count display to show on single line in menu bar
- Add conditional compilation to disable automatic updates in DEBUG mode
- Add "Open Dashboard" menu item that opens internal server URL
- Convert Help menu from popover to native macOS submenu style
- Enable automatic update downloads in Sparkle configuration
- Increase Advanced Settings tab height from 400 to 500 pixels
- Add Tailscale recommendation with clickable markdown link
- Fix Sendable protocol conformance issues throughout codebase
- Add ApplicationMover utility for app installation location management

These changes improve the overall user experience by making the UI more
intuitive and ensuring automatic updates work correctly in production
while being disabled during development.
2025-06-16 05:53:08 +02:00

63 lines
1.8 KiB
Swift

import SwiftUI
extension View {
func pressEvents(onPress: @escaping () -> Void, onRelease: @escaping () -> Void) -> some View {
modifier(PressEventModifier(onPress: onPress, onRelease: onRelease))
}
func pointingHandCursor() -> some View {
modifier(PointingHandCursorModifier())
}
}
/// View modifier for handling press events on buttons.
struct PressEventModifier: ViewModifier {
let onPress: () -> Void
let onRelease: () -> Void
func body(content: Content) -> some View {
content
.simultaneousGesture(
DragGesture(minimumDistance: 0)
.onChanged { _ in onPress() }
.onEnded { _ in onRelease() }
)
}
}
/// View modifier for showing pointing hand cursor on hover.
struct PointingHandCursorModifier: ViewModifier {
func body(content: Content) -> some View {
content
.background(
CursorTrackingView()
.allowsHitTesting(false)
)
}
}
/// NSViewRepresentable that handles cursor changes properly
struct CursorTrackingView: NSViewRepresentable {
func makeNSView(context _: Context) -> CursorTrackingNSView {
CursorTrackingNSView()
}
func updateNSView(_: CursorTrackingNSView, context _: Context) {
// No updates needed
}
}
/// Custom NSView that properly handles cursor tracking
///
/// This view ensures the pointing hand cursor is displayed when hovering over interactive elements
class CursorTrackingNSView: NSView {
override func resetCursorRects() {
super.resetCursorRects()
addCursorRect(bounds, cursor: .pointingHand)
}
override func viewDidMoveToWindow() {
super.viewDidMoveToWindow()
window?.invalidateCursorRects(for: self)
}
}