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 { public var body: some View {
List { List {
if !viewModel.isLoaded { if !viewModel.isLoaded {
quickAccessView
loadingView loadingView
} else if !viewModel.searchQuery.isEmpty { } else if !viewModel.searchQuery.isEmpty {
if let results = viewModel.results[viewModel.searchQuery] { if let results = viewModel.results[viewModel.searchQuery] {
@ -48,6 +49,7 @@ public struct ExploreView: View {
.listRowBackground(theme.secondaryBackgroundColor) .listRowBackground(theme.secondaryBackgroundColor)
.listRowSeparator(.hidden) .listRowSeparator(.hidden)
} else { } else {
quickAccessView
if !viewModel.trendingTags.isEmpty { if !viewModel.trendingTags.isEmpty {
trendingTagsSection trendingTagsSection
} }
@ -83,6 +85,30 @@ public struct ExploreView: View {
placement: .navigationBarDrawer(displayMode: .always), placement: .navigationBarDrawer(displayMode: .always),
prompt: Text("explore.search.prompt")) 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 { private var loadingView: some View {
ForEach(Status.placeholders()) { status in ForEach(Status.placeholders()) { status in