Fix Drafts button never turning into Post on Mac Catalyst

Closes #504
This commit is contained in:
Shadowfacts 2024-07-24 20:57:23 -07:00
parent f7d4737782
commit 61576bce58
1 changed files with 22 additions and 9 deletions

View File

@ -333,7 +333,12 @@ public final class ComposeController: ViewController {
} }
.toolbar { .toolbar {
ToolbarItem(placement: .cancellationAction) { cancelButton } ToolbarItem(placement: .cancellationAction) { cancelButton }
#if targetEnvironment(macCatalyst)
ToolbarItem(placement: .topBarTrailing) { draftsButton }
ToolbarItem(placement: .confirmationAction) { postButton } ToolbarItem(placement: .confirmationAction) { postButton }
#else
ToolbarItem(placement: .confirmationAction) { postOrDraftsButton }
#endif
#if os(visionOS) #if os(visionOS)
ToolbarItem(placement: .bottomOrnament) { ToolbarItem(placement: .bottomOrnament) {
ControllerView(controller: { controller.toolbarController }) ControllerView(controller: { controller.toolbarController })
@ -461,20 +466,28 @@ public final class ComposeController: ViewController {
} }
@ViewBuilder @ViewBuilder
private var postButton: some View { private var postOrDraftsButton: some View {
if draft.hasContent || draft.editedStatusID != nil || !controller.config.allowSwitchingDrafts { if draft.hasContent || draft.editedStatusID != nil || !controller.config.allowSwitchingDrafts {
Button(action: controller.postStatus) { postButton
Text(draft.editedStatusID == nil ? "Post" : "Edit")
}
.keyboardShortcut(.return, modifiers: .command)
.disabled(!controller.postButtonEnabled)
} else { } else {
Button(action: controller.showDrafts) { draftsButton
Text("Drafts")
}
} }
} }
private var draftsButton: some View {
Button(action: controller.showDrafts) {
Text("Drafts")
}
}
private var postButton: some View {
Button(action: controller.postStatus) {
Text(draft.editedStatusID == nil ? "Post" : "Edit")
}
.keyboardShortcut(.return, modifiers: .command)
.disabled(!controller.postButtonEnabled)
}
#if !os(visionOS) #if !os(visionOS)
@available(iOS, obsoleted: 16.0) @available(iOS, obsoleted: 16.0)
private var keyboardInset: CGFloat { private var keyboardInset: CGFloat {