From 61576bce581687341cdcdd3c7d3d3aedecbe939e Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Wed, 24 Jul 2024 20:57:23 -0700 Subject: [PATCH] Fix Drafts button never turning into Post on Mac Catalyst Closes #504 --- .../Controllers/ComposeController.swift | 31 +++++++++++++------ 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/Packages/ComposeUI/Sources/ComposeUI/Controllers/ComposeController.swift b/Packages/ComposeUI/Sources/ComposeUI/Controllers/ComposeController.swift index bb31f3c9..da478b5b 100644 --- a/Packages/ComposeUI/Sources/ComposeUI/Controllers/ComposeController.swift +++ b/Packages/ComposeUI/Sources/ComposeUI/Controllers/ComposeController.swift @@ -333,7 +333,12 @@ public final class ComposeController: ViewController { } .toolbar { ToolbarItem(placement: .cancellationAction) { cancelButton } + #if targetEnvironment(macCatalyst) + ToolbarItem(placement: .topBarTrailing) { draftsButton } ToolbarItem(placement: .confirmationAction) { postButton } + #else + ToolbarItem(placement: .confirmationAction) { postOrDraftsButton } + #endif #if os(visionOS) ToolbarItem(placement: .bottomOrnament) { ControllerView(controller: { controller.toolbarController }) @@ -461,20 +466,28 @@ public final class ComposeController: ViewController { } @ViewBuilder - private var postButton: some View { + private var postOrDraftsButton: some View { if draft.hasContent || draft.editedStatusID != nil || !controller.config.allowSwitchingDrafts { - Button(action: controller.postStatus) { - Text(draft.editedStatusID == nil ? "Post" : "Edit") - } - .keyboardShortcut(.return, modifiers: .command) - .disabled(!controller.postButtonEnabled) + postButton } else { - Button(action: controller.showDrafts) { - Text("Drafts") - } + draftsButton } } + 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) @available(iOS, obsoleted: 16.0) private var keyboardInset: CGFloat {