Fix displaying settings/account buttons when only search is visible (fix #56)

This commit is contained in:
Arkadiusz Fal 2022-01-24 22:22:47 +01:00
parent 33e86710a8
commit 975b8fe5c3
2 changed files with 36 additions and 2 deletions

View File

@ -35,7 +35,7 @@ struct AppTabNavigation: View {
trendingNavigationView
}
if visibleSections.contains(.playlists), accounts.app.supportsUserPlaylists {
if playlistsVisible {
playlistsNavigationView
}
@ -118,6 +118,11 @@ struct AppTabNavigation: View {
accounts.app.supportsSubscriptions && !(accounts.current?.anonymous ?? true)
}
private var playlistsVisible: Bool {
visibleSections.contains(.playlists) &&
accounts.app.supportsUserPlaylists && !(accounts.current?.anonymous ?? true)
}
private var popularNavigationView: some View {
NavigationView {
LazyView(PopularView())

View File

@ -177,11 +177,40 @@ struct SearchView: View {
.navigationTitle("Search")
#endif
#if os(iOS)
.navigationBarHidden(!Defaults[.visibleSections].isEmpty || navigationStyle == .sidebar)
.navigationBarHidden(navigationBarHidden)
.navigationBarTitleDisplayMode(.inline)
#endif
}
private var navigationBarHidden: Bool {
if navigationStyle == .sidebar {
return true
}
let preferred = Defaults[.visibleSections]
var visibleSections = [VisibleSection]()
if accounts.app.supportsPopular && preferred.contains(.popular) {
visibleSections.append(.popular)
}
if accounts.app.supportsSubscriptions && accounts.signedIn && preferred.contains(.subscriptions) {
visibleSections.append(.subscriptions)
}
if accounts.app.supportsUserPlaylists && preferred.contains(.playlists) {
visibleSections.append(.playlists)
}
[VisibleSection.favorites, .trending].forEach { section in
if preferred.contains(section) {
visibleSections.append(section)
}
}
return !visibleSections.isEmpty
}
private var results: some View {
VStack {
if showRecentQueries {