Compare commits

..
2 changed files with 27 additions and 9 deletions

No files matched your search

+26 -8
View File
@@ -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 }
@@ -75,6 +84,8 @@ struct NowPlayingScreen: View {
@State private var ctlH: CGFloat = 0
/// The screen's height, for the strip at the top that a drag down closes from.
@State private var screenH: CGFloat = 0
/// Where the art sits on screen: folded, a drag down that starts on it closes Now Playing.
@State private var artFrame: CGRect = .zero
@Environment(\.verticalSizeClass) private var vSize
/// Folded iPhone Duo: the outer display keeps a status column down the right edge.
@State private var folded = false
@@ -151,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)
@@ -167,6 +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: .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) }
@@ -287,19 +299,25 @@ struct NowPlayingScreen: View {
}
/// Drag down to close: from the grabber or song header, or anywhere in the top tenth of the screen.
/// Folded, also from the art (only while it shows, so never over the stem dials).
private func fromTop(_ v: DragGesture.Value, header: Bool) -> Bool {
header || v.startLocation.y < max(screenH * 0.1, 56)
|| (folded && !docked && panel == .Art && artFrame.contains(v.startLocation))
}
private func screenDrag(header: Bool = false) -> some Gesture {
DragGesture(minimumDistance: 20)
DragGesture(minimumDistance: 20, coordinateSpace: .global)
.onChanged { v in
let dy = v.translation.height
let top = header || v.startLocation.y < max(screenH * 0.1, 56)
drop = !docked && top && dy > 0 && dy > abs(v.translation.width) ? dy : 0
let top = fromTop(v, header: header)
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 = header || v.startLocation.y < max(screenH * 0.1, 56)
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 }
+1 -1
View File
@@ -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: "56"
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