aboutsummaryrefslogtreecommitdiff
path: root/Hotline/Views/ChatView.swift
diff options
context:
space:
mode:
authorDustin Mierau <dustin@mierau.me>2023-12-04 14:31:12 -0800
committerDustin Mierau <dustin@mierau.me>2023-12-04 14:31:12 -0800
commitb1a176ba3da2c7cf815084f0f8109008fe763809 (patch)
tree5bbf52900d5dab9091216cc0f1e5dc84ad69cc9f /Hotline/Views/ChatView.swift
parent471546236b8991f61d26c0e3aa8ee48b83b983af (diff)
Starting to get app views displaying data (roughly)
Diffstat (limited to 'Hotline/Views/ChatView.swift')
-rw-r--r--Hotline/Views/ChatView.swift78
1 files changed, 44 insertions, 34 deletions
diff --git a/Hotline/Views/ChatView.swift b/Hotline/Views/ChatView.swift
index 532a890..6dc7318 100644
--- a/Hotline/Views/ChatView.swift
+++ b/Hotline/Views/ChatView.swift
@@ -1,55 +1,64 @@
import SwiftUI
struct ChatView: View {
-// @Binding private var input: String
+ @Environment(HotlineClient.self) private var hotline
+
@State var input: String = ""
@State private var scrollPos: Int?
@State private var contentHeight: CGFloat = 0
var body: some View {
VStack(spacing: 0) {
- GeometryReader { geometry in
- ScrollView(.vertical) {
- ScrollViewReader { scrollReader in
- VStack(alignment: .leading) {
- Spacer()
- LazyVStack(alignment: .leading, spacing: 10) {
- HStack(alignment: .firstTextBaseline) {
- Text("bolt:").bold().fontDesign(.monospaced).frame(minWidth: 60)
- Text("hello!").fontDesign(.monospaced).textSelection(.enabled)
- }
- ForEach(0..<50) { i in
- HStack(alignment: .firstTextBaseline) {
- Text("mierau:").bold().fontDesign(.monospaced)
- Text("g'day to you. what's going on this afternoon?")
- .fontDesign(.monospaced)
- .textSelection(.enabled)
- }
- }
- Text("").font(.system(size: 0)).id("bottomScroll")
- }
- .padding()
- }
- // .frame(width: geometry.size.width)
- .frame(minHeight: geometry.size.height)
-// .background(Color.red)
- .onAppear() {
- scrollReader.scrollTo("bottomScroll", anchor: .bottom)
- }
- // .onChange() {
- // scrollReader.scrollTo(10000, anchor: .bottomTrailing)
- // }
- }
+ List(hotline.chatMessages) { msg in
+ if msg.username == "" {
+
+ }
+ HStack(alignment: .firstTextBaseline) {
+ Text("\(msg.username):").bold().fontDesign(.monospaced).font(.system(size: 12))
+ Text(msg.message)
+ .fontDesign(.monospaced)
+ .textSelection(.enabled)
+ .font(.system(size: 12))
}
}
+ .padding()
+
+// GeometryReader { geometry in
+// ScrollView(.vertical) {
+// ScrollViewReader { scrollReader in
+// VStack(alignment: .leading) {
+// Spacer()
+// List(hotline.chatMessages) { msg in
+// HStack(alignment: .firstTextBaseline) {
+// Text("\(msg.username):").bold().fontDesign(.monospaced)
+// Text(msg.message)
+// .fontDesign(.monospaced)
+// .textSelection(.enabled)
+// }
+// }
+// .padding()
+// }
+// // .frame(width: geometry.size.width)
+// .frame(minHeight: geometry.size.height)
+//// .background(Color.red)
+// .onAppear() {
+//// scrollReader.scrollTo("bottomScroll", anchor: .bottom)
+// }
+// // .onChange() {
+// // scrollReader.scrollTo(10000, anchor: .bottomTrailing)
+// // }
+// }
+// }
+// }
Divider()
HStack(alignment: .top) {
Image(systemName: "chevron.right")
- TextField("This is a chat topic", text: $input, axis: .vertical)
+ TextField("", text: $input, axis: .vertical)
.lineLimit(1...5)
.onSubmit {
+ hotline.sendChat(message: self.input)
// HotlineClient.shared.sendChat(message: self.input)
self.input = ""
}
@@ -60,4 +69,5 @@ struct ChatView: View {
#Preview {
ChatView()
+ .environment(HotlineClient())
}