Commit 91ef1795 authored by Kourser's avatar Kourser
Browse files

feat(macos): playback controls on the Touch Bar

While an episode is loaded, the Touch Bar app region shows skip-back,
play/pause and skip-forward buttons (using the configured skip
intervals) plus the current episode title; idle, the system default bar
stays. Implemented with SwiftUI's .touchBar on the root view — NSTouchBar
remains a supported API even though new Macs no longer ship the hardware.

Co-Authored-By: Claude (RCA)
parent dac55bdb
Loading
Loading
Loading
Loading
+35 −0
Original line number Diff line number Diff line
#if os(macOS)
import SwiftUI
import PlaybackKit

/// Transport controls shown on the MacBook Touch Bar while an episode is
/// loaded: skip back, play/pause, skip forward, plus the current title.
/// Attached to the root view; empty (system default bar) when idle.
struct PlaybackTouchBar: View {
    @Environment(PlaybackController.self) private var playback
    @Environment(PlaybackSettings.self) private var settings

    var body: some View {
        if let episode = playback.currentEpisode {
            Button {
                playback.skipBackward(TimeInterval(settings.skipBackward))
            } label: {
                Image(systemName: settings.backwardSymbol)
            }
            Button {
                playback.togglePlayPause()
            } label: {
                Image(systemName: playback.isPlaying ? "pause.fill" : "play.fill")
            }
            Button {
                playback.skipForward(TimeInterval(settings.skipForward))
            } label: {
                Image(systemName: settings.forwardSymbol)
            }
            Text(episode.title)
                .lineLimit(1)
                .frame(maxWidth: 280)
        }
    }
}
#endif
+5 −0
Original line number Diff line number Diff line
@@ -96,6 +96,11 @@ struct RootView: View {
            handleDroppedURLs(urls)
            return true
        }
        #if os(macOS)
        .touchBar {
            PlaybackTouchBar()
        }
        #endif
        .sheet(isPresented: $commands.showAddPodcast) { AddPodcastView() }
        .sheet(isPresented: $commands.showAddRadio) { AddRadioView() }
        .sheet(isPresented: $showingSearch) { SearchView() }