duo-patterns
Picks 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).
Kimeur · 已有静态检查记录
安装与使用
运行命令前先阅读来源与依赖说明。复制命令不会自动安装或执行。
npx skills add Kimeur/duology --skill duo-patterns技能说明
name: duo-patterns description: Picks 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). metadata: verified: "Xcode 27.1 (27A9275), iOS 27.1 simulator, device: no" sources: "https://github.com/Kimeur/duology/blob/main/reference/sources.md"
Duo layout patterns
Use this skill to choose a layout pattern for a screen on iPhone Duo, then build it. Every pattern has a reference file with when to use it, closed and open behaviour, the Apple APIs, rules, pitfalls, a SwiftUI recipe that typechecks against the iOS 27.1 SDK, and a screen in the Duology gallery app.
Read the reference for the pattern you pick before you write code. For bars and toolbars, load duo-navigation. For size classes, safe areas and UIKit layout depth, load duo-layout. For keeping state through a fold, load duo-continuity.
Ground rules for every pattern
- Design for two size classes, not for poses. Compact width for the outer display, regular width for the inner display. Let the layout grow; don't design one layout per way of holding the phone (HIG, talk 111466).
- One app on both displays. Same features and same state closed and open. Open may add one level of hierarchy, as Mail adds the message beside the list (HIG).
- System containers first.
NavigationSplitView,TabView,NavigationStack, sheets, alerts, menus and toolbar buttons already adapt to the fold (hub, talk 111463). - Nothing interactive in the fold. Scrolling content may cross it (talk 111466).
- Even columns whenever a fold crosses a grid, active or not (HIG, talk 111463).
- Small moves. Move only what must move. Don't swap in a different view tree when the window resizes; you lose scroll position, selection and typing (HIG).
- Arrangement placement. Navigation outside, content inside. Put an
ArrangementViewinside aNavigationStackor a tab. Never put a navigation container inside an arrangement, and never put an arrangement inside aListorScrollView. Don't nest it with aNavigationSplitVieweither way; Apple's pages disagree on that case, so see Combining patterns (talk 111463, HIG, hub). - No posture API exists. Lay out with size classes, the view's own size, arrangements and reserved regions. Use the hinge (
onHingeChange) for effects only (talk 111464). - No device checks. Never lay out from
UIScreen.main,userInterfaceIdiom, interface orientation or fixed sizes (prepare page).
What a layout can read
| Input | API | Use it for |
|---|---|---|
| Width class | @Environment(\.horizontalSizeClass) | One pane or two |
| The view's own size and shape | onGeometryChange(for:of:action:) | Wide or tall, column count |
| The fold | reservedRegions(kind: .division, options:) (iOS 27.1) | Where to split, where controls may not go |
| Cameras and the status bar corner | reservedRegions(kind: .occlusion, options:) | Keeping controls clear |
| System margins, per side | contentMargins(for: .container, edges:) (iOS 27.1) | Asymmetric margins next to a vertical bar |
| Is a tab sidebar available | isTabViewSidebarAvailable (iOS 27.0) | Hiding shortcuts the sidebar repeats |
Pick a pattern
Answer in order. The first yes is the screen's main pattern. If a later question is also a yes, read Combining patterns.
- Many top-level sections, information-dense? Tabs to sidebar, then pick a pattern for each tab.
- Two halves that must both show in every pose (two players, a before and after), or two people sharing the screen? None of these patterns: use
EvenSplitorFoldSplitLayoutfromduo-layout, andduo-shared-screen. A split arrangement can drop to its primary view alone, for example on the closed phone held sideways. - Items, each with its own detail that makes sense alone? List-detail.
- A second view that only m