diff --git a/Music/View/Player/FullscreenPlayerView.swift b/Music/View/Player/FullscreenPlayerView.swift index 5e015d6..809f273 100644 --- a/Music/View/Player/FullscreenPlayerView.swift +++ b/Music/View/Player/FullscreenPlayerView.swift @@ -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 } }