From cd78cab073cdbb52daa1ee861dc896f561c2878f Mon Sep 17 00:00:00 2001 From: Pascal Batty Date: Tue, 10 Jan 2023 14:44:11 +0100 Subject: [PATCH] Disable post button when there's no content (#57) Co-authored-by: Pascal Batty --- Packages/Status/Sources/Status/Editor/StatusEditorView.swift | 1 + .../Status/Sources/Status/Editor/StatusEditorViewModel.swift | 3 +++ 2 files changed, 4 insertions(+) diff --git a/Packages/Status/Sources/Status/Editor/StatusEditorView.swift b/Packages/Status/Sources/Status/Editor/StatusEditorView.swift index e012585b..3fc6fd78 100644 --- a/Packages/Status/Sources/Status/Editor/StatusEditorView.swift +++ b/Packages/Status/Sources/Status/Editor/StatusEditorView.swift @@ -84,6 +84,7 @@ public struct StatusEditorView: View { Text("Post") } } + .disabled(!viewModel.canPost) } ToolbarItem(placement: .navigationBarLeading) { Button { diff --git a/Packages/Status/Sources/Status/Editor/StatusEditorViewModel.swift b/Packages/Status/Sources/Status/Editor/StatusEditorViewModel.swift index 39349507..74f0baea 100644 --- a/Packages/Status/Sources/Status/Editor/StatusEditorViewModel.swift +++ b/Packages/Status/Sources/Status/Editor/StatusEditorViewModel.swift @@ -44,6 +44,9 @@ public class StatusEditorViewModel: ObservableObject { @Published var mediasImages: [ImageContainer] = [] @Published var replyToStatus: Status? @Published var embededStatus: Status? + var canPost: Bool { + statusText.length > 0 || !selectedMedias.isEmpty + } @Published var visibility: Models.Visibility = .pub