# Reader

> Hand the glasses a page of text and it reads itself, line by line, at the wearer's speed.

Source: https://docs.dev.glasslyos.com/app-devs/core-concepts/reader/

The Reader shows long text without scrolling. It marks one line and moves
down the text at the wearer's reading speed: the marked line stays just above
the middle, read lines dim, and a status row shows the title, how far the
wearer is, the speed and the time left. Reddit reads posts and comments with
it, and News reads stories.

```typescript
import {openReader} from "@glassly/miniapp/reader";

const reader = openReader(session, {
  title: story.headline,
  details: `${story.source} · ${story.age}`,
  sections: [{text: story.summary, stop: {title: "End of story", tap: {label: "next story", action: "next"}}}],
  leaveLabel: "back to the headlines",
});

reader.onEvent((event) => {
  if (event.type === "action" && event.action === "next") openStory(index + 1);
  if (event.type === "closed") showHeadlines();
});
```

Call it from the background side. It needs no manifest permission. While it is
open it draws the glasses and listens to touches, so skip your own touch
handling while `reader.isOpen` and draw your screen again when it closes.

## Text and stops

`sections` are read in order. Each takes `text`, an optional `label` drawn
above it, an optional `status` that replaces the title in the status row, and
an optional `stop`: an end screen after that section with a heading and what a
tap does. A tap without an `action` reads on into the next section, so Reddit
stops after the post ("tap top comments (12)") and reads the comments after a
tap. The last section always ends on an end screen.

`hold: {action, label}` makes hold emit your action anywhere in the Reader.
`reader.toast(text)` shows a 2-second message such as "★ Saved".
`reader.update({sections})` adds text that arrives later without moving the
wearer's place. `start: {part, percent}` opens at a saved place: use the
`percent` from the Reader's `progress` events.

## Gestures

| The wearer wants to | They do |
|---|---|
| Pause or resume | tap |
| Back or forward a line | swipe up / swipe down while reading |
| Slower or faster | swipe up / swipe down while paused, 20 wpm a step |
| Your hold action | hold |
| Your end-screen action | tap at the end |
| Leave the Reader | double tap, or swipe left on a Meta Neural Band |

The Reader claims `double_tap` while it is open, so the first double tap
leaves the Reader and the next leaves your app.

## The wearer's speed

Wearers have one reading speed for all of Glassly, along with starting by
itself, a beat at paragraph ends and the highlight style. A speed change on
the glasses becomes their speed everywhere. Your app never stores it; the
Reader applies it. These are platform settings any miniapp may read and
change, and the wearer edits them on the phone page of an app that reads: add
a Reading section with `followReadingSettings` from `@glassly/miniapp/reader`
in the background and the UI kit's `<ReadingSection>` on the page. See
[reading settings](https://docs.dev.glasslyos.com/app-devs/reference/system-apis.md#reading-settings).

The full reference is in the SDK's
[reader.md](https://github.com/tetramo-labs/glassly/blob/dev/sdk/docs/reader.md).
