/duology-design:duo-transitionsfrom duology-design
Guides implementing smooth transitions for iPhone Duo fold/unfold/rotation events using SwiftUI and UIKit animation APIs. Use when screen flashes, jumps, or reloads during resize.
Ships in duology-design. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
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.
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 |
withAnimation puts an animation in the transaction of a state change you make. A fold is not your state change. The system resizes the window and updates horizontalSizeClass; 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 runs body inside UIKit's 0.3 s animation.body and build the layout from it. The layout then changes in the very update that brings the new size class.animation(_:value:). When value changes 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..animation(nil, value:) for a subtree, transaction(_:) with $0.animation = nil for one leaf (Apple says to use it on leaf views), and contentTransition(.identity) to stop a text or symbol cross-fade while its frame still moves. Measured: both opt-outs stopped the opt-in.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 Reduce Motion.
.animation(reduceMotion ? nil : .smooth(duration: 0.3), value: isWide)
}
}
Open and close move your window to the other display, and nothing animates unless you ask. With the opt-in above, SwiftUI moves each view from where it sat in the old window to its new place. On open, the closed layout starts in the left part of the inner display, about as wide as the outer display, and grows into the open layout. That follows from how SwiftUI interpolates; we have not recorded it (unverified).
duo-patterns, displacement).// Bad: a second source of truth, and wrong at launch.
struct NowPlayingScreenCopy: View {
@Environment(\.horizontalSizeClass) private var widthClass
@State private var isWide = false // a copy of the size class
var body: some View {
let layout = isWide ? AnyLayout(HStackLayout()) : AnyLayout(VStackLayout())
layout {
Artwork()
PlaybackControls()
}
.onChange(of: widthClass) { _, newClass in
withAnimation(.smooth) { isWide = newClass == .regular }
}
}
}
.animation(_:value:), so lateness is not the problem.onChange without initial: true never ran; two values that can disagree; and a second body pass on every fold.DispatchQueue.main.asyncAfter, Task.sleep before a state change, or an animation started in onAppear: each animates after the resize, so people see the window change and then the content move. One measured exception isn't an animation: long text that reflows while the margins arrive late needs a scroll back to its saved paragraph after the width settles (duo-continuity section 4, the gallery's fold transition screen).onGeometryChange(for:of:action:). Return a small value (a column count, a fold flag), write it in one cheap action, and key the animation on it. Measured: on the two opens from closed portrait, its action ran in the same millisecond as the size-class update. On the open from the closed phone held sideways, it ran about 16 ms after it, once the width changed.AnyLayout, ArrangementView or one container, and give ForEach stable IDs. A branch on size class, a ViewThatFits that swaps children, or an .id fed by layout creates new views. New views can't move from their old frame: they fade or pop, and lose their state (AnyLayout, WWDC21 Demystify SwiftUI, duo-continuity).body. In UIKit, change layout inside the coordinator's alongside block.duo-patterns, displacement).duo-continuity).| You see | Usual cause | Fix |
|---|---|---|
| A blank or white frame | A background that differs by size class, or a view rebuilt before it has content | One background for every size; stable identity |
| A spinner or placeholder | A fetch in onAppear or .task that runs again because the view was rebuilt, or .task(id:) keyed on size | Load once, in a model (duo-continuity) |
| Images blink | AsyncImage rebuilt, so it starts empty and loads again | Stable identity; keep loaded images in a model or cache |
| Everything fades in | onAppear { withAnimation { opacity = 1 } } on a layout view | No appearance animation on views a fold rebuilds |
| The list jumps to the top | New identity, or a saved offset restored | ScrollPosition by item ID (duo-continuity) |
| UIKit cells flash | reloadData() or new child view controllers on a trait change | Invalidate the layout inside the coordinator |
Full code for each, and the measured transaction rules: references/swiftui.md.
| Need | Pattern |
|---|---|
| Stacked closed, side by side open | AnyLayout and .animation(_:value:), above |
| A pane that only exists open | if isWide inside a container that never changes, .transition(.opacity) |
| One picture that changes container (mini player artwork into a player pane) | matchedGeometryEffect on that stateless element only |
| Grid columns | Stable ForEach IDs, the animation keyed on the column count |
| Controls off the fold | FoldGeometry and .animation(.smooth, value: fold), from duo-patterns |
| Text that changes with the size | .contentTransition(.identity), or .interpolate for a size change of the same string |
| A part that must snap | .animation(nil, value:) on it, under the animated parent |
| Check what a change hands a view | AnimationProbe, a debug-only Animatable modifier |
import UIKit
final class PlayerViewController: UIViewController {
private var tallConstraints: [NSLayoutConstraint] = []
private var wideConstraints: [NSLayoutConstraint] = []
override func viewWillTransition(to size: CGSize, with coordinator: any UIViewControllerTransitionCoordinator) {
super.viewWillTransition(to: size, with: coordinator)
let isWide = size.width > size.height // decide from the size you are handed
coordinator.animate(alongsideTransition: { _ in
self.applyLayout(isWide: isWide) // same views, new constraints
self.view.layoutIfNeeded() // rotation: rides the system's animation
})
}
private func applyLayout(isWide: Bool) {
NSLayoutConstraint.deactivate(isWide ? tallConstraints : wideConstraints)
NSLayoutConstraint.activate(isWide ? wideConstraints : tallConstraints)
}
}
viewWillTransition(to:with:) runs before the size changes. Always call super. Blocks you pass to animate(alongsideTransition:completion:) run in the transition's own animation context.isAnimated false with duration 0, so the layout lands at once, together with the resize.reloadData() there. Keep the top item in view as duo-continuity shows.layoutSubviews of the view that lays out around the fold. UIKit runs that pass again when the fold turns active or inactive (measured in duo-postures). Don't trigger layout from UIHingeInteraction: when folding, the status changes 0.7 to 0.9 s before the region does. Work out the place on every pass, because a resize moves it too. Animate only when the fold changed and the window kept its size, with UIView.animate(_:changes:completion:) (iOS 18), which takes a SwiftUI Animation. It is declared in SwiftUI, so the file needs import SwiftUI.accessibilityReduceMotion, and accessibilityPrefersCrossFadeTransitions from iOS 26.4. UIKit UIAccessibility.isReduceMotionEnabled and UIAccessibility.prefersCrossFadeTransitions.extension Animation {
/// The animation for a layout change caused by a fold or a resize.
/// Nil under Reduce Motion: views take their new place at once.
static func resize(reduceMotion: Bool) -> Animation? {
reduceMotion ? nil : .smooth(duration: 0.3)
}
}
Measured: a transition with its own .animation(_:) ran its full length on a size-class change that carried no animation. So .transition(.opacity.animation(.easeInOut(duration: 0.2))) still fades a new pane when the layout animation is nil.
.smooth spring needs no extra code.body free of sorting, filtering, formatting and image decoding. Don't put a GeometryReader in every row. Use lazy stacks for long content.CADisplayLink: set preferredFrameRateRange, pace by targetTimestamp, and add CADisableMinimumFrameDurationOnPhone to Info.plist, or iPhone stays at its default rate for it. Code: references/performance.md.maximumFramesPerSecond = 60 (device facts). It can't show 120 Hz or hitches.| Don't animate | Why | Instead |
|---|---|---|
| Scroll position, or a feed moving between halves | Scrolling content already adapts; moving it breaks continuity | Anchor by item ID; let it reflow |
| Sheets, alerts, menus, bars, split view columns | The system moves them already; a second motion fights it | Nothing |
| The raw window size | It arrives in several steps per fold (measured); each one retargets | A discrete key: width class, column count, fold state |
| Layout from the hinge angle | A continuous stream, meant for effects | Reserved regions and arrangements |
| First appearance after a fold | Reads as a reload | Nothing; a short fade only for a pane that is new |
| A different background or font size per display | A flash, and text that cross-fades | One background; the same type size |
| Position, size and style of one control together | Hard to follow | Move it; keep its look |
| Zoom, 3D or blur on resize | Uncomfortable, and Reduce Motion asks you not to | A plain move or a fade |
Until Duology has run on hardware, its metadata.verified says device: no. Say so in your own review notes.
xcrun simctl io <UDID> recordVideo --display=primary-1 --force open.mov, press Open, then stop it with Ctrl-C. Use --display=primary for Closed. Step through it frame by frame. Look for a blank frame, a pop then a glide, a jump to the top, a control that vanishes and comes back.AnimationProbe (references/swiftui.md) to see whether a change reaches a view animated.withAnimation in onChange(of: horizontalSizeClass) that copies the size class into @State.animation(_:value:) keyed on proxy.size, a width or a CGSize; a long or bouncy spring on a size-class changeif sizeClass == .compact { A } else { B } with the same views in both branches; .id(sizeClass)DispatchQueue.main.asyncAfter, Task.sleep or onAppear animations after a size changereloadData() in viewWillTransition(to:with:) or a trait handler; code that expects the trait change before the size change, or after itaccessibilityReduceMotion or isReduceMotionEnabled check next to custom motionbody; no copy of the size class in @State.AnyLayout, ArrangementView or one container; stable ForEach IDs; no .id fed by layout..animation(_:value:) is keyed on a discrete value, never on the raw size..animation(nil, value:), a leaf transaction, or contentTransition(.identity).duo-continuity).animate(alongsideTransition:completion:); no reloadData() on a resize; no assumed order of trait and size changes.body does no heavy work; custom display links use preferredFrameRateRange and targetTimestamp.What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub kimeur/duology --plugin duology-design8 skills in this plugin
/duo-accessibilityMakes iPhone Duo apps work with VoiceOver, Dynamic Type, Reduce Motion, Increase Contrast, hardware keyboards, Switch Control and Voice Control on both displays. Use it when VoiceOver reads two panes row by row or loses its place after the phone folds or unfolds, when text truncates or clips on the 5.4-inch outer display at large text sizes, when a hinge effect or resize animation ignores Reduce Motion, when colours fail contrast, when keyboard shortcuts or focus don't work, or when you add accessibility labels, identifiers or audits. Covers accessibilityElement(children: .contain), accessibilitySortPriority, AccessibilityFocusState with a delayed move after a size-class change, AnyLayout and ViewThatFits reflow with isAccessibilitySize, ScaledMetric, accessibilityReduceMotion with onHingeChange, colorSchemeContrast, keyboardShortcut, accessibilityInputLabels, modifiers before .position, Accessibility Inspector, performAccessibilityAudit and XCUIDevice voiceOverService UI tests on the iPhone Duo simulator./duo-design-reviewReviews screenshots, simulator captures and Figma frames for iPhone Duo, Apple's foldable, against a 15-point checklist (letterboxing, state lost on fold and unfold, sizing from UIScreen.main, text or buttons in the fold via reservedRegions .division and .occlusion, odd grid columns, vertical toolbars with symbols and titles, tabletop and book layouts with ArrangementView overlay, camera preview rotation, outer display feature parity, multiple windows with UIWindowScene.ActivationAction, transitions, 44 pt touch targets, hardware keyboard, drag and drop) and writes findings with severity, rule, where and fix. Use it when someone asks to critique, audit or review a design, mockup, concept or Dribbble shot for the foldable, the outer display or the inner display, or asks what breaks when the phone is closed, open, partly folded like a book, propped on a table, in Split View or under Picture in Picture./duo-design-systemDesign tokens and a drop-in SwiftUI token module for iPhone Duo, Apple's foldable, that adapt by size class instead of by device. Covers a 4-point spacing scale, system margins and gutters with a wider gap at the fold, even-column layout grids (4 compact, 8 regular) with spans, one type scale with Dynamic Type for the 5.4-inch outer and 7.6-inch inner display, Liquid Glass usage and legibility (glassEffect, GlassEffectContainer, regular vs clear, dimming, tint), ConcentricRectangle and containerShape for corners, 44 pt touch targets, and light, dark and Increase Contrast colours with a contrast check. Use when you set up spacing, grids, fonts, corners, glass or colours, build a design system, theme or tokens for an iPhone Duo app, or turn a two-frame Figma design into code./duo-ergonomicsPuts controls where hands can reach them on iPhone Duo, Apple's foldable iPhone: one-handed on the closed phone, two hands on the open display, the book grip, and hands-free on a table. Use it when you decide where a primary action, a floating button, player controls or a custom control strip goes; when buttons sit at the top centre of the open display, on the fold or out of thumb reach; when you check thumb zones or reachability; when you design for left-handed people or right-to-left languages; or when touch targets are small. Covers why bars move to the side edge, toolbarVerticalEdge and verticalBarEdge (read them; right to left changes the name, not the side), visibilityPriority for bottom-bar actions, a ThumbCorner modifier for floating controls, an in-app hand preference, ArrangementView with the overlay style to put controls in the bottom half, reservedRegions(kind: .division) to keep targets off the fold, and 44 pt hit regions with frame(minWidth:minHeight:) and contentShape on the label./duo-patternsPicks and builds layout patterns for iPhone Duo, Apple's foldable iPhone, in SwiftUI - list-detail, supporting pane, two-page, dual view, extended canvas, feed reflow with even columns, tabs to sidebar, and displacement off the fold. Use it when you design or fix a screen for the outer display and the inner display, when content or buttons land in the fold, or when choosing between NavigationSplitView, inspector, ArrangementView (split and overlay styles), TabView with sidebarAdaptable and defaultTabBarPlacement, and reserved regions (division, occlusion, includeInactive)./duo-posturesDesigns iPhone Duo screens for every pose Apple shows: closed on the outer display, open flat (wide or tall), partly folded like a book, propped on a table like a laptop (tabletop), standing like a tent, and open and turned around (flipped, rear cameras facing the user). Use it when a screen must work half folded, when you build a tabletop media player or video call (video on top, the same controls below the fold), a book-pose layout with two regions, or a hinge effect. There is no posture API: read size classes and the .division reserved region (active only when partly folded) with FoldGeometry and FoldRegionsLayout, and keep onHingeChange and UIHingeInteraction for effects, with Reduce Motion and accessibility rules.Other plugins' skills for the same job