diff --git a/damus/Views/ThreadV2View.swift b/damus/Views/ThreadV2View.swift index 7b9b6ce..f31706c 100644 --- a/damus/Views/ThreadV2View.swift +++ b/damus/Views/ThreadV2View.swift @@ -232,28 +232,41 @@ struct BuildThreadV2View: View { struct ThreadV2View: View { let damus: DamusState let thread: ThreadV2 + @State var nav_target: String? = nil + @State var navigating: Bool = false + + var MaybeBuildThreadView: some View { + Group { + if let evid = nav_target { + BuildThreadV2View(damus: damus, event_id: evid) + } else { + EmptyView() + } + } + } var body: some View { + NavigationLink(destination: MaybeBuildThreadView, isActive: $navigating) { + EmptyView() + } ScrollViewReader { reader in ScrollView { VStack { // MARK: - Parents events view VStack { ForEach(thread.parentEvents, id: \.id) { event in - NavigationLink(destination: BuildThreadV2View( + EventView( + event: event, + highlight: .none, + has_action_bar: true, damus: damus, - event_id: event.id - )){ - EventView( - event: event, - highlight: .none, - has_action_bar: true, - damus: damus, - show_friend_icon: true, // TODO: change it - size: .small - ) + show_friend_icon: true, // TODO: change it + size: .small + ) + .onTapGesture { + nav_target = event.id + navigating = true } - .buttonStyle(.plain) .onAppear { // TODO: find another solution to prevent layout shifting and layout blocking on large responses reader.scrollTo("main", anchor: .bottom) @@ -283,19 +296,18 @@ struct ThreadV2View: View { // MARK: - Responses of the actual event view ForEach(thread.childEvents, id: \.id) { event in - NavigationLink(destination: BuildThreadV2View( + EventView( + event: event, + highlight: .none, + has_action_bar: true, damus: damus, - event_id: event.id - )){ - EventView( - event: event, - highlight: .none, - has_action_bar: true, - damus: damus, - show_friend_icon: true, // TODO: change it - size: .small - ) - }.buttonStyle(.plain) + show_friend_icon: true, // TODO: change it + size: .small + ) + .onTapGesture { + nav_target = event.id + navigating = true + } } }.padding() }.navigationBarTitle("Thread") diff --git a/damus/Views/TimelineView.swift b/damus/Views/TimelineView.swift index 63cdec2..b4e237d 100644 --- a/damus/Views/TimelineView.swift +++ b/damus/Views/TimelineView.swift @@ -17,8 +17,23 @@ struct InnerTimelineView: View { let damus: DamusState let show_friend_icon: Bool let filter: (NostrEvent) -> Bool + @State var nav_target: NostrEvent? = nil + @State var navigating: Bool = false + + var MaybeBuildThreadView: some View { + Group { + if let ev = nav_target { + BuildThreadV2View(damus: damus, event_id: (ev.inner_event ?? ev).id) + } else { + EmptyView() + } + } + } var body: some View { + NavigationLink(destination: MaybeBuildThreadView, isActive: $navigating) { + EmptyView() + } LazyVStack { if events.isEmpty { EmptyTimelineView() @@ -28,14 +43,11 @@ struct InnerTimelineView: View { //let is_chatroom = should_show_chatroom(ev) //let tv = ThreadView(thread: tm, damus: damus, is_chatroom: is_chatroom) - NavigationLink(destination: BuildThreadV2View( - damus: damus, - event_id: (ev.inner_event ?? ev).id - )) { - EventView(event: ev, highlight: .none, has_action_bar: true, damus: damus, show_friend_icon: show_friend_icon) - } - .isDetailLink(true) - .buttonStyle(PlainButtonStyle()) + EventView(event: ev, highlight: .none, has_action_bar: true, damus: damus, show_friend_icon: show_friend_icon) + .onTapGesture { + nav_target = ev + navigating = true + } } } }