diff options
| author | Dustin Mierau <dustin@mierau.me> | 2023-12-12 15:27:00 -0800 |
|---|---|---|
| committer | Dustin Mierau <dustin@mierau.me> | 2023-12-12 15:27:00 -0800 |
| commit | 248fcbbd5dca84747e6f3fd9d1d52c41ab8640c3 (patch) | |
| tree | f8f76c7b071aff2fe56c4e900c72dcbaddd3c62a /Hotline/Views/ChatView.swift | |
| parent | f71c4cae3b21db506573bcdfa9fdb6cde41cc0ca (diff) | |
New category listing is working again. Added optionset for user access info. Some UI cleanup across the board.
Diffstat (limited to 'Hotline/Views/ChatView.swift')
| -rw-r--r-- | Hotline/Views/ChatView.swift | 71 |
1 files changed, 20 insertions, 51 deletions
diff --git a/Hotline/Views/ChatView.swift b/Hotline/Views/ChatView.swift index 60951c3..8e5b135 100644 --- a/Hotline/Views/ChatView.swift +++ b/Hotline/Views/ChatView.swift @@ -15,12 +15,12 @@ struct ChatView: View { @State private var contentHeight: CGFloat = 0 @Namespace var bottomID - + var body: some View { NavigationStack { VStack(spacing: 0) { - ScrollView { - ScrollViewReader { reader in + ScrollViewReader { reader in + ScrollView { LazyVStack(alignment: .leading) { ForEach(model.chat) { msg in if msg.type == .agreement { @@ -71,27 +71,27 @@ struct ChatView: View { } Spacer() } - .padding() + .padding(EdgeInsets(top: 4, leading: 16, bottom: 4, trailing: 16)) } } EmptyView().id(bottomID) } - .onChange(of: model.chat.count) { - withAnimation { - reader.scrollTo(bottomID, anchor: .bottom) - } - print("SCROLLED TO BOTTOM") - } - .onAppear { - withAnimation { - reader.scrollTo("bottom view", anchor: .bottom) - } + .padding(.bottom, 12) + } + .onChange(of: model.chat.count) { + withAnimation { + reader.scrollTo(bottomID, anchor: .bottom) } + print("SCROLLED TO BOTTOM") + } + .onAppear { + print("SCROLLED TO BOTTOM ON APPEAR") + reader.scrollTo(bottomID, anchor: .bottom) + } + .scrollDismissesKeyboard(.interactively) + .onTapGesture { + self.endEditing() } - } - .scrollDismissesKeyboard(.interactively) - .onTapGesture { - self.endEditing() } Divider() @@ -104,7 +104,7 @@ struct ChatView: View { .onSubmit { if !self.input.isEmpty { model.sendChat(self.input) -// hotline.sendChat(message: self.input) + // hotline.sendChat(message: self.input) } self.input = "" } @@ -112,7 +112,7 @@ struct ChatView: View { Button { if !self.input.isEmpty { model.sendChat(self.input) -// hotline.sendChat(message: self.input) + // hotline.sendChat(message: self.input) } self.input = "" } label: { @@ -143,37 +143,6 @@ struct ChatView: View { } } - - - // 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) - // // } - // } - // } - // } - - } } |