Add quick access button to explore screen

This commit is contained in:
Thomas Ricouard 2023-07-18 08:39:52 +02:00
parent ab834be2f3
commit 4943a1708c

View file

@ -19,6 +19,7 @@ public struct ExploreView: View {
public var body: some View {
List {
if !viewModel.isLoaded {
quickAccessView
loadingView
} else if !viewModel.searchQuery.isEmpty {
if let results = viewModel.results[viewModel.searchQuery] {
@ -48,6 +49,7 @@ public struct ExploreView: View {
.listRowBackground(theme.secondaryBackgroundColor)
.listRowSeparator(.hidden)
} else {
quickAccessView
if !viewModel.trendingTags.isEmpty {
trendingTagsSection
}
@ -83,6 +85,30 @@ public struct ExploreView: View {
placement: .navigationBarDrawer(displayMode: .always),
prompt: Text("explore.search.prompt"))
}
private var quickAccessView: some View {
ScrollView(.horizontal) {
HStack {
Button("explore.section.trending.tags") {
routerPath.navigate(to: RouterDestination.tagsList(tags: viewModel.trendingTags))
}
.buttonStyle(.bordered)
Button("explore.section.suggested-users") {
routerPath.navigate(to: RouterDestination.accountsList(accounts: viewModel.suggestedAccounts))
}
.buttonStyle(.bordered)
Button("explore.section.trending.posts") {
routerPath.navigate(to: RouterDestination.trendingTimeline)
}
.buttonStyle(.bordered)
}
.padding(.horizontal, 16)
}
.scrollIndicators(.never)
.listRowInsets(EdgeInsets())
.listRowBackground(theme.secondaryBackgroundColor)
.listRowSeparator(.hidden)
}
private var loadingView: some View {
ForEach(Status.placeholders()) { status in