diff --git a/ios/Stemify/App/StemifyApp.swift b/ios/Stemify/App/StemifyApp.swift index c6eeeb2..2cb0dae 100644 --- a/ios/Stemify/App/StemifyApp.swift +++ b/ios/Stemify/App/StemifyApp.swift @@ -34,13 +34,13 @@ final class AppDelegate: NSObject, UIApplicationDelegate { enum Orientation { nonisolated(unsafe) static var mask: UIInterfaceOrientationMask = .allButUpsideDown - @MainActor static func lock(_ upright: Bool) { - let m: UIInterfaceOrientationMask = upright ? .portrait : .allButUpsideDown + /// Folded Duo: portrait only. Unfolded Duo: landscape only. Anything else turns freely. + @MainActor static func lock(_ m: UIInterfaceOrientationMask) { guard m != mask else { return } mask = m for case let scene as UIWindowScene in UIApplication.shared.connectedScenes { scene.keyWindow?.rootViewController?.setNeedsUpdateOfSupportedInterfaceOrientations() - if upright { scene.requestGeometryUpdate(.iOS(interfaceOrientations: .portrait)) { _ in } } + if m != .allButUpsideDown { scene.requestGeometryUpdate(.iOS(interfaceOrientations: m)) { _ in } } } } } diff --git a/ios/Stemify/UI/Nav.swift b/ios/Stemify/UI/Nav.swift index ed401a1..80a14f9 100644 --- a/ios/Stemify/UI/Nav.swift +++ b/ios/Stemify/UI/Nav.swift @@ -131,13 +131,24 @@ final class Ui { duo = true UserDefaults.standard.set(true, forKey: "duoSeen") } - Orientation.lock(folded) + lockOrientation() + } + + /// Split (unfolded) goes landscape at once. Portrait waits a moment and checks again, so a + /// frame without a hinge reading mid-rotation can't throw an unfolded phone back upright. + private func lockOrientation() { + if split { Orientation.lock(.landscape); return } + guard folded else { Orientation.lock(.allButUpsideDown); return } + Task { @MainActor in + try? await Task.sleep(for: .milliseconds(400)) + if self.folded { Orientation.lock(.portrait) } + } } func setSplit(_ on: Bool) { guard on != split else { return } split = on - Orientation.lock(folded) + lockOrientation() if on { nowPlayingOpen = false } diff --git a/ios/project.yml b/ios/project.yml index 01ee3da..18402ad 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.9.0" VERSION_LABEL: "0.9.0" - CURRENT_PROJECT_VERSION: "34" + CURRENT_PROJECT_VERSION: "35" # Dev builds override these (build-ipa.sh dev) so they install next to the release app. APP_ID: org.cdnutter.stemify APP_NAME: Stemify