fix broken nagivation

Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
William Casarin
2022-04-23 12:41:36 -07:00
parent 0c63433f8e
commit 4de2ce402e
15 changed files with 303 additions and 131 deletions

View File

@@ -9,26 +9,39 @@ import SwiftUI
struct ChatroomView: View {
@EnvironmentObject var thread: ThreadModel
@Environment(\.dismiss) var dismiss
var body: some View {
ScrollViewReader { scroller in
ScrollView {
VStack {
LazyVStack {
let count = thread.events.count
ForEach(Array(zip(thread.events, thread.events.indices)), id: \.0.id) { (ev, ind) in
ChatView(event: thread.events[ind],
prev_ev: ind > 0 ? thread.events[ind-1] : nil,
next_ev: ind == count-1 ? nil : thread.events[ind+1]
)
.onTapGesture {
if thread.event!.id == ev.id {
//dismiss()
toggle_thread_view()
} else {
thread.set_active_event(ev)
}
}
.environmentObject(thread)
}
}
}
.onAppear() {
scroll_to_event(scroller: scroller, id: thread.event.id, delay: 0.5, animate: true, anchor: .center)
scroll_to_event(scroller: scroller, id: thread.event!.id, delay: 0.3, animate: true, anchor: .bottom)
}
}
}
func toggle_thread_view() {
NotificationCenter.default.post(name: .toggle_thread_view, object: nil)
}
}