Hide empty player accessory and preserve paused track
This commit is contained in:
1 parent
35faa78ec4
commit
037fb01623
2 files changed
+41
-61
No files matched your search
@@ -2,19 +2,24 @@ import SwiftUI
|
||||
|
||||
struct MainTabView: View {
|
||||
@EnvironmentObject private var player: PlayerManager
|
||||
@State private var selectedTab: MainTab = .home
|
||||
@AppStorage("music.selected-tab") private var selectedTabRawValue = MainTab.home.rawValue
|
||||
|
||||
var body: some View {
|
||||
tabs
|
||||
.tabViewBottomAccessory {
|
||||
PlayerBottomAccessoryView()
|
||||
Group {
|
||||
if player.currentTrack != nil {
|
||||
tabs.tabViewBottomAccessory {
|
||||
PlayerBottomAccessoryView()
|
||||
}
|
||||
} else {
|
||||
tabs
|
||||
}
|
||||
.animation(.snappy(duration: 0.25), value: player.currentTrack?.id)
|
||||
.animation(.snappy(duration: 0.25), value: player.isMiniPlayerCompact)
|
||||
}
|
||||
.animation(.snappy(duration: 0.25), value: player.currentTrack?.id)
|
||||
.animation(.snappy(duration: 0.25), value: player.isMiniPlayerCompact)
|
||||
}
|
||||
|
||||
private var tabs: some View {
|
||||
TabView(selection: $selectedTab) {
|
||||
TabView(selection: selectedTab) {
|
||||
Tab("Home", systemImage: "house", value: MainTab.home) {
|
||||
HomeView()
|
||||
}
|
||||
@@ -31,7 +36,14 @@ struct MainTabView: View {
|
||||
.tabBarMinimizeBehavior(.onScrollDown)
|
||||
}
|
||||
|
||||
private enum MainTab: Hashable {
|
||||
private var selectedTab: Binding<MainTab> {
|
||||
Binding(
|
||||
get: { MainTab(rawValue: selectedTabRawValue) ?? .home },
|
||||
set: { selectedTabRawValue = $0.rawValue }
|
||||
)
|
||||
}
|
||||
|
||||
private enum MainTab: String, Hashable {
|
||||
case home
|
||||
case library
|
||||
case search
|
||||
|
||||
Reference in new issue
Block a user