From cd5a0835231cba2e8ac5a064617136a59206db02 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 23 Nov 2026 09:59:04 -0800 Subject: [PATCH] iOS: Now Playing close drag tracks the finger 1:1 (global space) and only re-renders the offset (DropState/DropOffset); build 58 Co-Authored-By: Claude Opus 5.5 --- ios/Stemify/UI/Screens/NowPlayingScreen.swift | 24 ++++++++++++------- ios/project.yml | 2 +- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/ios/Stemify/UI/Screens/NowPlayingScreen.swift b/ios/Stemify/UI/Screens/NowPlayingScreen.swift index 7e51f9b..e6ae5ac 100644 --- a/ios/Stemify/UI/Screens/NowPlayingScreen.swift +++ b/ios/Stemify/UI/Screens/NowPlayingScreen.swift @@ -3,6 +3,14 @@ import UIKit enum NpPanel { case Art, Mixer, Queue, Lyrics } +/// The close drag's offset. Only DropOffset reads it, so dragging re-renders just the offset. +@Observable final class DropState { var y: CGFloat = 0 } + +private struct DropOffset: ViewModifier { + let state: DropState + func body(content: Content) -> some View { content.offset(y: state.y) } +} + func deviceIcon(_ d: OutputDevice) -> (String, UInt32) { switch d.kind { case .Speaker: ("iphone", 0x8E8E93) @@ -62,8 +70,9 @@ struct NowPlayingScreen: View { @Environment(\.palette) private var base @Environment(\.dismiss) private var dismiss @State private var panel = NpPanel.Art - /// How far the screen is being dragged down to close it. - @State private var drop: CGFloat = 0 + /// How far the screen is being dragged down to close it. Kept out of the view's own state so a + /// drag only moves the screen (DropOffset) instead of rebuilding all of Now Playing each frame. + @State private var drop = DropState() /// Docked beside the hinge the pane is narrow, so the controls pack tighter. Full screen /// (folded or any other iPhone) uses the roomy layout across the whole window. private var tight: Bool { docked } @@ -144,7 +153,6 @@ struct NowPlayingScreen: View { .padding(.top, docked ? 4 : tight ? 14 : 20) .padding(.bottom, runsLow ? 0 : tight ? 4 : 8) .frame(maxWidth: .infinity, maxHeight: .infinity) - .coordinateSpace(.named("np")) .background(c.bg.ignoresSafeArea()) .overlay(alignment: .top) { // Stands in for the sheet's grabber: tap or drag down to close. @@ -154,7 +162,7 @@ struct NowPlayingScreen: View { .gesture(screenDrag(header: true)) } } .onGeometryChange(for: CGFloat.self) { $0.size.height } action: { screenH = $0 } - .offset(y: drop) + .modifier(DropOffset(state: drop)) // Drag down from the top strip (or the song header) to close, so it never fights the // stem faders. Swipe up anywhere on the art for the queue. .simultaneousGesture(screenDrag(), including: panel == .Art ? .all : .subviews) @@ -170,7 +178,7 @@ struct NowPlayingScreen: View { switch panel { case .Art: ArtPanel(thumb: track.thumb, playing: g.playback.playWhenReady, inset: header ? artInset : 12, leading: folded && !docked && !ui.split && g.settings.foldedArtLeft, edge: hPad).contentShape(Rectangle()) - .onGeometryChange(for: CGRect.self) { $0.frame(in: .named("np")) } action: { artFrame = $0 } + .onGeometryChange(for: CGRect.self) { $0.frame(in: .global) } action: { if drop.y == 0 { artFrame = $0 } } case .Mixer: VStack(spacing: 0) { if header { mini(track) }; MixerPanel(spread: folded) } case .Queue: VStack(spacing: 0) { if header { mini(track) }; QueuePanel(close: { show(.Queue) }) } case .Lyrics: VStack(spacing: 0) { if header { mini(track) }; LyricsPanel(track: track) } @@ -298,18 +306,18 @@ struct NowPlayingScreen: View { } private func screenDrag(header: Bool = false) -> some Gesture { - DragGesture(minimumDistance: 20, coordinateSpace: .named("np")) + DragGesture(minimumDistance: 20, coordinateSpace: .global) .onChanged { v in let dy = v.translation.height let top = fromTop(v, header: header) - drop = !docked && top && dy > 0 && dy > abs(v.translation.width) ? dy : 0 + drop.y = !docked && top && dy > 0 && dy > abs(v.translation.width) ? dy : 0 } .onEnded { v in let dy = v.translation.height let vertical = abs(dy) > abs(v.translation.width) let top = fromTop(v, header: header) if !docked && top && vertical && (dy > 120 || v.predictedEndTranslation.height > 300) { dismiss(); return } - withAnimation(.spring(duration: 0.3, bounce: 0.1)) { drop = 0 } + withAnimation(.spring(duration: 0.3, bounce: 0.1)) { drop.y = 0 } // Never from the stems: a slightly upward fader drag or scroll there kept opening the queue. if !docked && vertical && dy < -50 && panel != .Mixer && g.settings.swipeUpQueue { withAnimation(.spring(duration: 0.38, bounce: 0.12)) { panel = .Queue } diff --git a/ios/project.yml b/ios/project.yml index 387ee8c..b3e4cd7 100644 --- a/ios/project.yml +++ b/ios/project.yml @@ -9,7 +9,7 @@ settings: # iOS needs a plain number for the bundle version; the label is what the app and releases show. MARKETING_VERSION: "0.10.1" VERSION_LABEL: "0.10.1" - CURRENT_PROJECT_VERSION: "57" + CURRENT_PROJECT_VERSION: "58" # Dev builds override these (build-ipa.sh dev) so they install next to the release app. APP_ID: org.cdnutter.stemify APP_NAME: Stemify