شعار Duo Reading

Duo Reading

المجتمع
Kimeur
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
المستودعduology
اسم المهارةduo-reading
النجوم
40
التفريعات
2
الملفات المرفقة
6
الترخيصMIT
الروابط
  • تعليمات بصيغة Markdown

    ملف SKILL.md يُحمّله النموذج عند الحاجة، فلا يستهلك توكنات إلا عندما يَرِد طلب ذو صلة فعلًا.

  • تعمل مع أي نموذج لغوي كبير

    مهارات الذكاء الاصطناعي مكتوبة بصيغة Markdown وليست شيفرة خاصة بمزوّد معيّن، لذا تعمل مع GPT أو Claude أو Gemini أو Grok أو نموذج محلي.

  • الملفات المرفقة: 6

    نصوص برمجية وقوالب ومراجع يمكن للنموذج قراءتها أثناء عمله. الملفات للقراءة فقط ولا تُنفّذ أبدًا.

  • مفتوحة المصدر

    نشرها Kimeur على GitHub. اطّلع على المصدر قبل تثبيتها.

التثبيت

ثبّت مهارة الذكاء الاصطناعي Duo Reading في TypingMind لاستخدامها مع أي نموذج لغوي كبير، أو أضفها إلى وكيل ذكاء اصطناعي آخر يقرأ SKILL.md.

1

التثبيت في TypingMind

يُثبّت TypingMind المهارة مباشرةً من مجلدها على GitHub — فيقرأ SKILL.md، ويجمع ملفات الموارد في حزمة، ويحفظ النتيجة محليًا.

  1. افتح التطبيق وانتقل إلى «الإضافات» ثم «المهارات».
  2. اختر «تثبيت من GitHub».
  3. الصق رابط مجلد المهارة الموضّح أدناه وأكّد التثبيت.
    https://github.com/Kimeur/duology/tree/main/plugins/duology-features/skills/duo-reading
  4. فعّل المهارة في كل محادثة تريد إتاحتها فيها.
الإضافات ← المهارات ← إضافة مهارة ← من رابط GitHub، ثم الصق رابط المجلد واضغط على «متابعة».
2

التثبيت في وكيل ذكاء اصطناعي آخر

يمكن لأي وكيل ذكاء اصطناعي يقرأ تنسيق Agent Skills استخدام هذه المهارة — انسخ المجلد إلى مجلد المهارات الخاص بذلك الوكيل.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/Kimeur/duology.git /tmp/duology
mkdir -p .claude/skills
cp -r /tmp/duology/plugins/duology-features/skills/duo-reading .claude/skills/duo-reading
أعد تشغيل Claude Code بعد النسخ ليتعرّف على المهارة الجديدة.

استخدمها في TypingMind

فعّل Duo Reading في أي محادثة على TypingMind وسيتولى النموذج الباقي. تتضمن مطالبة النظام اسمها ووصفها، وبمجرد ورود طلب ذي صلة، يُحمّل النموذج التعليمات الكاملة تلقائيًا — فلا تحتاج إلى استدعائها يدويًا، ولا تستهلك أي توكنات حتى تُستخدم فعليًا.

يُحمّل النموذج مهارة Duo Reading تلقائيًا بمجرد ورود طلب ذي صلة بها.

تعمل مع أي نموذج ذكاء اصطناعي

مهارات الذكاء الاصطناعي هي تعليمات بصيغة Markdown وليست شيفرة خاصة بمزوّد معيّن، لذا لا ترتبط Duo Reading بالنموذج الذي كُتبت له. ثبّتها مرة واحدة في TypingMind واستخدمها مع GPT-5 أو Claude أو Gemini أو Grok أو DeepSeek أو Mistral أو Llama أو نموذج محلي تشغّله بنفسك — كل ذلك باستخدام مفاتيح API الخاصة بك.

  • تُحمَّل عند الحاجة فقط

    تتضمن مطالبة النظام الاسم والوصف فقط. وتُجلب التعليمات عند أول طلب ذي صلة، لذا لا تستهلك تعليمات المهارة أي توكنات ما دامت المهارة غير مستخدمة.

  • بدّل النماذج أثناء المحادثة

    لأن المهارة تعليمات وليست شيفرة، فإن تغيير النموذج لا يعطّلها — فالنموذج التالي يقرأ ملف SKILL.md نفسه.

تعليمات المهارة

هذا هو محتوى SKILL.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).

swift
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,
        ])
    }
}
  • Measured: with the place at character 20,000 of a 44,500-character chapter, the page on screen held it in every pose: closed page 22 of 48, open and book pages 23 and 24 of 50, tabletop page 22 of 48.
  • Measured: a 44,500-character chapter took 0.04 to 0.15 s to paginate on the simulator; 558,000 characters (a long novel) took 1.1 to 3.1 s in four runs. The simulator runs on the Mac's CPU. Paginate one chapter at a time. Device speed is unverified.
  • Spreads lose at most one page of position: after closing, the reader sees the leading page of the last spread. That is the price of never skipping text.

The reader

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.

swift
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:

  • Splits at the fold, not the middle. Held wide, the reader is 867 pt wide and the fold is at x = 455.5, 22 pt right of the reader's middle (measured).
  • Gives both pages the narrower region's size, so one pagination serves both sides.
  • Tabletop: the page above the fold, page turns below. A single tall page put text lines inside the active fold band (measured before the fix). Apple suggests content on top and controls on the stable base below when the phone sits on a table (talk 111463). The bottom bar hides there and the same buttons move into the bottom region.
  • Measures its size with .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).
  • Waits 200 ms for the size to settle. Opening the phone sent seven sizes in 0.2 s, and the reader paginated once, after the last (measured). task(id:) cancels the wait when a newer size arrives.

Document and notes side by side

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.

  • Measured: notes open on the closed phone showed as a sheet. Opening the phone dismissed the sheet and the notes appeared beside a single page in the leading region (455.5 pt wide). Closing it again brought the sheet back.
  • Trailing is where Apple moves alerts in book pose, because that is where they sit once the phone closes (talk 111463).
  • Keep the notes text, the open state and the reader's offset in one @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.
  • Where the keyboard appears in book pose and in tabletop is unverified. Check that the notes field stays visible.

Dynamic Type

  • Build fonts from the environment's 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.
  • Put the type size in the pagination key, next to the page size and the chapter. The offset stays.
  • Measured at the largest accessibility size: the place held in every pose, and a closed page held about 100 characters instead of about 900 at Large. Keep two pages in book pose anyway: each region is still about as wide as the closed page (331.5 pt against 342 pt, measured). Apple's typography guidance at large sizes is fewer columns, not text across the fold (HIG: Typography).

Text selection across panes

Two pages are two text views, and a selection stays inside one of them. Details and code: references/selection-and-pencil.md.

  • In iOS 27, a SwiftUI 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.
  • Drag works too. Measured: 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.
  • For long highlights, offer a scroll layout of the chapter in one text view.

PDFs and fixed layouts

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.

Apple Pencil (coming)

  • Apple says iPhone Duo will support Apple Pencil (USB-C) later in 2026, for notes, sketches and markup on either display (Newsroom). Which Pencil features work on iPhone Duo is unverified.
  • On iPad, that model has tilt and hover but no pressure, double tap or squeeze (Apple Pencil). Don't depend on them.
  • Use PencilKit with drawingPolicy = .anyInput so fingers draw today (PKCanvasView).
  • Never anchor ink to points on reflowing text: every fold moves the words. Store highlights as text ranges; keep ink for fixed pages such as PDFs and images.

UIKit

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

Test it

In Device Hub: Closed, Open, Partially Open, and Rotate Right for tabletop (Device Hub).

  1. Turn to a page in the middle of a chapter. Close, open, fold, rotate, close again. The same paragraph must be on screen each time.
  2. Book: no line of text and no button inside the fold frame.
  3. Tabletop: the page ends above the fold; page turns sit below it.
  4. Change Dynamic Type from the smallest size to AX5 (Xcode's Environment Overrides, or launch with -UIPreferredContentSizeCategoryName UICTContentSizeCategoryAccessibilityXXXL). The place holds.
  5. Open notes closed, then open the phone: notes move beside the page, text intact.
  6. Select text on a page, pick Add to Notes in every pose.
  7. VoiceOver: a three-finger swipe turns the page.

Checklist

  • The place is a character offset in a model or @SceneStorage, never a page index or scroll offset.
  • Pages paginate again after size, chapter and Dynamic Type changes, after the size settles.
  • One page closed; two pages only with a top-to-bottom fold or a wide regular-width view; split at the fold frame.
  • Tabletop: the page sits above the fold and the page turns below it.
  • The reader's frame uses minWidth: 0 and minHeight: 0, so its measured size can't feed back.
  • Spreads start on an even page; nothing unread is skipped after a fold.
  • Page turns are system bar buttons with labels, plus a VoiceOver scroll action; no hinge page turns.
  • Notes sit on the trailing side when open and in a sheet otherwise; their text lives in a model.
  • Selection offers Add to Notes; nothing promises selection across the fold.
  • PDF two-up is centred on the fold; ink is stored per fixed page, never on reflowing text.
  • iOS 27.1 APIs are behind @available or if #available when the app deploys lower.
  • Checked in Device Hub: Closed, Open wide and tall, book, tabletop, AX5 text size, right-to-left.

الملفات المرفقة

يقرأ النموذج هذه الملفات عند الحاجة ما دامت المهارة محمّلة. وهي متاحة للقراءة ولا تُنفّذ أبدًا.

الأسئلة الشائعة

ماذا تفعل مهارة الذكاء الاصطناعي 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(ki...

لماذا تستخدم Duo Reading على TypingMind؟

لأنك تثبّتها مرة واحدة وتستخدمها مع أي نموذج. مهارة Duo Reading عبارة عن نص Markdown وليست شيفرة خاصة بمزود بعينه، لذا تعمل المهارة نفسها مع GPT-5 أو Claude أو Gemini أو Grok أو نموذج محلي، ويمكنك تبديل النموذج أثناء المحادثة دون تعطّل المهارة. يعمل TypingMind بمفاتيح API الخاصة بك، فتدفع للمزودين مباشرةً بدلًا من اشتراك لكل مقعد، وتبقى مهاراتك ومحادثاتك في مساحة التخزين الخاصة بك.

كيف أثبّت Duo Reading في TypingMind؟

في TypingMind، افتح «الإضافات»، ثم «المهارات»، ثم اختر «التثبيت من GitHub» والصق https://github.com/Kimeur/duology/tree/main/plugins/duology-features/skills/duo-reading. يقرأ TypingMind ملف SKILL.md الخاص بالمهارة، ويجمع ملفاتها ويثبّتها كمهارة يمكنك تفعيلها لكل محادثة على حدة.

ما نماذج الذكاء الاصطناعي التي يمكنها استخدام Duo Reading؟

أي نموذج تربطه في TypingMind. مهارات الذكاء الاصطناعي عبارة عن تعليمات Markdown وليست شيفرة خاصة بمزود بعينه، لذا يمكن لكل من GPT وClaude وGemini وGrok والنماذج المحلية تحميل هذه المهارة عندما يتوافق الطلب معها.

كم نموذج ذكاء اصطناعي يمكنني استخدامه مع Duo Reading؟

أي عدد تريده. ما دام النموذج يدعم المهارات، يمكنك استخدام Duo Reading معه، سواء كان GPT أو Claude أو Gemini أو Grok أو DeepSeek أو Mistral أو Llama أو غيرها، وكل ذلك على TypingMind باستخدام مفاتيح API الخاصة بك.

هل مهارة الذكاء الاصطناعي Duo Reading مجانية؟

نعم. نشرها Kimeur على GitHub بموجب ترخيص MIT. لا تدفع إلا لمزود الذكاء الاصطناعي الخاص بك مقابل التوكنات التي تستخدمها.

ما هي مهارات الذكاء الاصطناعي؟

مهارة الذكاء الاصطناعي حزمة تعليمات قابلة لإعادة الاستخدام تعلّم نموذج الذكاء الاصطناعي كيفية تنفيذ مهمة محددة. وتتبع تنسيق Agent Skills المفتوح: ملف SKILL.md يتضمن اسمًا ووصفًا، إلى جانب أي نصوص برمجية أو قوالب أو ملفات مرجعية قد يحتاج إليها النموذج. لا يقرأ النموذج التعليمات إلا عندما يتوافق طلبك مع المهارة، لذا لا تترتب على المهارة المثبتة أي تكلفة حتى تُستخدم.

كيف تختلف مهارات الذكاء الاصطناعي عن الإضافات أو موصلات MCP؟

تمنح الإضافة أو موصل MCP النموذج أدوات جديدة يمكنه استدعاؤها، وهي شيفرة تُنفَّذ في مكان ما وتُرجع نتيجة. أما مهارة الذكاء الاصطناعي فتزوّد النموذج بالمعرفة ومنهجية العمل: كيفية التعامل مع مهمة، والخطوات التي ينبغي اتباعها، وما ينبغي أن تكون عليه المخرجات الجيدة. المهارات عبارة عن نصوص Markdown، لذا لا تحتاج إلى خادم أو مفتاح API أو بيئة تشغيل، وتعمل مع أي نموذج.

عرض الكل

أنشئ مساحة عملك للذكاء الاصطناعي الآن

اشترك في نشرتنا الإخبارية لتصلك أخبار الميزات الجديدة والهدايا القادمة 👇