From 1f44c502dd71947853efe10db609d5704389a0b1 Mon Sep 17 00:00:00 2001 From: Bosco Ho Date: Tue, 26 Sep 2023 23:38:17 -0700 Subject: [PATCH] Use NavigationLink with value to push Explore trending links" (#1594) - Fixes trending links "see more" not getting added to navigation path. --- IceCubesApp/App/AppRegistry.swift | 2 ++ Packages/Env/Sources/Env/Router.swift | 1 + .../Sources/Explore/CardsListView.swift | 29 +++++++++++++++++++ .../Explore/Sources/Explore/ExploreView.swift | 16 ++-------- 4 files changed, 34 insertions(+), 14 deletions(-) create mode 100644 Packages/Explore/Sources/Explore/CardsListView.swift diff --git a/IceCubesApp/App/AppRegistry.swift b/IceCubesApp/App/AppRegistry.swift index ec6ef2c0..f00167a2 100644 --- a/IceCubesApp/App/AppRegistry.swift +++ b/IceCubesApp/App/AppRegistry.swift @@ -55,6 +55,8 @@ extension View { selectedTagGroup: .constant(nil), scrollToTopSignal: .constant(0), canFilterTimeline: false) + case let .trendingLinks(cards): + CardsListView(cards: cards) case let .tagsList(tags): TagsListView(tags: tags) } diff --git a/Packages/Env/Sources/Env/Router.swift b/Packages/Env/Sources/Env/Router.swift index 313e3b2e..71930353 100644 --- a/Packages/Env/Sources/Env/Router.swift +++ b/Packages/Env/Sources/Env/Router.swift @@ -21,6 +21,7 @@ public enum RouterDestination: Hashable { case rebloggedBy(id: String) case accountsList(accounts: [Account]) case trendingTimeline + case trendingLinks(cards: [Card]) case tagsList(tags: [Tag]) } diff --git a/Packages/Explore/Sources/Explore/CardsListView.swift b/Packages/Explore/Sources/Explore/CardsListView.swift new file mode 100644 index 00000000..24df710b --- /dev/null +++ b/Packages/Explore/Sources/Explore/CardsListView.swift @@ -0,0 +1,29 @@ +import DesignSystem +import Models +import Status +import SwiftUI + +public struct CardsListView: View { + @Environment(Theme.self) private var theme + + let cards: [Card] + + public init(cards: [Card]) { + self.cards = cards + } + + public var body: some View { + List { + ForEach(cards) { card in + StatusRowCardView(card: card) + .listRowBackground(theme.primaryBackgroundColor) + .padding(.vertical, 8) + } + } + .scrollContentBackground(.hidden) + .background(theme.primaryBackgroundColor) + .listStyle(.plain) + .navigationTitle("explore.section.trending.links") + .navigationBarTitleDisplayMode(.inline) + } +} diff --git a/Packages/Explore/Sources/Explore/ExploreView.swift b/Packages/Explore/Sources/Explore/ExploreView.swift index 0ef711b3..2308a995 100644 --- a/Packages/Explore/Sources/Explore/ExploreView.swift +++ b/Packages/Explore/Sources/Explore/ExploreView.swift @@ -226,20 +226,8 @@ public struct ExploreView: View { .listRowBackground(theme.primaryBackgroundColor) .padding(.vertical, 8) } - NavigationLink { - List { - ForEach(viewModel.trendingLinks) { card in - StatusRowCardView(card: card) - .listRowBackground(theme.primaryBackgroundColor) - .padding(.vertical, 8) - } - } - .scrollContentBackground(.hidden) - .background(theme.primaryBackgroundColor) - .listStyle(.plain) - .navigationTitle("explore.section.trending.links") - .navigationBarTitleDisplayMode(.inline) - } label: { + + NavigationLink(value: RouterDestination.trendingLinks(cards: viewModel.trendingLinks)) { Text("see-more") .foregroundColor(theme.tintColor) }