Add iCloud Drive path description for iCloud profile type
This commit is contained in:
@@ -21,39 +21,45 @@ public struct EditProfileView: View {
|
||||
|
||||
private var formContent: some View {
|
||||
FormView {
|
||||
FormItem(String(localized: "Name")) {
|
||||
TextField("Name", text: $profile.name, prompt: Text("Required"))
|
||||
.multilineTextAlignment(.trailing)
|
||||
}
|
||||
|
||||
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"))
|
||||
Section {
|
||||
FormItem(String(localized: "Name")) {
|
||||
TextField("Name", text: $profile.name, prompt: Text("Required"))
|
||||
.multilineTextAlignment(.trailing)
|
||||
}
|
||||
} 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
|
||||
Picker(selection: $profile.type) {
|
||||
Text("Local").tag(ProfileType.local)
|
||||
Text("iCloud").tag(ProfileType.icloud)
|
||||
Text("Remote").tag(ProfileType.remote)
|
||||
} label: {
|
||||
Text("Type")
|
||||
}
|
||||
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
|
||||
.disabled(true)
|
||||
if profile.type == .icloud {
|
||||
FormItem(String(localized: "Path")) {
|
||||
TextField("Path", text: $profile.path, prompt: Text("Required"))
|
||||
.multilineTextAlignment(.trailing)
|
||||
}
|
||||
} 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 {
|
||||
|
||||
@@ -52,67 +52,74 @@ public struct NewProfileView: View {
|
||||
|
||||
private var formContent: some View {
|
||||
FormView {
|
||||
FormItem(String(localized: "Name")) {
|
||||
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")
|
||||
Section {
|
||||
FormItem(String(localized: "Name")) {
|
||||
TextField("Name", text: $viewModel.profileName, prompt: Text("Required"))
|
||||
.multilineTextAlignment(.trailing)
|
||||
}
|
||||
#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
|
||||
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)
|
||||
.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 {
|
||||
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
|
||||
} footer: {
|
||||
if viewModel.profileType == .icloud {
|
||||
let fileName = viewModel.remotePath.isEmpty ? String(localized: "FileName") : viewModel.remotePath
|
||||
Text("File will be located at iCloud Drive/sing-box/\(fileName)")
|
||||
}
|
||||
}
|
||||
#if os(iOS) || os(tvOS)
|
||||
|
||||
Reference in New Issue
Block a user