diff options
| author | Dustin Mierau <dustin@mierau.me> | 2023-12-22 17:37:13 -0800 |
|---|---|---|
| committer | Dustin Mierau <dustin@mierau.me> | 2023-12-22 17:37:13 -0800 |
| commit | 4ddc0699afedae39fa27e134bec05330426f2120 (patch) | |
| tree | ce0936e7c537ef527c6472b746b8ef16e471c912 /Hotline/macOS/ChatView.swift | |
| parent | 3d26737cccd57fcbb5289874363f030ecef77573 (diff) | |
Some work to get banner images working. Some plumbing to get file transfers working though they don't yet. Moving some code away from async/await.
Diffstat (limited to 'Hotline/macOS/ChatView.swift')
| -rw-r--r-- | Hotline/macOS/ChatView.swift | 104 |
1 files changed, 47 insertions, 57 deletions
diff --git a/Hotline/macOS/ChatView.swift b/Hotline/macOS/ChatView.swift index 294f13b..f16ac8b 100644 --- a/Hotline/macOS/ChatView.swift +++ b/Hotline/macOS/ChatView.swift @@ -7,6 +7,7 @@ enum FocusedField: Int, Hashable { struct ChatView: View { @Environment(Hotline.self) private var model: Hotline @Environment(\.colorScheme) var colorScheme + @Environment(\.dismiss) var dismiss @State var input: String = "" @State private var scrollPos: Int? @@ -26,26 +27,56 @@ struct ChatView: View { GeometryReader { gm in ScrollView(.vertical) { LazyVStack(alignment: .leading) { + ForEach(model.chat) { msg in // MARK: Agreement if msg.type == .agreement { - if !msg.text.isEmpty { - HStack { - VStack(alignment: .leading) { - Text(msg.text) - .textSelection(.enabled) - .lineSpacing(4) - .padding(32) - .opacity(0.75) + VStack(alignment: .center) { + + FileImageView() + .environment(self.model) + .frame(maxWidth: 468.0) + .clipShape(RoundedRectangle(cornerRadius: 8)) + + VStack(spacing: 0) { + ScrollView(.vertical) { + HStack { + Text(msg.text) + .font(.system(size: 12)) + .fontDesign(.monospaced) + .textSelection(.enabled) + Spacer() + } + .padding(16) } - .frame(minWidth: 150, maxWidth: 450, alignment: .center) - .background(VisualEffectView(material: .titlebar, blendingMode: .withinWindow).cornerRadius(24)) - .padding() + .scrollBounceBehavior(.basedOnSize) + .frame(maxHeight: 325) + +// Divider() +// +// HStack { +// Button("Disagree") { +// dismiss() +// } +// .controlSize(.large) +// +// Spacer() +// +// Button("Agree") { +// model.sendAgree() +// } +// .controlSize(.large) +// .keyboardShortcut(.defaultAction) +// } +// .padding(16) } - .frame(maxWidth: .infinity) - .padding() + .background(Color(white: colorScheme == .light ? 0.0 : 1.0).opacity(0.05)) + .frame(maxWidth: 468.0) + .clipShape(RoundedRectangle(cornerRadius: 8)) } + .frame(maxWidth: .infinity) + .padding() } // MARK: Status else if msg.type == .status { @@ -105,7 +136,7 @@ struct ChatView: View { // MARK: Input Divider Divider() - .padding(.bottom, 0) + .padding([.top, .bottom], 0) // MARK: Input Bar HStack(alignment: .lastTextBaseline, spacing: 0) { @@ -141,52 +172,11 @@ struct ChatView: View { .onTapGesture { focusedField = .chatInput } - - -// .overlay(alignment: .bottom) { -// // MARK: Input Bar -// VStack(alignment: .leading, spacing: 0) { -// -// } -// } - // } - - // VStack(alignment: .center) { - // Spacer() - - - // .onKeyPress(keys: [.return]) { event in - // print(event) - // guard - // event.phase == .down, - // event.key == .return else { - // return .ignored - // } - // - // if event.modifiers.contains(.shift) { - // print("TRYING TO ADD NEW LINE") - // self.input += "\n" - // return .handled - // } - // - // if !self.input.isEmpty { - // model.sendChat(self.input) - // } - // self.input = "" - // - // return .handled - // } - // .onSubmit { - // if !self.input.isEmpty { - // model.sendChat(self.input) - // } - // self.input = "" - // } - } } + .navigationTitle(self.model.serverTitle) + .navigationSubtitle(self.model.users.count > 0 ? "^[\(self.model.users.count) user](inflect: true) online" : "") .background(Color(nsColor: .textBackgroundColor)) - // } } } |