fix(iOS): Connect+Browse buttons — Connect opens Files for auth, Browse opens file picker. Add auto-opens Files.
This commit is contained in:
parent
6c7a6e567f
commit
01bf7d6f4a
@ -132,7 +132,7 @@ private func buildFileItems(_ contents: [URL], assNames: Set<String>) -> [Networ
|
||||
.compactMap{ url->NetworkFileItem? in var d:ObjCBool=false; FileManager.default.fileExists(atPath:url.path,isDirectory:&d); let base=url.deletingPathExtension().lastPathComponent.lowercased(); return NetworkFileItem(url:url,name:url.lastPathComponent,isDirectory:d.boolValue,fileSize:d.boolValue ? nil : (try? url.resourceValues(forKeys:[.fileSizeKey]))?.fileSize.map(Int64.init),hasMatchingASS:assNames.contains(base)) }
|
||||
}
|
||||
|
||||
// MARK: - iOS:服务器列表 + 系统文件选择器
|
||||
// MARK: - iOS:服务器列表 → Files 认证 → 文件选择器播放
|
||||
#if os(iOS)
|
||||
import UniformTypeIdentifiers
|
||||
|
||||
@ -150,13 +150,16 @@ struct NetworkFileBrowserIOS: View {
|
||||
Section("Saved Servers") {
|
||||
if savedServers.isEmpty { Text("No saved servers").foregroundColor(.secondary) }
|
||||
ForEach(savedServers, id: \.self) { url in
|
||||
Button(action: { showFilePicker = true }) {
|
||||
HStack {
|
||||
Image(systemName: "server.rack").foregroundColor(.accentColor)
|
||||
Text(url).foregroundColor(.primary).lineLimit(1)
|
||||
Spacer()
|
||||
Image(systemName: "chevron.right").font(.caption).foregroundColor(.secondary)
|
||||
}
|
||||
HStack {
|
||||
Image(systemName: "server.rack").foregroundColor(.accentColor)
|
||||
Text(url).foregroundColor(.primary).lineLimit(1).font(.system(size: 13))
|
||||
Spacer()
|
||||
Button("Connect") {
|
||||
guard let u = URL(string: url) else { return }
|
||||
UIApplication.shared.open(u)
|
||||
}.buttonStyle(.bordered).controlSize(.small)
|
||||
Button("Browse") { showFilePicker = true }
|
||||
.buttonStyle(.borderedProminent).controlSize(.small)
|
||||
}
|
||||
}
|
||||
.onDelete { savedServers.remove(atOffsets: $0); UserDefaults.standard.set(savedServers, forKey: "MiniPlayer.smbServers") }
|
||||
@ -169,11 +172,16 @@ struct NetworkFileBrowserIOS: View {
|
||||
let t = smbURL.trimmingCharacters(in: .whitespaces)
|
||||
guard !t.isEmpty else { return }
|
||||
if !savedServers.contains(t) { savedServers.insert(t, at: 0); UserDefaults.standard.set(savedServers, forKey: "MiniPlayer.smbServers") }
|
||||
// 同时打开 Files 认证
|
||||
if let u = URL(string: t) { UIApplication.shared.open(u) }
|
||||
smbURL = ""
|
||||
showFilePicker = true
|
||||
}.disabled(smbURL.trimmingCharacters(in: .whitespaces).isEmpty)
|
||||
}
|
||||
}
|
||||
Section {
|
||||
Text("First time: Add server → login in Files → back to MiniPlayer → Browse. After that, just Browse.")
|
||||
.font(.caption).foregroundColor(.secondary)
|
||||
}
|
||||
Section("Stream URL") {
|
||||
HStack {
|
||||
TextField("https://...", text: $streamURL).keyboardType(.URL).autocapitalization(.none).disableAutocorrection(true)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user