跳至正文
OpenAgentSkill
浏览已开放 · 目录记录日期 2026-11-21 · 自动更新和账户服务暂时关闭。
设计与 UI

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 · 已有静态检查记录

安装与使用

运行命令前先阅读来源与依赖说明。复制命令不会自动安装或执行。

npx skills add Kimeur/duology --skill duo-transitions

技能说明


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:

ChangeWindowSize classUIKit coordinatorSwiftUI transaction
Open466 × 678 → 951 × 669 pt, other displaycompact → 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 0no animation
Close951 × 669 → 466 × 678 pt, other displayregular → compact, 25 to 70 ms before the new sizenot animated, duration 0no animation
Partially openno changeno changeno callthe fold region turns active once the hinge settles
Rotatewidth and height swapvertical class flips on the closed phoneanimated, 0.3 sno 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

  1. 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).
  2. 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.
  3. So read the size class, or the view's size, in body and build the layout from it. The layout then changes in the very update that brings the new size class.
  4. Opt in with 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.
  5. Opt out below an animation: .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.
  6. 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
阅读完整来源 ↗