From a32582e171af2f6ef8893b3bc65462cf639de088 Mon Sep 17 00:00:00 2001 From: Arkadiusz Fal Date: Thu, 23 Apr 2026 18:06:47 +0200 Subject: [PATCH] Replace macOS video nav arrows with left/right keyboard shortcuts --- Yattee/Views/Video/VideoInfoView.swift | 66 ++++++++++---------------- 1 file changed, 24 insertions(+), 42 deletions(-) diff --git a/Yattee/Views/Video/VideoInfoView.swift b/Yattee/Views/Video/VideoInfoView.swift index 1e63a837..fc7d2976 100644 --- a/Yattee/Views/Video/VideoInfoView.swift +++ b/Yattee/Views/Video/VideoInfoView.swift @@ -543,17 +543,37 @@ struct VideoInfoView: View { .scrollDismissesKeyboard(.interactively) #endif .modifier(VideoInfoScrollOffsetModifier(scrollOffset: $scrollOffset)) - // Navigation buttons overlay - floats above scrolling content in ZStack (macOS only) + #if os(macOS) - if videoQueueContext != nil { - navigationButtonsOverlay - } + videoNavigationKeyboardShortcuts #endif } } } #endif + #if os(macOS) + // Bare left/right arrow keys switch to previous/next video in the queue. + // Command-modified arrows are reserved for player seek shortcuts (see PlaybackCommands), + // so these don't collide. Disabled buttons don't fire their shortcuts, which also + // prevents activation when no queue context exists. + @ViewBuilder + private var videoNavigationKeyboardShortcuts: some View { + Group { + Button(action: navigateToPrevious) { EmptyView() } + .keyboardShortcut(.leftArrow, modifiers: []) + .disabled(!canNavigatePrevious) + + Button(action: navigateToNext) { EmptyView() } + .keyboardShortcut(.rightArrow, modifiers: []) + .disabled(!canNavigateNext) + } + .frame(width: 0, height: 0) + .opacity(0) + .accessibilityHidden(true) + } + #endif + #if os(tvOS) // MARK: - tvOS Two-Column Layout @@ -2432,44 +2452,6 @@ struct VideoInfoView: View { #endif loadComments() } - - #if os(macOS) - /// Navigation buttons overlay - floats at bottom of screen (macOS only) - @ViewBuilder - private var navigationButtonsOverlay: some View { - VStack { - Spacer() - - HStack { - // Previous button - if canNavigatePrevious { - VideoNavigationButton(direction: .previous) { - navigateToPrevious() - } - .transition(.opacity.combined(with: .scale)) - } - - Spacer(minLength: 0) - - // Next button - if canNavigateNext { - VideoNavigationButton( - direction: .next, - action: navigateToNext, - isLoading: isLoadingMoreVideos, - hasError: loadMoreError != nil - ) - .transition(.opacity.combined(with: .scale)) - } - } - .padding(.horizontal, 16) - .padding(.bottom, 16) - .contentShape(Rectangle()) - } - .animation(.easeInOut(duration: 0.2), value: canNavigatePrevious) - .animation(.easeInOut(duration: 0.2), value: canNavigateNext) - } - #endif #endif }