tv-anarchy/Sources/TVAnarchy/MiniTransport.swift
Natalie b44b5a2d1a feat(@applications): add adult content browsing tab
Co-Authored-By: Lilith Autocommit <noreply@atlilith.com>
2026-06-09 19:51:12 -07:00

35 lines
1.5 KiB
Swift
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import SwiftUI
import TVAnarchyCore
/// Compact transport for a view's header toolbar: previous · 10s · play/pause ·
/// +10s · next, driving the active host. Lets you control playback without
/// leaving the current tab for the Player tab. Disabled when nothing is playing
/// (no title) or the host is unreachable, so the controls never fire into a void.
struct MiniTransport: View {
@Bindable var controller: PlayerController
private var snap: PlayerController.Snapshot { controller.activeSnapshot }
private var status: PlaybackStatus { snap.status }
/// Same "nothing playing" signal the Player tab uses for its title line.
private var idle: Bool { status.title == nil }
var body: some View {
HStack(spacing: 10) {
button("backward.end.fill") { await $0.previous() }
button("gobackward.10") { await $0.seek(relative: -10) }
button(status.paused == true ? "play.fill" : "pause.fill", big: true) { await $0.playPause() }
button("goforward.10") { await $0.seek(relative: 10) }
button("forward.end.fill") { await $0.next() }
}
.disabled(idle || snap.state == .unreachable)
.help(idle ? "Nothing playing" : (status.title ?? ""))
}
private func button(_ system: String, big: Bool = false,
_ op: @escaping (any PlayerTarget) async -> Void) -> some View {
Button { controller.command(op) } label: {
Image(systemName: system).font(big ? .title3 : .body)
}
.buttonStyle(.borderless)
}
}