Animate player queue transition

This commit is contained in:
lucast committed 2026-10-09 01:48:09 +02:00
1 parent df9eef3058
commit 4be9eb84b6
1 file changed
+59 -22
+59 -22
View File
@@ -14,6 +14,7 @@ struct FullscreenPlayerView: View {
@State private var isQueuePresented = false @State private var isQueuePresented = false
@State private var isShuffleEnabled = false @State private var isShuffleEnabled = false
@State private var isAutoplayEnabled = false @State private var isAutoplayEnabled = false
@Namespace private var queueArtworkNamespace
private enum SliderKind { private enum SliderKind {
case progress case progress
@@ -55,33 +56,45 @@ struct FullscreenPlayerView: View {
.accessibilityLabel("Swipe down to close player") .accessibilityLabel("Swipe down to close player")
if isQueuePresented { if isQueuePresented {
queueContent(size: size) queueArtwork(for: track, size: 56)
.transition(.opacity) .matchedGeometryEffect(
id: "fullscreen-current-artwork",
in: queueArtworkNamespace,
isSource: isQueuePresented
)
.position(
x: size.width * 0.08 + 28,
y: size.height * 0.12 + 39
)
} else { } else {
artwork artwork
.frame(width: artworkLength, height: artworkLength) .frame(width: artworkLength, height: artworkLength)
.matchedGeometryEffect(
id: "fullscreen-current-artwork",
in: queueArtworkNamespace,
isSource: !isQueuePresented
)
.clipShape(RoundedRectangle(cornerRadius: 14, style: .continuous)) .clipShape(RoundedRectangle(cornerRadius: 14, style: .continuous))
.shadow(color: .black.opacity(0.16), radius: 26, y: 18) .shadow(color: .black.opacity(0.16), radius: 26, y: 18)
.position(x: size.width * 0.5, y: size.height * 0.31) .position(x: size.width * 0.5, y: size.height * 0.31)
}
Image(systemName: "ellipsis") if isQueuePresented {
.font(.system(size: 16, weight: .semibold)) queueDetails(size: size)
.frame(width: size.width - 72, alignment: .trailing) .transition(
.foregroundStyle(.white) .asymmetric(
.position(x: size.width * 0.5, y: size.height * 0.60) insertion: .offset(y: -24).combined(with: .opacity),
removal: .offset(y: 34).combined(with: .opacity)
VStack(alignment: .leading, spacing: 6) { )
Text(track?.name ?? "") )
.font(.system(size: 20, weight: .bold)) } else {
.lineLimit(1) playerDetails(size: size)
Text(artistNames) .transition(
.font(.system(size: 16)) .asymmetric(
.foregroundStyle(.white.opacity(0.68)) insertion: .offset(y: -18).combined(with: .opacity),
.lineLimit(1) removal: .offset(y: 18).combined(with: .opacity)
} )
.foregroundStyle(.white) )
.frame(width: size.width * 0.68, alignment: .leading)
.position(x: size.width * 0.41, y: size.height * 0.60)
} }
seekControls seekControls
@@ -172,10 +185,33 @@ struct FullscreenPlayerView: View {
.background(.ultraThinMaterial) .background(.ultraThinMaterial)
} }
private func queueContent(size: CGSize) -> some View { @ViewBuilder
private func playerDetails(size: CGSize) -> some View {
Image(systemName: "ellipsis")
.font(.system(size: 16, weight: .semibold))
.frame(width: size.width - 72, alignment: .trailing)
.foregroundStyle(.white)
.position(x: size.width * 0.5, y: size.height * 0.60)
VStack(alignment: .leading, spacing: 6) {
Text(track?.name ?? "")
.font(.system(size: 20, weight: .bold))
.lineLimit(1)
Text(artistNames)
.font(.system(size: 16))
.foregroundStyle(.white.opacity(0.68))
.lineLimit(1)
}
.foregroundStyle(.white)
.frame(width: size.width * 0.68, alignment: .leading)
.position(x: size.width * 0.41, y: size.height * 0.60)
}
private func queueDetails(size: CGSize) -> some View {
VStack(alignment: .leading, spacing: 18) { VStack(alignment: .leading, spacing: 18) {
HStack(spacing: 14) { HStack(spacing: 14) {
queueArtwork(for: track, size: 56) Color.clear
.frame(width: 56, height: 56)
VStack(alignment: .leading, spacing: 3) { VStack(alignment: .leading, spacing: 3) {
Text(track?.name ?? "") Text(track?.name ?? "")
@@ -264,6 +300,7 @@ struct FullscreenPlayerView: View {
.frame(maxWidth: .infinity, alignment: .topLeading) .frame(maxWidth: .infinity, alignment: .topLeading)
.frame(height: size.height * 0.66, alignment: .top) .frame(height: size.height * 0.66, alignment: .top)
.foregroundStyle(.white) .foregroundStyle(.white)
.animation(.spring(response: 0.42, dampingFraction: 0.88), value: isQueuePresented)
} }
private func queueModeButton( private func queueModeButton(