/duology-features:duo-readingfrom duology-features
Builds reading and document screens for iPhone Duo foldable: one page on closed display, two facing pages when open. Covers TextKit 1 pagination, PDFKit two-up, Dynamic Type reflow, text selection, and notes beside documents.
Ships in duology-features. 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.
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.
.division, never UIScreen.main, idiom or orientation (prepare page).| 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).
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)
}
}
enum Paginator {
/// Lays the text out in page-sized containers until it runs out (TextKit 1).
static func pageBreaks(for text: NSAttributedString, pageSize: CGSize) -> PageBreaks {
guard text.length > 0, pageSize.width >= 44, pageSize.height >= 44 else { return PageBreaks() }
let storage = NSTextStorage(attributedString: text)
let layout = NSLayoutManager()
storage.addLayoutManager(layout)
var ranges: [NSRange] = []
while NSMaxRange(ranges.last ?? NSRange()) < text.length {
let container = NSTextContainer(size: pageSize)
container.lineFragmentPadding = 0 // PageTextView uses the same value
layout.addTextContainer(container)
let glyphs = layout.glyphRange(for: container)
let characters = layout.characterRange(forGlyphRange: glyphs, actualGlyphRange: nil)
guard characters.length > 0 else { break } // not even one line fits
ranges.append(characters)
}
return PageBreaks(ranges: ranges)
}
/// Body text at the reader's Dynamic Type size. Rebuild it when the size changes.
static func styledText(_ plain: String, size: DynamicTypeSize) -> NSAttributedString {
let traits = UITraitCollection(preferredContentSizeCategory: UIContentSizeCategory(size))
let paragraph = NSMutableParagraphStyle()
paragraph.lineSpacing = 3
paragraph.paragraphSpacing = 10
paragraph.hyphenationFactor = 0.7
return NSAttributedString(string: plain, attributes: [
.font: UIFont.preferredFont(forTextStyle: .body, compatibleWith: traits),
.foregroundColor: UIColor.label,
.paragraphStyle: paragraph,
])
}
}
PagedReader renders pages with PageTextView, a non-scrolling TextKit 1 UITextView. Full code, with the tabletop layout and every pitfall: references/paged-reader.md. It needs FoldGeometry from references/fold-geometry.md.
import SwiftUI
// requires: Chapter, PagedReader (references/paged-reader.md)
@available(iOS 27.1, *)
struct BookScreen: View {
let chapter: Chapter
// The place, saved per window. It also comes back after the system ends the app.
@SceneStorage("reader.offset") private var offset = 0
var body: some View {
NavigationStack {
PagedReader(chapter: chapter, offset: $offset)
.navigationTitle(chapter.id)
.navigationBarTitleDisplayMode(.inline)
}
}
}
What the reader does, and why:
.frame(minWidth: 0, maxWidth: .infinity, minHeight: 0, maxHeight: .infinity). With only maxWidth: .infinity, the frame grew to fit its fixed-width pages and the measured size fed back into the page widths: once it measured 951 pt, the reader stayed 951 pt wide in tabletop and on the closed phone, and pages ran off both edges (measured).task(id:) cancels the wait when a newer size arrives.Open, the notes take the facing page's place on the trailing side of the fold. Closed, held tall or in tabletop, they open in a sheet. Code: references/notes-beside.md.
@Observable model above the layout. The sheet and the pane are two different editors, so keyboard focus doesn't move with the notes; the text does.dynamicTypeSize with UIFont.preferredFont(forTextStyle:compatibleWith:) and UIContentSizeCategory(_:). Don't let UITextView adjust fonts on its own (adjustsFontForContentSizeCategory = false): the pages would grow but the breaks wouldn't.Two pages are two text views, and a selection stays inside one of them. Details and code: references/selection-and-pencil.md.
Text with textSelection(.enabled) shows selection handles and selects a range. In iOS 26 and earlier it offered a menu for the whole text (textSelection(_:)).PageTextView adds Add to Notes to the edit menu with textView(_:editMenuForTextInRanges:suggestedActions:) (iOS 26). Measured by UI test: a touch and hold on a page selected a word, and Add to Notes put the quote in the notes: beside the page in book, in the sheet closed and in tabletop. Put the action first; appended last, it sat on the menu's second page.UIDragInteraction.isEnabledByDefault and a new UITextView's textDragInteraction?.isEnabled were both true on the iPhone Duo simulator. PageTextView sets it anyway. Dropping text into a SwiftUI TextEditor on a device is unverified.PDF pages don't reflow, so the place is a page index. PDFView in .twoUp centres the spread in its own frame, so give it a frame centred on the fold (measured: the pages then met at the fold's centre). Turn displaysAsBook off: on, the cover sat alone across the fold (measured). Code and the UIKit version of the reader: references/pdf-and-uikit.md.
drawingPolicy = .anyInput so fingers draw today (PKCanvasView).Use the same Paginator. Lay out two UITextView(usingTextLayoutManager: false) pages in layoutSubviews from reservedRegions(kind: .division, options: .includeInactive); UIKit runs it again when the fold turns active or inactive (measured in duo-postures). SpreadView in references/pdf-and-uikit.md. Don't choose a UIPageViewController spine from the interface orientation: the inner display ignores your supported orientations (talk 111461).
In Device Hub: Closed, Open, Partially Open, and Rotate Right for tabletop (Device Hub).
-UIPreferredContentSizeCategoryName UICTContentSizeCategoryAccessibilityXXXL). The place holds.@SceneStorage, never a page index or scroll offset.minWidth: 0 and minHeight: 0, so its measured size can't feed back.@available or if #available when the app deploys lower.What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
foldable-ui, ereader, pdf-viewer, textkit, paginated-reading
8 skills in this plugin
/duo-app-intentsApp Intents on iPhone Duo: AppIntent, AppEntity with EntityStringQuery, OpenIntent with TargetContentProvidingIntent and onAppIntentExecution (UISceneAppIntent and AppIntentSceneDelegate in UIKit) to show the right item in the right pane or window, handlesExternalEvents to pick the window, intents that work with the phone closed (supportedModes .background, IntentDialog, ProvidesDialog, isVoiceOnly), onscreen awareness when two panes are visible (appEntityIdentifier, appEntityIdentifier(forSelectionType:), NSUserActivity), App Shortcuts (AppShortcutsProvider) and AppIntentsTesting runs on the Duo simulator in each pose. Use when an app adds Siri, Shortcuts, Spotlight or Apple Intelligence actions, when an intent opens the wrong pane or an extra window, or when an intent must work while the phone is closed./duo-cameraCamera capture on iPhone Duo, Apple's foldable. Use when an app takes photos or video, runs a video call or shows a camera preview, and must work closed (outer display), open (inner display), partly folded (book, tabletop), open and turned around (flipped) and through fold and unfold. Covers the virtual front camera (.builtInWideAngleCamera or .builtInUltraWideCamera at .front; shared features only, up to 1080p at 60 fps, no depth), the physical front cameras (.builtInOuterUltraWideCamera, .builtInInnerUltraWideCamera), choosing a camera by the way it faces with AVCaptureDeviceDirectionCoordinator (AVKit) and AVCaptureDeviceDescriptor, mirroring a rear-camera selfie, AVCaptureDevice.RotationCoordinator across displays, the square front sensor and dynamicAspectRatio, a subject preview on the outer display with CameraCaptureAccessory, tabletop hands-free capture, and Split View interruptions. The simulator has no camera: the code typechecks; capture is unverified on a device.npx claudepluginhub kimeur/duology --plugin duology-featuresOther plugins' skills for the same job