From b50670471681e2ce976492cb7ac81e1a0d9387b4 Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Thu, 26 Jan 2023 22:17:49 -0500 Subject: [PATCH] Move Drafts button to nav bar when current composed post doesn't have any content --- Tusker/Screens/Compose/ComposeToolbar.swift | 10 --------- Tusker/Screens/Compose/ComposeView.swift | 23 ++++++++++++++------- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/Tusker/Screens/Compose/ComposeToolbar.swift b/Tusker/Screens/Compose/ComposeToolbar.swift index 4c19e37e..646c12d3 100644 --- a/Tusker/Screens/Compose/ComposeToolbar.swift +++ b/Tusker/Screens/Compose/ComposeToolbar.swift @@ -78,12 +78,6 @@ struct ComposeToolbar: View { } Spacer() - - Button(action: self.draftsButtonPressed) { - Text("Drafts") - } - .padding(5) - .hoverEffect() } .padding(.horizontal, 16) .frame(minWidth: minWidth) @@ -119,10 +113,6 @@ struct ComposeToolbar: View { uiState.currentInput?.beginAutocompletingEmoji() } - private func draftsButtonPressed() { - uiState.isShowingDraftsList = true - } - private func formatAction(_ format: StatusFormat) -> () -> Void { { uiState.currentInput?.applyFormat(format) diff --git a/Tusker/Screens/Compose/ComposeView.swift b/Tusker/Screens/Compose/ComposeView.swift index db54926c..eeecbe53 100644 --- a/Tusker/Screens/Compose/ComposeView.swift +++ b/Tusker/Screens/Compose/ComposeView.swift @@ -239,16 +239,25 @@ struct ComposeView: View { } } + @ViewBuilder private var postButton: some View { - Button { - Task { - await self.postStatus() + if draft.hasContent { + Button { + Task { + await self.postStatus() + } + } label: { + Text("Post") + } + .keyboardShortcut(.return, modifiers: .command) + .disabled(!postButtonEnabled) + } else { + Button { + uiState.isShowingDraftsList = true + } label: { + Text("Drafts") } - } label: { - Text("Post") } - .keyboardShortcut(.return, modifiers: .command) - .disabled(!postButtonEnabled) } private func cancel() {