iOS: unfolded upright never splits, always turns to landscape; orientation request re-checked until it takes
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
566c5f7e8f
commit
5868430f8a
4 files changed
+26
-11
No files matched your search
@@ -202,7 +202,9 @@ private struct DuoPane<Content: View>: View {
|
||||
|
||||
var body: some View {
|
||||
GeometryReader { geo in
|
||||
let cut = Self.cut(geo)
|
||||
let hinge = Self.cut(geo)
|
||||
// Unfolded upright (hinge across) never splits: the app turns to landscape instead.
|
||||
let cut = hinge?.vertical == true ? hinge : nil
|
||||
let flip = duoSwapEnabled && swap && cut?.vertical == true
|
||||
let layout = cut?.vertical == false ? AnyLayout(VStackLayout(spacing: cut?.gap ?? 0)) : AnyLayout(HStackLayout(spacing: cut?.gap ?? 0))
|
||||
layout {
|
||||
@@ -227,6 +229,7 @@ private struct DuoPane<Content: View>: View {
|
||||
// The hinge gap shows whatever is behind; paint it so the two sides read as one.
|
||||
.background(p.bg.ignoresSafeArea())
|
||||
.animation(.spring(duration: 0.4, bounce: 0.1), value: flip)
|
||||
.onChange(of: hinge != nil, initial: true) { _, on in ui.setUnfolded(on) }
|
||||
.onChange(of: cut != nil, initial: true) { _, on in ui.setSplit(on) }
|
||||
}
|
||||
}
|
||||
@@ -250,6 +253,10 @@ private struct DuoPane<Content: View>: View {
|
||||
let screenW = (UIApplication.shared.connectedScenes.first as? UIWindowScene)?.screen.bounds.width
|
||||
let half = ((screenW ?? size.width) / 2 - geo.frame(in: .global).minX).rounded()
|
||||
c = Cut(vertical: true, first: half - 12, gap: 24, second: size.width - half - 12)
|
||||
} else if UIDevice.current.userInterfaceIdiom == .phone, size.width >= 500, size.height >= 700 {
|
||||
// Unfolded but still upright: only marks the phone as unfolded so it turns to landscape.
|
||||
let half = (size.height / 2).rounded()
|
||||
c = Cut(vertical: false, first: half - 12, gap: 24, second: size.height - half - 12)
|
||||
}
|
||||
guard let c else { return nil }
|
||||
// A region that doesn't leave usable room on both sides isn't a hinge worth splitting at.
|
||||
|
||||
Reference in new issue
Block a user