import SwiftUI import FlixyDesign import PlexKit /// Während ein Weg zum Server gesucht wird. struct ConnectingView: View { let serverName: String var body: some View { VStack(spacing: FlixySpacing.loose) { ProgressView() Text(serverName.isEmpty ? String(localized: "connecting.searching") : String(localized: "connecting.to \(serverName)")) .font(.flixyBody) .foregroundStyle(Color.flixyTextSecondary) } .frame(maxWidth: .infinity, maxHeight: .infinity) .background(Color.flixyCanvas) } } /// Wenn am Konto mehrere Server hängen. struct ServerPickerView: View { let servers: [PlexResource] let onSelect: (PlexResource) -> Void @Environment(\.flixyAccent) private var accent var body: some View { List(servers) { server in Button { onSelect(server) } label: { HStack(spacing: FlixySpacing.regular) { Image(systemName: server.owned ? "server.rack" : "person.2") .foregroundStyle(accent) .frame(width: 28) VStack(alignment: .leading, spacing: 2) { Text(server.name) .font(.flixyCardTitle) .foregroundStyle(Color.flixyTextPrimary) Text(subtitle(for: server)) .font(.flixyCaption) .foregroundStyle(Color.flixyTextMuted) } Spacer() Image(systemName: "chevron.right") .font(.flixyCaption) .foregroundStyle(Color.flixyTextMuted) } .contentShape(.rect) } .buttonStyle(.plain) .listRowBackground(Color.flixySurface) } .scrollContentBackground(.hidden) .background(Color.flixyCanvas) .navigationTitle(Text("serverPicker.title")) } private func subtitle(for server: PlexResource) -> String { var pieces: [String] = [] pieces.append(server.owned ? String(localized: "serverPicker.owned") : String(localized: "serverPicker.shared")) if let platform = server.platform { pieces.append(platform) } if let version = server.productVersion { pieces.append(version) } return pieces.joined(separator: " · ") } } /// Wenn etwas schiefgegangen ist. struct ConnectionFailureView: View { let message: String let onRetry: () -> Void let onSignOut: () -> Void var body: some View { ContentUnavailableView { Label("error.title", systemImage: "exclamationmark.triangle") } description: { Text(message) } actions: { Button("action.retry", action: onRetry).buttonStyle(.borderedProminent) Button("action.signOut", action: onSignOut) .foregroundStyle(Color.flixyTextSecondary) } .background(Color.flixyCanvas) } }