Use NavigationLink with value to push Explore trending links" (#1594)

- Fixes trending links "see more" not getting added to navigation path.
This commit is contained in:
Bosco Ho 2023-09-26 23:38:17 -07:00 committed by GitHub
parent 1f28595d39
commit 1f44c502dd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 34 additions and 14 deletions

View File

@ -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)
}

View File

@ -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])
}

View File

@ -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)
}
}

View File

@ -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)
}