better chat view

Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
William Casarin
2022-04-23 17:10:51 -07:00
parent 4de2ce402e
commit 090385d3da
7 changed files with 106 additions and 60 deletions

View File

@@ -14,7 +14,7 @@ struct ChatroomView: View {
var body: some View {
ScrollViewReader { scroller in
ScrollView {
LazyVStack {
LazyVStack(alignment: .leading) {
let count = thread.events.count
ForEach(Array(zip(thread.events, thread.events.indices)), id: \.0.id) { (ev, ind) in
ChatView(event: thread.events[ind],
@@ -33,6 +33,13 @@ struct ChatroomView: View {
}
}
}
.onReceive(NotificationCenter.default.publisher(for: .select_quote)) { notif in
let ev = notif.object as! NostrEvent
if ev.id != thread.event!.id {
thread.set_active_event(ev)
}
scroll_to_event(scroller: scroller, id: ev.id, delay: 0, animate: true, anchor: .top)
}
.onAppear() {
scroll_to_event(scroller: scroller, id: thread.event!.id, delay: 0.3, animate: true, anchor: .bottom)
}