diff --git a/ApplicationLibrary/Views/Profile/EditProfileView.swift b/ApplicationLibrary/Views/Profile/EditProfileView.swift index db5b9ad..f68af35 100644 --- a/ApplicationLibrary/Views/Profile/EditProfileView.swift +++ b/ApplicationLibrary/Views/Profile/EditProfileView.swift @@ -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 { diff --git a/ApplicationLibrary/Views/Profile/NewProfileView.swift b/ApplicationLibrary/Views/Profile/NewProfileView.swift index f0210ee..5418b87 100644 --- a/ApplicationLibrary/Views/Profile/NewProfileView.swift +++ b/ApplicationLibrary/Views/Profile/NewProfileView.swift @@ -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) diff --git a/Localizable.xcstrings b/Localizable.xcstrings index 4247917..2742a72 100644 --- a/Localizable.xcstrings +++ b/Localizable.xcstrings @@ -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" : { "localizations" : { "zh-Hans" : {