Add persistent mini player
This commit is contained in:
1 parent
f7e204f2d8
commit
f6f370d5ca
3 files changed
+134
No files matched your search
@@ -1,6 +1,8 @@
|
||||
import SwiftUI
|
||||
|
||||
struct MainTabView: View {
|
||||
@EnvironmentObject private var player: PlayerManager
|
||||
|
||||
var body: some View {
|
||||
TabView {
|
||||
Tab("Home", systemImage: "house") {
|
||||
@@ -16,6 +18,26 @@ struct MainTabView: View {
|
||||
}
|
||||
}
|
||||
.tint(.red)
|
||||
.safeAreaInset(edge: .bottom, spacing: 0) {
|
||||
if let track = player.currentTrack {
|
||||
MiniPlayerView(
|
||||
track: track,
|
||||
isPlaying: player.isPlaying,
|
||||
artworkURL: player.artworkURL(for: track),
|
||||
onTogglePlayback: {
|
||||
if player.isPlaying { player.pause() }
|
||||
else { player.play() }
|
||||
},
|
||||
onNext: player.next
|
||||
)
|
||||
.padding(.horizontal, 12)
|
||||
// The iOS 26 tab bar floats over the bottom safe area, so lift
|
||||
// the mini-player above it instead of letting the glass layers collide.
|
||||
.padding(.bottom, 54)
|
||||
.transition(.move(edge: .bottom).combined(with: .opacity))
|
||||
}
|
||||
}
|
||||
.animation(.snappy(duration: 0.25), value: player.currentTrack?.id)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user