duo-transitions
Makes fold, unfold, partial fold and rotation on iPhone Duo, Apple's foldable, feel like one app instead of a reload. Use when a screen flashes, blinks, jumps, reloads, pops or moves its controls as the phone opens or closes, or when writing or reviewing SwiftUI or UIKit code that animates a resize: AnyLayout, stable ForEach IDs, matchedGeometryEffect, geometryGroup, .animation(_:value:), transaction, withAnimation, contentTransition, accessibilityReduceMotion, viewWillTransition(to:with:), animate(alongsideTransition:completion:), UIView.animate with a SwiftUI spring, and 120 Hz ProMotion frame budgets.
Kimeur · Static checks on file
Installation
Read the source and dependencies before running a command. Copying does not install or execute anything.
npx skills add Kimeur/duology --skill duo-transitionsAbout this skill
name: duo-transitions description: "Makes fold, unfold, partial fold and rotation on iPhone Duo, Apple's foldable, feel like one app instead of a reload. Use when a screen flashes, blinks, jumps, reloads, pops or moves its controls as the phone opens or closes, or when writing or reviewing SwiftUI or UIKit code that animates a resize: AnyLayout, stable ForEach IDs, matchedGeometryEffect, geometryGroup, .animation(_:value:), transaction, withAnimation, contentTransition, accessibilityReduceMotion, viewWillTransition(to:with:), animate(alongsideTransition:completion:), UIView.animate with a SwiftUI spring, and 120 Hz ProMotion frame budgets." metadata: verified: "Xcode 27.1 (27A9275), iOS 27.1 simulator, device: no" sources: "https://github.com/Kimeur/duology/blob/main/reference/sources.md"
duo-transitions
Opening or closing iPhone Duo resizes your app, the same way a person resizes it in iPhone Mirroring (Tech Talk 111461). People do it often, so Apple asks for an app that stays predictable and consistent inside and out (Tech Talk 111466). This skill makes the change read as the same screen taking a new shape, not a new screen loading.
Load other skills for neighbouring work: duo-continuity (scroll, selection, typing and playback that must survive), duo-patterns (layouts, and displacement off the fold), duo-layout (size classes, reserved regions), duo-navigation (bars move on their own).
Labels: measured means we ran it on the iPhone Duo simulator (iOS 27.1), pressing Device Hub's pose buttons; see references/evidence.md. Unverified means we could not confirm it. Device only means the simulator can't show it. Everything else comes from Apple's pages, linked inline. Full source list: reference/sources.md.
What each change hands your app
All measured:
| Change | Window | Size class | UIKit coordinator | SwiftUI transaction |
|---|---|---|---|---|
| Open | 466 × 678 → 951 × 669 pt, other display | compact → regular. From closed portrait: same update as the new size (2 runs). From closed sideways: about 16 ms before it (1 run) | not animated, duration 0 | no animation |
| Close | 951 × 669 → 466 × 678 pt, other display | regular → compact, 25 to 70 ms before the new size | not animated, duration 0 | no animation |
| Partially open | no change | no change | no call | the fold region turns active once the hinge settles |
| Rotate | width and height swap | vertical class flips on the closed phone | animated, 0.3 s | no animation |
- A fold keeps your app running: one root view, no relaunch, and the scene never left the active state.
- On open and close the system adds no motion to your layout. Any motion there is motion you add.
- Sizes arrive in steps. On open, a full-width view went 382 → 466 → 951 → 867 pt wide within 50 to 250 ms, as safe area insets changed around the resize.
- The trait change and the size transition come in no fixed order. Never write code that expects one first.
How SwiftUI animates a resize
- Every update runs in a transaction. When an animatable value changes (a frame, an offset, an opacity), SwiftUI checks the transaction for an animation. With one, it interpolates from the old value to the new one. Without one, the value jumps (WWDC23 Explore SwiftUI animation).
withAnimationputs an animation in the transaction of a state change you make. A fold is not your state change. The system resizes the window and updateshorizontalSizeClass; none of your code runs first, so there is nothing to wrap. Measured: open, close and rotation all reached SwiftUI with no animation, even though a rotation runsbodyinside UIKit's 0.3 s animation.- So read the size class, or the view's size, in
bodyand build the layout from it. The layout then changes in the very update that brings the new size class. - Opt in with
animation(_:value:). Whenvaluechanges in an update, the views below the modifier animate in that update. Key it on a discrete value: the width class, a column count, the fold's active state. Never on the raw size. Measured: the opt-in interpolated on open, close, rotation and partial fold; a probe without it jumped. - Opt out below an animation:
.animation(nil, value:)for a subtree,transaction(_:)with$0.animation = nilfor one leaf (Apple says to use it on leaf views), andcontentTransition(.identity)to stop a text or symbol cross-fade while its frame still moves. Measured: both opt-outs stopped the opt-in. - Frames animate at the leaf views that draw. An opt-out on a container also stops that container's frame.
geometryGroup()makes a group animate as one frame.
import SwiftUI
struct NowPlayingScreen: View {
@Environment(\.horizontalSizeClass) private var widthClass
@Environment(\.accessibilityReduceMotion) private var reduceMotion
var body: some View {
// Read in body, so the arrangement changes in the update that brings the size class.
let isWide = widthClass == .regular
let layout = isWide
? AnyLayout(HStackLayout(alignment: .center, spacing: 24))
: AnyLayout(VStackLayout(spacing: 16))
layout {
Artwork() // the same view in both layouts: it moves, it doesn't reload
PlaybackControls()
}
// Opt in: short, no bounce, keyed on a discrete value. Nil under
Read the complete source ↗