Scale fullscreen artwork to player width
This commit is contained in:
1 parent
9149983234
commit
2562acd96f
1 file changed
+13
-2
@@ -5,6 +5,8 @@ struct FullscreenPlayerView: View {
|
||||
@Environment(\.dismiss) private var dismiss
|
||||
@State private var seekPosition: Double?
|
||||
@State private var expandedSlider: SliderKind?
|
||||
@State private var displayedIsPlaying = false
|
||||
@State private var playIconScale: CGFloat = 1
|
||||
|
||||
private enum SliderKind {
|
||||
case progress
|
||||
@@ -107,6 +109,14 @@ struct FullscreenPlayerView: View {
|
||||
}
|
||||
.ignoresSafeArea()
|
||||
.preferredColorScheme(.dark)
|
||||
.onAppear { displayedIsPlaying = player.isPlaying }
|
||||
.onChange(of: player.isPlaying) { _, newValue in
|
||||
withAnimation(.easeOut(duration: 0.12)) { playIconScale = 0 }
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.12) {
|
||||
displayedIsPlaying = newValue
|
||||
withAnimation(.easeOut(duration: 0.12)) { playIconScale = 1 }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
@@ -228,9 +238,10 @@ struct FullscreenPlayerView: View {
|
||||
Button {
|
||||
if player.isPlaying { player.pause() } else { player.play() }
|
||||
} label: {
|
||||
Image(systemName: player.isPlaying ? "pause.fill" : "play.fill")
|
||||
Image(systemName: displayedIsPlaying ? "pause.fill" : "play.fill")
|
||||
.font(.system(size: 36, weight: .semibold))
|
||||
.frame(width: 76, height: 76)
|
||||
.scaleEffect(playIconScale)
|
||||
}
|
||||
.accessibilityLabel(player.isPlaying ? "Pause" : "Play")
|
||||
|
||||
@@ -255,7 +266,7 @@ struct FullscreenPlayerView: View {
|
||||
}
|
||||
|
||||
private func artworkSize(in size: CGSize) -> CGFloat {
|
||||
min(280, size.width - 40)
|
||||
size.width * 0.86
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user