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 isShuffleEnabled = false
@State private var isAutoplayEnabled = false
@Namespace private var queueArtworkNamespace
private enum SliderKind {
case progress
@@ -55,33 +56,45 @@ struct FullscreenPlayerView: View {
.accessibilityLabel("Swipe down to close player")
if isQueuePresented {
queueContent(size: size)
.transition(.opacity)
queueArtwork(for: track, size: 56)
.matchedGeometryEffect(
id: "fullscreen-current-artwork",
in: queueArtworkNamespace,
isSource: isQueuePresented
)
.position(
x: size.width * 0.08 + 28,
y: size.height * 0.12 + 39
)
} else {
artwork
.frame(width: artworkLength, height: artworkLength)
.matchedGeometryEffect(
id: "fullscreen-current-artwork",
in: queueArtworkNamespace,
isSource: !isQueuePresented
)
.clipShape(RoundedRectangle(cornerRadius: 14, style: .continuous))
.shadow(color: .black.opacity(0.16), radius: 26, y: 18)
.position(x: size.width * 0.5, y: size.height * 0.31)
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)
if isQueuePresented {
queueDetails(size: size)
.transition(
.asymmetric(
insertion: .offset(y: -24).combined(with: .opacity),
removal: .offset(y: 34).combined(with: .opacity)
)
)
} else {
playerDetails(size: size)
.transition(
.asymmetric(
insertion: .offset(y: -18).combined(with: .opacity),
removal: .offset(y: 18).combined(with: .opacity)
)
)
}
seekControls
@@ -172,10 +185,33 @@ struct FullscreenPlayerView: View {
.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) {
HStack(spacing: 14) {
queueArtwork(for: track, size: 56)
Color.clear
.frame(width: 56, height: 56)
VStack(alignment: .leading, spacing: 3) {
Text(track?.name ?? "")
@@ -264,6 +300,7 @@ struct FullscreenPlayerView: View {
.frame(maxWidth: .infinity, alignment: .topLeading)
.frame(height: size.height * 0.66, alignment: .top)
.foregroundStyle(.white)
.animation(.spring(response: 0.42, dampingFraction: 0.88), value: isQueuePresented)
}
private func queueModeButton(