Files
yattee/Yattee/Views/Settings/AddSource/AddSourceShared.swift
Arkadiusz Fal 88fafc5ada Remove Test Connection from source editing
The Test Connection buttons only probed API/server reachability, which
was misleading: a green result said nothing about whether videos would
actually play. Remove both the remote-server and WebDAV bandwidth test
buttons and all code exclusive to them (testBandwidth, BandwidthTestResult,
and orphaned localization keys). Add-time connectivity validation for
SMB/WebDAV sources is retained.
2026-05-19 20:40:28 +02:00

73 lines
1.8 KiB
Swift

//
// AddSourceShared.swift
// Yattee
//
// Shared components for the Add Source views.
//
import SwiftUI
// MARK: - Test Result
/// Result of a connection test for WebDAV/SMB sources.
enum SourceTestResult {
case failure(String)
}
// MARK: - Test Result Section
/// Displays the result of a connection test.
struct SourceTestResultSection: View {
let result: SourceTestResult
var body: some View {
Section {
switch result {
case .failure(let error):
Label(error, systemImage: "xmark.circle.fill")
.foregroundStyle(.red)
}
}
}
}
// MARK: - Folder Picker (iOS)
#if os(iOS)
import UniformTypeIdentifiers
struct FolderPickerView: UIViewControllerRepresentable {
let onSelect: (URL) -> Void
func makeUIViewController(context: Context) -> UIDocumentPickerViewController {
let picker = UIDocumentPickerViewController(forOpeningContentTypes: [.folder])
picker.delegate = context.coordinator
picker.allowsMultipleSelection = false
return picker
}
func updateUIViewController(_ uiViewController: UIDocumentPickerViewController, context: Context) {}
func makeCoordinator() -> Coordinator {
Coordinator(onSelect: onSelect)
}
class Coordinator: NSObject, UIDocumentPickerDelegate {
let onSelect: (URL) -> Void
init(onSelect: @escaping (URL) -> Void) {
self.onSelect = onSelect
}
func documentPicker(_ controller: UIDocumentPickerViewController, didPickDocumentsAt urls: [URL]) {
guard let url = urls.first else { return }
guard url.startAccessingSecurityScopedResource() else { return }
defer { url.stopAccessingSecurityScopedResource() }
onSelect(url)
}
}
}
#endif