duo-reading
Builds reading and document screens for iPhone Duo, Apple's foldable: one page on the closed outer display, two facing pages split at the fold when the phone is open and held wide or folded like a book, and in tabletop the page above the fold with page turns below it. Use when you build an e-reader, a long-form or PDF viewer, notes beside a document, or when a reader loses its place on fold, unfold, rotation or a Dynamic Type change. Covers TextKit 1 pagination (NSLayoutManager, NSTextContainer) that keeps the place as a character offset, PagedReader with FoldGeometry and reservedRegions(kind: .division, options: .includeInactive), notes that move between the trailing region and a sheet, Dynamic Type reflow, text selection that stays inside one page (iOS 27 Text range selection, a UITextView edit menu Add to Notes action, drag), PDFKit two-up centred on the fold, and Apple Pencil, which Apple says comes later in 2026 (what it will support is unverified).
Kimeur · 已有静态检查记录
安装与使用
运行命令前先阅读来源与依赖说明。复制命令不会自动安装或执行。
npx skills add Kimeur/duology --skill duo-reading技能说明
name: duo-reading description: "Builds reading and document screens for iPhone Duo, Apple's foldable: one page on the closed outer display, two facing pages split at the fold when the phone is open and held wide or folded like a book, and in tabletop the page above the fold with page turns below it. Use when you build an e-reader, a long-form or PDF viewer, notes beside a document, or when a reader loses its place on fold, unfold, rotation or a Dynamic Type change. Covers TextKit 1 pagination (NSLayoutManager, NSTextContainer) that keeps the place as a character offset, PagedReader with FoldGeometry and reservedRegions(kind: .division, options: .includeInactive), notes that move between the trailing region and a sheet, Dynamic Type reflow, text selection that stays inside one page (iOS 27 Text range selection, a UITextView edit menu Add to Notes action, drag), PDFKit two-up centred on the fold, and Apple Pencil, which Apple says comes later in 2026 (what it will support is unverified)." metadata: verified: "Xcode 27.1 (27A9275), iOS 27.1 simulator, device: no" sources: "https://github.com/Kimeur/duology/blob/main/reference/sources.md"
duo-reading
Reading suits iPhone Duo: one page when closed, two facing pages when open, like a book. This skill builds that, keeps the reader's place through every fold, and puts notes, selection and PDFs in the right region.
Load neighbours when the task needs them: duo-patterns (the two-page pattern and its measured fold frames), duo-continuity (state through a fold), duo-postures (book and tabletop), duo-accessibility (Dynamic Type, VoiceOver), duo-layout (reserved regions in depth).
Labels: measured means we ran it in a probe app on the iPhone Duo simulator (Xcode 27.1, iOS 27.1, 20 Oct 2026); details in references/measurements.md. Unverified means we could not confirm it. Everything else links to Apple. "Book" and "tabletop" are Duology's words for Apple's "partially folded, like a book" and "seated on a table like a laptop"; no API reports them.
Rules
- Scrolling text may cross the fold; paged text splits at it. Apple says articles, feeds and documents that scroll don't need to move away from the fold (talk 111463, talk 111466). A page is not scrolling content: give each page its own region.
- The place is a character offset, never a page number. Page breaks change with every fold, rotation and text size. The offset of the first character on screen doesn't.
- Paginate again after every size or text size change, once the size settles. Then show the page that holds the offset.
- Never skip unread text. A spread starts on an even page. After any change, the page holding the offset is on screen, even if the offset falls mid-page.
- One page or two by the fold, not by device. Two pages only when a top-to-bottom fold crosses the reader, or on a wide regular-width view without a fold. Use size class and
.division, neverUIScreen.main, idiom or orientation (prepare page). - Page turns are buttons in the system bottom bar, which stays off the fold on its own (talk 111466). Add a VoiceOver scroll action. Never turn pages from the hinge: folds happen by accident.
- Notes go on the trailing side of the fold when there is room, in a sheet otherwise. The text lives in a model, so moving it loses nothing.
- A selection lives inside one page. Don't promise selection across the fold. Offer Add to Notes and drag instead.
- Dynamic Type reflows the pages. Build the text at the reader's size and paginate again; the offset keeps the place.
- No Pencil-only features yet. Apple has announced Apple Pencil (USB-C) for iPhone Duo later in 2026 (Newsroom). Build markup that works with a finger.
What the reader does in each pose
| Pose | Reader (measured, inside a NavigationStack) | Pages | Notes |
|---|---|---|---|
| Closed | 382 × 620 pt | one | sheet |
| Closed, sideways (tent) | not measured | one, wide | sheet |
| Open, flat, held wide | 867 × 611 pt (the bar takes 84 pt) | two, split at the fold line | trailing region |
| Book | 867 × 611 pt, fold active | two, the fold's frame between them | trailing region |
| Open, flat, held tall | 669 × 787 pt | one tall page | sheet |
| Tabletop | 669 × 835 pt, fold active across | one, above the fold; page turns below | sheet |
| Split View | not measured | one | sheet |
The fold frame stays put when the phone folds; only isActive changes (duo-patterns two-page measurements). So flat and book get the same pages, and folding doesn't paginate again (measured).
Paginate by character offset
PageBreaks holds character ranges, one per page. Paginator fills page-sized TextKit 1 containers until the text runs out. Pages render with the same engine, so a page never overflows (NSLayoutManager, NSTextContainer).
import SwiftUI
import UIKit
/// Where each page starts and ends, as character ranges in the chapter.
/// A place in the text is a character offset, so it survives any new page size.
nonisolated struct PageBreaks: Equatable, Sendable {
var ranges: [NSRange] = []
/// The page that holds a character offset (the last page if the offset is past the end).
func page(containing offset: Int) -> Int {
ranges.firstIndex { NSMaxRange($0) > offset } ?? max(ranges.count - 1, 0)
}
}
阅读完整来源 ↗