mirror of
https://github.com/yattee/yattee.git
synced 2026-07-21 14:52:03 +00:00
Render Add Source buttons inline on macOS where toolbar items aren't shown
Pre-macOS 26 doesn't reliably surface a detail-pane NavigationStack's toolbar confirmation items in the window title bar, leaving the "Add Source" actions invisible. Gate the toolbar placement behind macOS 26+ and fall back to an inline form/header button on older macOS across the add-source views and the sources list.
This commit is contained in:
@@ -36,6 +36,21 @@ struct AddSMBView: View {
|
||||
!name.isEmpty && !server.isEmpty
|
||||
}
|
||||
|
||||
/// macOS surfaces toolbar confirmation items from a pushed-in-sheet view
|
||||
/// reliably only from macOS 26 onward. On older macOS we render the
|
||||
/// "Add Source" action button inline in the form instead.
|
||||
private var usesToolbarActionButton: Bool {
|
||||
#if os(macOS)
|
||||
if #available(macOS 26, *) {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
#else
|
||||
return false
|
||||
#endif
|
||||
}
|
||||
|
||||
// MARK: - Body
|
||||
|
||||
var body: some View {
|
||||
@@ -133,25 +148,31 @@ struct AddSMBView: View {
|
||||
if let result = testResult {
|
||||
SourceTestResultSection(result: result)
|
||||
}
|
||||
|
||||
if !usesToolbarActionButton {
|
||||
actionSection
|
||||
}
|
||||
}
|
||||
.formStyle(.grouped)
|
||||
.navigationTitle(String(localized: "sources.addSMB"))
|
||||
.toolbar {
|
||||
ToolbarItem(placement: .confirmationAction) {
|
||||
Button {
|
||||
addSource()
|
||||
} label: {
|
||||
if isTesting {
|
||||
HStack(spacing: 6) {
|
||||
ProgressView().controlSize(.small)
|
||||
Text(testProgress ?? String(localized: "sources.testing"))
|
||||
if usesToolbarActionButton {
|
||||
ToolbarItem(placement: .confirmationAction) {
|
||||
Button {
|
||||
addSource()
|
||||
} label: {
|
||||
if isTesting {
|
||||
HStack(spacing: 6) {
|
||||
ProgressView().controlSize(.small)
|
||||
Text(testProgress ?? String(localized: "sources.testing"))
|
||||
}
|
||||
} else {
|
||||
Text(String(localized: "sources.addSource"))
|
||||
}
|
||||
} else {
|
||||
Text(String(localized: "sources.addSource"))
|
||||
}
|
||||
.disabled(!canAdd || isTesting)
|
||||
.keyboardShortcut(.defaultAction)
|
||||
}
|
||||
.disabled(!canAdd || isTesting)
|
||||
.keyboardShortcut(.defaultAction)
|
||||
}
|
||||
}
|
||||
.onAppear {
|
||||
|
||||
Reference in New Issue
Block a user