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), selectedTagGroup: .constant(nil),
scrollToTopSignal: .constant(0), scrollToTopSignal: .constant(0),
canFilterTimeline: false) canFilterTimeline: false)
case let .trendingLinks(cards):
CardsListView(cards: cards)
case let .tagsList(tags): case let .tagsList(tags):
TagsListView(tags: tags) TagsListView(tags: tags)
} }

View file

@ -21,6 +21,7 @@ public enum RouterDestination: Hashable {
case rebloggedBy(id: String) case rebloggedBy(id: String)
case accountsList(accounts: [Account]) case accountsList(accounts: [Account])
case trendingTimeline case trendingTimeline
case trendingLinks(cards: [Card])
case tagsList(tags: [Tag]) 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) .listRowBackground(theme.primaryBackgroundColor)
.padding(.vertical, 8) .padding(.vertical, 8)
} }
NavigationLink {
List { NavigationLink(value: RouterDestination.trendingLinks(cards: viewModel.trendingLinks)) {
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: {
Text("see-more") Text("see-more")
.foregroundColor(theme.tintColor) .foregroundColor(theme.tintColor)
} }