Add iCloud Drive path description for iCloud profile type

This commit is contained in:
世界
2026-02-15 17:47:40 +08:00
parent 9411f39173
commit 4a91a0c588
3 changed files with 154 additions and 85 deletions
@@ -21,39 +21,45 @@ public struct EditProfileView: View {
private var formContent: some View { private var formContent: some View {
FormView { FormView {
FormItem(String(localized: "Name")) { Section {
TextField("Name", text: $profile.name, prompt: Text("Required")) FormItem(String(localized: "Name")) {
.multilineTextAlignment(.trailing) TextField("Name", text: $profile.name, prompt: Text("Required"))
}
Picker(selection: $profile.type) {
Text("Local").tag(ProfileType.local)
Text("iCloud").tag(ProfileType.icloud)
Text("Remote").tag(ProfileType.remote)
} label: {
Text("Type")
}
.disabled(true)
if profile.type == .icloud {
FormItem(String(localized: "Path")) {
TextField("Path", text: $profile.path, prompt: Text("Required"))
.multilineTextAlignment(.trailing) .multilineTextAlignment(.trailing)
} }
} else if profile.type == .remote { Picker(selection: $profile.type) {
FormItem(String(localized: "URL")) { Text("Local").tag(ProfileType.local)
TextField("URL", text: $profile.remoteURL.unwrapped(""), prompt: Text("Required")) Text("iCloud").tag(ProfileType.icloud)
.multilineTextAlignment(.trailing) Text("Remote").tag(ProfileType.remote)
#if !os(macOS) } label: {
.keyboardType(.URL) Text("Type")
#endif
} }
Toggle("Auto Update", isOn: $profile.autoUpdate) .disabled(true)
FormItem(String(localized: "Auto Update Interval")) { if profile.type == .icloud {
TextField("Auto Update Interval", text: $profile.autoUpdateInterval.stringBinding(defaultValue: 60), prompt: Text("In Minutes")) FormItem(String(localized: "Path")) {
.multilineTextAlignment(.trailing) TextField("Path", text: $profile.path, prompt: Text("Required"))
#if !os(macOS) .multilineTextAlignment(.trailing)
.keyboardType(.numberPad) }
#endif } else if profile.type == .remote {
FormItem(String(localized: "URL")) {
TextField("URL", text: $profile.remoteURL.unwrapped(""), prompt: Text("Required"))
.multilineTextAlignment(.trailing)
#if !os(macOS)
.keyboardType(.URL)
#endif
}
Toggle("Auto Update", isOn: $profile.autoUpdate)
FormItem(String(localized: "Auto Update Interval")) {
TextField("Auto Update Interval", text: $profile.autoUpdateInterval.stringBinding(defaultValue: 60), prompt: Text("In Minutes"))
.multilineTextAlignment(.trailing)
#if !os(macOS)
.keyboardType(.numberPad)
#endif
}
}
} footer: {
if profile.type == .icloud {
let fileName = profile.path.isEmpty ? String(localized: "FileName") : profile.path
Text("File will be located at iCloud Drive/sing-box/\(fileName)")
} }
} }
if profile.type == .remote { if profile.type == .remote {
@@ -52,67 +52,74 @@ public struct NewProfileView: View {
private var formContent: some View { private var formContent: some View {
FormView { FormView {
FormItem(String(localized: "Name")) { Section {
TextField("Name", text: $viewModel.profileName, prompt: Text("Required")) FormItem(String(localized: "Name")) {
.multilineTextAlignment(.trailing) TextField("Name", text: $viewModel.profileName, prompt: Text("Required"))
} .multilineTextAlignment(.trailing)
Picker(selection: $viewModel.profileType) {
Text("Local").tag(ProfileType.local)
#if !os(tvOS)
Text("iCloud").tag(ProfileType.icloud)
#endif
Text("Remote").tag(ProfileType.remote)
} label: {
Text("Type")
}
if viewModel.profileType == .local {
Picker(selection: $viewModel.fileImport) {
Text("Create New").tag(false)
Text("Import").tag(true)
} label: {
Text("File")
} }
#if os(tvOS) Picker(selection: $viewModel.profileType) {
.disabled(true) Text("Local").tag(ProfileType.local)
#endif #if !os(tvOS)
Group { Text("iCloud").tag(ProfileType.icloud)
if viewModel.fileImport { #endif
HStack { Text("Remote").tag(ProfileType.remote)
Text("File Path") } label: {
Spacer() Text("Type")
Spacer() }
if let fileURL = viewModel.fileURL { if viewModel.profileType == .local {
Button(fileURL.fileName) { Picker(selection: $viewModel.fileImport) {
viewModel.pickerPresented = true Text("Create New").tag(false)
} Text("Import").tag(true)
} else { } label: {
Button("Choose") { Text("File")
viewModel.pickerPresented = true }
#if os(tvOS)
.disabled(true)
#endif
Group {
if viewModel.fileImport {
HStack {
Text("File Path")
Spacer()
Spacer()
if let fileURL = viewModel.fileURL {
Button(fileURL.fileName) {
viewModel.pickerPresented = true
}
} else {
Button("Choose") {
viewModel.pickerPresented = true
}
} }
} }
} }
} }
} else if viewModel.profileType == .icloud {
FormItem(String(localized: "Path")) {
TextField("Path", text: $viewModel.remotePath, prompt: Text("Required"))
.multilineTextAlignment(.trailing)
}
} else if viewModel.profileType == .remote {
FormItem(String(localized: "URL")) {
TextField("URL", text: $viewModel.remotePath, prompt: Text("Required"))
.multilineTextAlignment(.trailing)
#if !os(macOS)
.keyboardType(.URL)
#endif
}
Toggle("Auto Update", isOn: $viewModel.autoUpdate)
FormItem(String(localized: "Auto Update Interval")) {
TextField("Auto Update Interval", text: $viewModel.autoUpdateInterval.stringBinding(defaultValue: 60), prompt: Text("In Minutes"))
.multilineTextAlignment(.trailing)
#if !os(macOS)
.keyboardType(.numberPad)
#endif
}
} }
} else if viewModel.profileType == .icloud { } footer: {
FormItem(String(localized: "Path")) { if viewModel.profileType == .icloud {
TextField("Path", text: $viewModel.remotePath, prompt: Text("Required")) let fileName = viewModel.remotePath.isEmpty ? String(localized: "FileName") : viewModel.remotePath
.multilineTextAlignment(.trailing) Text("File will be located at iCloud Drive/sing-box/\(fileName)")
}
} else if viewModel.profileType == .remote {
FormItem(String(localized: "URL")) {
TextField("URL", text: $viewModel.remotePath, prompt: Text("Required"))
.multilineTextAlignment(.trailing)
#if !os(macOS)
.keyboardType(.URL)
#endif
}
Toggle("Auto Update", isOn: $viewModel.autoUpdate)
FormItem(String(localized: "Auto Update Interval")) {
TextField("Auto Update Interval", text: $viewModel.autoUpdateInterval.stringBinding(defaultValue: 60), prompt: Text("In Minutes"))
.multilineTextAlignment(.trailing)
#if !os(macOS)
.keyboardType(.numberPad)
#endif
} }
} }
#if os(iOS) || os(tvOS) #if os(iOS) || os(tvOS)
+56
View File
@@ -3481,6 +3481,62 @@
} }
} }
}, },
"File will be located at iCloud Drive/sing-box/%@" : {
"localizations" : {
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "此文件将位于 iCloud 云盘/sing-box/%@"
}
},
"zh-Hant" : {
"stringUnit" : {
"state" : "translated",
"value" : "此檔案將位於 iCloud 雲碟/sing-box/%@"
}
},
"ru" : {
"stringUnit" : {
"state" : "translated",
"value" : "Файл будет расположен в iCloud Drive/sing-box/%@"
}
},
"fa" : {
"stringUnit" : {
"state" : "translated",
"value" : "فایل در iCloud Drive/sing-box/%@ قرار خواهد گرفت"
}
}
}
},
"FileName" : {
"localizations" : {
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "文件名"
}
},
"zh-Hant" : {
"stringUnit" : {
"state" : "translated",
"value" : "檔案名稱"
}
},
"ru" : {
"stringUnit" : {
"state" : "translated",
"value" : "ИмяФайла"
}
},
"fa" : {
"stringUnit" : {
"state" : "translated",
"value" : "نام فایل"
}
}
}
},
"Filter" : { "Filter" : {
"localizations" : { "localizations" : {
"zh-Hans" : { "zh-Hans" : {