Legt das Fundament für den Plex-Client an: - XcodeGen-Projekt nach dem Muster von Onyx (com.scarriffleservices, strict concurrency, Projektdatei nicht eingecheckt) - FlixyKit mit vier Modulen: PlexKit, FlixyDesign, FlixyPlayback, FlixyDownloads. macOS steht als Plattform mit drin, damit die Logik-Tests ohne Simulator laufen. - FlixyDesign: dunkle Farb-Tokens, Schriftskala, Poster- und Querformat-Kacheln, Aufmacher-Bild. Die Akzentfarbe fließt über die Umgebung und wird per WCAG-Rechnung lesbar gehalten. - PlexKit: Kopfzeilen-Identität, Transport-Protokoll, Fehlerarten und die Medienmodelle samt nachsichtigem Decoder. - FlixyPlayback: VideoPlayerEngine-Protokoll und PlaybackDecider — die eine Funktion, an der Phase 2 das Transcoding andockt. - Ausfahrbare Seitenleiste auf dem iPhone, Split-View auf dem iPad. - 45 Tests, alle grün. VLCKit 4.0.0-a24 ist vorab geprüft: baut über SPM unter Swift 6 mit strict concurrency. Die iOS-Slice ist mit 239 MB allerdings gewichtig, deshalb bekommt sie in Phase 1 ein eigenes Target. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
100 lines
3.4 KiB
Swift
100 lines
3.4 KiB
Swift
import SwiftUI
|
|
import FlixyDesign
|
|
|
|
/// Der Inhalt der Seitenleiste.
|
|
///
|
|
/// Kennt keine Navigation — sie meldet nur, was ausgewählt wurde. Dadurch
|
|
/// lässt sie sich auf dem iPhone in den Drawer und auf dem iPad in die
|
|
/// `NavigationSplitView` stecken, ohne etwas zu ändern.
|
|
struct SidebarView: View {
|
|
let libraries: [SidebarDestination]
|
|
@Binding var selection: SidebarDestination
|
|
/// Auf dem iPad trägt die Navigationsleiste den Namen bereits — dort wäre
|
|
/// eine eigene Überschrift die dritte Nennung auf demselben Bildschirm.
|
|
var showsHeader: Bool = true
|
|
let onSelect: () -> Void
|
|
|
|
var body: some View {
|
|
ScrollView {
|
|
VStack(alignment: .leading, spacing: FlixySpacing.section) {
|
|
if showsHeader { header }
|
|
|
|
section(title: nil, items: [.home])
|
|
|
|
if !libraries.isEmpty {
|
|
section(title: String(localized: "sidebar.libraries"), items: libraries)
|
|
}
|
|
|
|
section(
|
|
title: String(localized: "sidebar.more"),
|
|
items: [.liveTV, .downloads, .settings]
|
|
)
|
|
}
|
|
.padding(.horizontal, FlixySpacing.regular)
|
|
.padding(.vertical, FlixySpacing.section)
|
|
}
|
|
.scrollBounceBehavior(.basedOnSize)
|
|
.background(Color.flixySurface)
|
|
}
|
|
|
|
private var header: some View {
|
|
Text(Branding.appName)
|
|
.font(.flixyTitle)
|
|
.foregroundStyle(Color.flixyTextPrimary)
|
|
.padding(.horizontal, FlixySpacing.snug)
|
|
}
|
|
|
|
@ViewBuilder
|
|
private func section(title: String?, items: [SidebarDestination]) -> some View {
|
|
VStack(alignment: .leading, spacing: FlixySpacing.tight) {
|
|
if let title {
|
|
Text(title)
|
|
.font(.flixyCaption)
|
|
.foregroundStyle(Color.flixyTextMuted)
|
|
.textCase(.uppercase)
|
|
.padding(.horizontal, FlixySpacing.snug)
|
|
.padding(.bottom, FlixySpacing.tight)
|
|
}
|
|
ForEach(items, id: \.self) { item in
|
|
SidebarRow(destination: item, isSelected: item == selection) {
|
|
selection = item
|
|
onSelect()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
private struct SidebarRow: View {
|
|
let destination: SidebarDestination
|
|
let isSelected: Bool
|
|
let action: () -> Void
|
|
|
|
@Environment(\.flixyAccent) private var accent
|
|
|
|
var body: some View {
|
|
Button(action: action) {
|
|
Label {
|
|
Text(destination.sidebarLabel).font(.flixyBody)
|
|
} icon: {
|
|
Image(systemName: destination.symbol)
|
|
// Feste Breite, damit die Beschriftungen auf einer Linie
|
|
// stehen — SF-Symbole sind unterschiedlich breit.
|
|
.frame(width: 22)
|
|
}
|
|
.foregroundStyle(isSelected ? accent : Color.flixyTextSecondary)
|
|
.padding(.horizontal, FlixySpacing.snug)
|
|
.padding(.vertical, FlixySpacing.regular)
|
|
.frame(maxWidth: .infinity, alignment: .leading)
|
|
.background {
|
|
if isSelected {
|
|
RoundedRectangle(cornerRadius: FlixyRadius.control)
|
|
.fill(accent.opacity(0.14))
|
|
}
|
|
}
|
|
}
|
|
.buttonStyle(.plain)
|
|
.accessibilityAddTraits(isSelected ? [.isButton, .isSelected] : .isButton)
|
|
}
|
|
}
|