aboutsummaryrefslogtreecommitdiff
path: root/Hotline/macOS/MessageBoardView.swift
diff options
context:
space:
mode:
Diffstat (limited to 'Hotline/macOS/MessageBoardView.swift')
-rw-r--r--Hotline/macOS/MessageBoardView.swift32
1 files changed, 31 insertions, 1 deletions
diff --git a/Hotline/macOS/MessageBoardView.swift b/Hotline/macOS/MessageBoardView.swift
index 65a947f..e7fdeb5 100644
--- a/Hotline/macOS/MessageBoardView.swift
+++ b/Hotline/macOS/MessageBoardView.swift
@@ -4,6 +4,8 @@ struct MessageBoardView: View {
@Environment(Hotline.self) private var model: Hotline
@State private var initialLoadComplete = false
+ @State private var composerDisplayed = false
+ @State private var composerText = ""
var body: some View {
NavigationStack {
@@ -12,6 +14,7 @@ struct MessageBoardView: View {
ForEach(model.messageBoard, id: \.self) {
Text($0)
.lineLimit(100)
+ .lineSpacing(4)
.padding()
.textSelection(.enabled)
Divider()
@@ -35,10 +38,37 @@ struct MessageBoardView: View {
}
.background(Color(nsColor: .textBackgroundColor))
}
+ .sheet(isPresented: $composerDisplayed) {
+ TextEditor(text: $composerText)
+ .padding()
+ .font(.system(size: 13))
+ .lineSpacing(4)
+ .background(Color(nsColor: .textBackgroundColor))
+ .frame(idealWidth: 450, idealHeight: 350)
+ .toolbar {
+ ToolbarItem(placement: .cancellationAction) {
+ Button("Cancel") {
+ composerDisplayed.toggle()
+ }
+ }
+
+ ToolbarItem(placement: .primaryAction) {
+ Button("Post") {
+ composerDisplayed.toggle()
+ let text = composerText
+ composerText = ""
+ model.postToMessageBoard(text: text)
+ Task {
+ await model.getMessageBoard()
+ }
+ }
+ }
+ }
+ }
.toolbar {
ToolbarItem(placement:.primaryAction) {
Button {
-
+ composerDisplayed.toggle()
} label: {
Image(systemName: "square.and.pencil")
}