Refine tab mini player layout
This commit is contained in:
1 parent
f6f370d5ca
commit
80812e8fc1
5 files changed
+135
-31
No files matched your search
+36
-7
@@ -18,11 +18,13 @@ struct MainTabView: View {
|
||||
}
|
||||
}
|
||||
.tint(.red)
|
||||
.safeAreaInset(edge: .bottom, spacing: 0) {
|
||||
.tabBarMinimizeBehavior(.onScrollDown)
|
||||
.tabViewBottomAccessory {
|
||||
if let track = player.currentTrack {
|
||||
MiniPlayerView(
|
||||
PlayerBottomAccessory(
|
||||
track: track,
|
||||
isPlaying: player.isPlaying,
|
||||
isCompact: player.isMiniPlayerCompact,
|
||||
artworkURL: player.artworkURL(for: track),
|
||||
onTogglePlayback: {
|
||||
if player.isPlaying { player.pause() }
|
||||
@@ -30,14 +32,41 @@ struct MainTabView: View {
|
||||
},
|
||||
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)
|
||||
.animation(.snappy(duration: 0.25), value: player.isMiniPlayerCompact)
|
||||
}
|
||||
}
|
||||
|
||||
private struct PlayerBottomAccessory: View {
|
||||
@Environment(\.tabViewBottomAccessoryPlacement) private var placement
|
||||
|
||||
let track: Track
|
||||
let isPlaying: Bool
|
||||
let isCompact: Bool
|
||||
let artworkURL: URL?
|
||||
let onTogglePlayback: () -> Void
|
||||
let onNext: () -> Void
|
||||
|
||||
private var shouldBeCompact: Bool {
|
||||
isCompact || placement == .inline
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
MiniPlayerView(
|
||||
track: track,
|
||||
isPlaying: isPlaying,
|
||||
isCompact: shouldBeCompact,
|
||||
isInline: placement == .inline,
|
||||
artworkURL: artworkURL,
|
||||
onTogglePlayback: onTogglePlayback,
|
||||
onNext: onNext
|
||||
)
|
||||
.padding(.horizontal, placement == .inline ? 4 : 12)
|
||||
.frame(maxWidth: placement == .inline ? 320 : .infinity)
|
||||
.padding(.bottom, placement == .inline ? 0 : 8)
|
||||
.transition(.move(edge: .bottom).combined(with: .opacity))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user