Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d6ba09f14b | ||
|
|
5959c8a347 | ||
|
|
1604a6b3e3 |
No files matched your search
+35
-20
@@ -137,45 +137,60 @@ final class Ui {
|
|||||||
lockOrientation()
|
lockOrientation()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Split (unfolded) goes landscape at once. Portrait waits a moment and checks again, so a
|
/// The Duo is never free to turn: folded is portrait only, unfolded is landscape only.
|
||||||
/// frame without a hinge reading mid-rotation can't throw an unfolded phone back upright.
|
/// Hinge readings flicker while the window settles (coming back from the background, mid
|
||||||
/// Back in the foreground: the phone may have been folded or unfolded meanwhile.
|
/// fold), so the lock only changes once a reading has held for a moment. Other iPhones turn freely.
|
||||||
/// The split/unfolded flags are from before the app left, so locking on them at once can force
|
private var lockGen = 0
|
||||||
/// landscape on a phone folded meanwhile. Free the rotation while away and decide again once
|
|
||||||
/// the window has settled to the screen it came back on.
|
|
||||||
func resumed() {
|
func resumed() {
|
||||||
|
lockOrientation()
|
||||||
|
if away { showPlayingFolded() }
|
||||||
|
away = false
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Leaves the lock as it is: freeing it let iOS turn the window while audio kept the app alive.
|
||||||
|
func backgrounded() { away = true }
|
||||||
|
|
||||||
|
private var away = false
|
||||||
|
|
||||||
|
/// Folded with something playing, the app comes back on Now Playing.
|
||||||
|
private func showPlayingFolded() {
|
||||||
|
guard folded, !nowPlayingOpen, AppGraph.shared.playback.current != nil else { return }
|
||||||
|
// Back from the background folded with something playing: Now Playing slides up as if
|
||||||
|
// swiped open, once the app's own opening animation has landed.
|
||||||
Task { @MainActor in
|
Task { @MainActor in
|
||||||
try? await Task.sleep(for: .milliseconds(300))
|
try? await Task.sleep(for: .milliseconds(180))
|
||||||
self.lockOrientation()
|
guard self.folded, !self.nowPlayingOpen, AppGraph.shared.playback.current != nil else { return }
|
||||||
|
self.nowPlayingOpen = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Folded stays locked upright: while audio plays the app lives on in the background and iOS
|
|
||||||
/// would turn the free window with the phone, so it came back sideways. Unfolding meanwhile is
|
|
||||||
/// still caught on return (upright unfolded marks the phone unfolded and turns it).
|
|
||||||
/// Unfolded frees rotation, so a phone folded meanwhile isn't held in landscape.
|
|
||||||
func backgrounded() {
|
|
||||||
if folded { Orientation.lock(.portrait) } else { Orientation.lock(.allButUpsideDown) }
|
|
||||||
}
|
|
||||||
|
|
||||||
private func lockOrientation() {
|
private func lockOrientation() {
|
||||||
if split || unfolded { Orientation.lock(.landscape); return }
|
guard duo || split || unfolded else { Orientation.lock(.allButUpsideDown); return }
|
||||||
guard folded else { Orientation.lock(.allButUpsideDown); return }
|
let want: UIInterfaceOrientationMask = (split || unfolded) ? .landscape : .portrait
|
||||||
|
lockGen += 1
|
||||||
|
let gen = lockGen
|
||||||
Task { @MainActor in
|
Task { @MainActor in
|
||||||
try? await Task.sleep(for: .milliseconds(400))
|
try? await Task.sleep(for: .milliseconds(450))
|
||||||
if self.folded { Orientation.lock(.portrait) }
|
guard gen == self.lockGen else { return }
|
||||||
|
let now: UIInterfaceOrientationMask = (self.split || self.unfolded) ? .landscape : .portrait
|
||||||
|
guard now == want else { return }
|
||||||
|
Log.shared.info("orient", "lock \(want == .landscape ? "landscape" : "portrait") split=\(self.split) unfolded=\(self.unfolded)")
|
||||||
|
Orientation.lock(want)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func setUnfolded(_ on: Bool) {
|
func setUnfolded(_ on: Bool) {
|
||||||
guard on != unfolded else { return }
|
guard on != unfolded else { return }
|
||||||
unfolded = on
|
unfolded = on
|
||||||
|
Log.shared.info("orient", "unfolded \(on)")
|
||||||
lockOrientation()
|
lockOrientation()
|
||||||
}
|
}
|
||||||
|
|
||||||
func setSplit(_ on: Bool) {
|
func setSplit(_ on: Bool) {
|
||||||
guard on != split else { return }
|
guard on != split else { return }
|
||||||
split = on
|
split = on
|
||||||
|
Log.shared.info("orient", "split \(on)")
|
||||||
lockOrientation()
|
lockOrientation()
|
||||||
if on {
|
if on {
|
||||||
nowPlayingOpen = false
|
nowPlayingOpen = false
|
||||||
|
|||||||
+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: "53"
|
CURRENT_PROJECT_VERSION: "56"
|
||||||
# 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