Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3ec9b043e3 |
No files matched your search
@@ -6,6 +6,36 @@ enum NpPanel { case Art, Mixer, Queue, Lyrics }
|
|||||||
/// The close drag's offset. Only DropOffset reads it, so dragging re-renders just the offset.
|
/// The close drag's offset. Only DropOffset reads it, so dragging re-renders just the offset.
|
||||||
@Observable final class DropState { var y: CGFloat = 0 }
|
@Observable final class DropState { var y: CGFloat = 0 }
|
||||||
|
|
||||||
|
/// ProMotion only runs as fast as someone asks. A plain drag asks nothing, and the 30 fps meters and
|
||||||
|
/// bars then set the pace, so the close drag crawled. This display link asks for 120 Hz while held.
|
||||||
|
@MainActor final class FrameBoost: NSObject {
|
||||||
|
static let shared = FrameBoost()
|
||||||
|
private var link: CADisplayLink?
|
||||||
|
private var stopGen = 0
|
||||||
|
|
||||||
|
func start() {
|
||||||
|
stopGen += 1
|
||||||
|
guard link == nil else { return }
|
||||||
|
let l = CADisplayLink(target: self, selector: #selector(tick))
|
||||||
|
l.preferredFrameRateRange = CAFrameRateRange(minimum: 80, maximum: 120, preferred: 120)
|
||||||
|
l.add(to: .main, forMode: .common)
|
||||||
|
link = l
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Keeps the boost through the spring back or the cover's slide down.
|
||||||
|
func stop(after: Double = 0.6) {
|
||||||
|
stopGen += 1
|
||||||
|
let gen = stopGen
|
||||||
|
DispatchQueue.main.asyncAfter(deadline: .now() + after) { [weak self] in
|
||||||
|
guard let self, gen == self.stopGen else { return }
|
||||||
|
self.link?.invalidate()
|
||||||
|
self.link = nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@objc private func tick() {}
|
||||||
|
}
|
||||||
|
|
||||||
private struct DropOffset: ViewModifier {
|
private struct DropOffset: ViewModifier {
|
||||||
let state: DropState
|
let state: DropState
|
||||||
func body(content: Content) -> some View { content.offset(y: state.y) }
|
func body(content: Content) -> some View { content.offset(y: state.y) }
|
||||||
@@ -310,9 +340,12 @@ struct NowPlayingScreen: View {
|
|||||||
.onChanged { v in
|
.onChanged { v in
|
||||||
let dy = v.translation.height
|
let dy = v.translation.height
|
||||||
let top = fromTop(v, header: header)
|
let top = fromTop(v, header: header)
|
||||||
drop.y = !docked && top && dy > 0 && dy > abs(v.translation.width) ? dy : 0
|
let y = !docked && top && dy > 0 && dy > abs(v.translation.width) ? dy : 0
|
||||||
|
if y > 0 { FrameBoost.shared.start() }
|
||||||
|
if y != drop.y { drop.y = y }
|
||||||
}
|
}
|
||||||
.onEnded { v in
|
.onEnded { v in
|
||||||
|
FrameBoost.shared.stop()
|
||||||
let dy = v.translation.height
|
let dy = v.translation.height
|
||||||
let vertical = abs(dy) > abs(v.translation.width)
|
let vertical = abs(dy) > abs(v.translation.width)
|
||||||
let top = fromTop(v, header: header)
|
let top = fromTop(v, header: header)
|
||||||
|
|||||||
+1
-1
@@ -9,7 +9,7 @@ settings:
|
|||||||
# iOS needs a plain number for the bundle version; the label is what the app and releases show.
|
# iOS needs a plain number for the bundle version; the label is what the app and releases show.
|
||||||
MARKETING_VERSION: "0.10.1"
|
MARKETING_VERSION: "0.10.1"
|
||||||
VERSION_LABEL: "0.10.1"
|
VERSION_LABEL: "0.10.1"
|
||||||
CURRENT_PROJECT_VERSION: "58"
|
CURRENT_PROJECT_VERSION: "59"
|
||||||
# Dev builds override these (build-ipa.sh dev) so they install next to the release app.
|
# Dev builds override these (build-ipa.sh dev) so they install next to the release app.
|
||||||
APP_ID: org.cdnutter.stemify
|
APP_ID: org.cdnutter.stemify
|
||||||
APP_NAME: Stemify
|
APP_NAME: Stemify
|
||||||
|
|||||||
Reference in new issue
Block a user