mirror of
https://github.com/yattee/yattee.git
synced 2026-06-05 06:14:18 +00:00
Make source add/edit forms feel native on macOS
Use grouped Form style with LabeledContent rows and move primary actions into the sheet toolbar for SMB, WebDAV, Local Folder, Remote Server and the Edit sheet. iOS and tvOS branches unchanged.
This commit is contained in:
@@ -34,6 +34,9 @@ struct AddLocalFolderView: View {
|
||||
// MARK: - Body
|
||||
|
||||
var body: some View {
|
||||
#if os(macOS)
|
||||
macOSBody
|
||||
#else
|
||||
Form {
|
||||
nameSection
|
||||
folderSection
|
||||
@@ -53,8 +56,64 @@ struct AddLocalFolderView: View {
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
#if os(macOS)
|
||||
private var macOSBody: some View {
|
||||
Form {
|
||||
Section {
|
||||
LabeledContent(String(localized: "sources.field.name")) {
|
||||
TextField("", text: $name)
|
||||
}
|
||||
} footer: {
|
||||
Text(String(localized: "sources.footer.displayName"))
|
||||
.font(.callout)
|
||||
.foregroundStyle(.secondary)
|
||||
}
|
||||
|
||||
Section {
|
||||
LabeledContent(String(localized: "sources.header.folder")) {
|
||||
HStack {
|
||||
if let url = selectedFolderURL {
|
||||
Text(url.path)
|
||||
.lineLimit(1)
|
||||
.truncationMode(.middle)
|
||||
.foregroundStyle(.secondary)
|
||||
.font(.system(.body, design: .monospaced))
|
||||
} else {
|
||||
Text(String(localized: "sources.selectFolder"))
|
||||
.foregroundStyle(.secondary)
|
||||
}
|
||||
Button(String(localized: "sources.selectFolder")) {
|
||||
selectFolderMacOS()
|
||||
}
|
||||
}
|
||||
}
|
||||
} footer: {
|
||||
Text(String(localized: "sources.footer.folder"))
|
||||
.font(.callout)
|
||||
.foregroundStyle(.secondary)
|
||||
}
|
||||
|
||||
if let result = testResult {
|
||||
SourceTestResultSection(result: result)
|
||||
}
|
||||
}
|
||||
.formStyle(.grouped)
|
||||
.navigationTitle(String(localized: "sources.addLocalFolder"))
|
||||
.toolbar {
|
||||
ToolbarItem(placement: .confirmationAction) {
|
||||
Button(String(localized: "sources.addSource")) {
|
||||
addSource()
|
||||
}
|
||||
.disabled(!canAdd)
|
||||
.keyboardShortcut(.defaultAction)
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// MARK: - Sections
|
||||
|
||||
private var nameSection: some View {
|
||||
|
||||
Reference in New Issue
Block a user