import SwiftUI import FlixyDesign import PlexKit /// Die Einstellungen. /// /// In Phase 1 bewusst schmal: Serverangaben und Abmelden. Akzentfarbe, /// Qualitätsregler und Download-Einstellungen kommen mit den Phasen, in denen /// es das Geregelte auch gibt. struct SettingsView: View { @Environment(FlixySession.self) private var session @State private var showsSignOutConfirmation = false var body: some View { Form { if let server = session.server { Section("settings.server") { LabeledContent("settings.serverName", value: server.name) LabeledContent("settings.connection", value: connectionLabel(server.connection)) LabeledContent("settings.address", value: server.connection.uri) .font(.flixyCaption) .textSelection(.enabled) } Section("settings.libraries") { ForEach(session.libraries) { library in LabeledContent(library.title, value: library.type.capitalized) } } } Section("settings.app") { LabeledContent("settings.version", value: Branding.version) } Section { Button("action.signOut", role: .destructive) { showsSignOutConfirmation = true } } } .scrollContentBackground(.hidden) .background(Color.flixyCanvas) .navigationTitle(Text("sidebar.settings")) .navigationBarTitleDisplayMode(.inline) .confirmationDialog( Text("settings.signOutConfirm"), isPresented: $showsSignOutConfirmation, titleVisibility: .visible ) { Button("action.signOut", role: .destructive) { session.signOut() } Button("action.cancel", role: .cancel) {} } message: { Text("settings.signOutExplanation") } } /// Zeigt, über welchen Weg die Verbindung läuft — beim Suchen nach /// Ruckeln ist das die erste Frage. private func connectionLabel(_ connection: PlexConnection) -> String { if connection.local { return String(localized: "settings.connectionLocal") } if connection.relay { return String(localized: "settings.connectionRelay") } return String(localized: "settings.connectionRemote") } }