1
0
mirror of https://github.com/yattee/yattee.git synced 2024-12-13 13:50:32 +05:30

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

View File

@ -177,11 +177,40 @@ struct SearchView: View {
.navigationTitle("Search") .navigationTitle("Search")
#endif #endif
#if os(iOS) #if os(iOS)
.navigationBarHidden(!Defaults[.visibleSections].isEmpty || navigationStyle == .sidebar) .navigationBarHidden(navigationBarHidden)
.navigationBarTitleDisplayMode(.inline) .navigationBarTitleDisplayMode(.inline)
#endif #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 { private var results: some View {
VStack { VStack {
if showRecentQueries { if showRecentQueries {