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

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

  1. 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.
  2. 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.
  3. Paginate again after every size or text size change, once the size settles. Then show the page that holds the offset.
  4. 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.
  5. 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, never UIScreen.main, idiom or orientation (prepare page).
  6. 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.
  7. 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.
  8. A selection lives inside one page. Don't promise selection across the fold. Offer Add to Notes and drag instead.
  9. Dynamic Type reflows the pages. Build the text at the reader's size and paginate again; the offset keeps the place.
  10. 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

PoseReader (measured, inside a NavigationStack)PagesNotes
Closed382 × 620 ptonesheet
Closed, sideways (tent)not measuredone, widesheet
Open, flat, held wide867 × 611 pt (the bar takes 84 pt)two, split at the fold linetrailing region
Book867 × 611 pt, fold activetwo, the fold's frame between themtrailing region
Open, flat, held tall669 × 787 ptone tall pagesheet
Tabletop669 × 835 pt, fold active acrossone, above the fold; page turns belowsheet
Split Viewnot measuredonesheet

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)
    }
}

阅读完整来源 ↗