KiteDocViewState
Observable state + control surface of a KiteDocView.
Everything a navigation/zoom widget needs lives here, so widgets are just composables that take a KiteDocViewState. Place them inside the viewport (via KiteDocView's overlay slot), next to it, or anywhere else in your tree.
Reads (currentPage, zoom, panOffset…) are snapshot-state backed and recompose their readers automatically. Navigation suspends until finished; calls made before the state is attached to a composed KiteDocView are remembered and applied on attach.
Constructors
Opens at a saved reading position instead of a page number.
Opens at position, including the continuous layout's pixel offset.
Properties
Where the reader is. Always exact, even mid-layout, unlike a global page number which cannot exist until the pages before it are counted.
The slot the viewport rests on: the snapped page in paged mode, the page nearest the viewport centre in continuous mode.
The leading visible page and how many pixels have scrolled past its leading edge. Unlike currentLocation, this anchors the viewport edge, not its centre, so a continuous viewport can be restored without a jump. Reads observe scroll state. Paged and single-page layouts report zero. See KiteScrollPosition for the layout and zoom boundaries.
The form field that has the caret, or null when none has. A viewer shows the platform keyboard while it is set, and what the reader types goes through the document's scripts.
App-owned highlights, each with its own fill colour and its own optional margin marker. Painted over the page after searchHighlights, in list order, so later entries win where they overlap. Clear by assigning an empty list.
True once every chapter is laid out and pageCount is final.
True while text selection owns the pointer, and while the selection it produced is still on screen.
Pages laid out so far. While a book is still paginating this grows; show it as an approximate total until isComplete.
Fires on every selection change, including clearing (null).
Search hits to paint as translucent quads over their pages (colour: KiteDocViewColors.searchHighlight). Feed it from PdfDocument.search, EpubDocument.search or KiteStructuredText.search (quads are display-space, as both produce); clear it by assigning an empty list.
The active text selection, or null. Set by the long-press-drag gesture; observe via snapshot reads or onSelectionChange. The viewer never touches the clipboard itself. Read KiteTextSelection.text and copy in the app (see the sample's selection actions).
True only while the finger is still down on the long-press drag that is building the selection; false the moment it lifts.
Current zoom factor. 1 = fit. Bounded by KiteZoomSpec.minZoom/maxZoom.
Functions
Animates to slot page (coerced into range).
A position to save now and reopen with later. Survives a font size, page size or margin change: hand it to rememberKiteDocViewState.
The topmost app-owned highlight under a viewport tap, or null on unmarked paper. Uses the same display-space geometry as painting, including page rotation, zoom and pan. Search results are intentionally excluded: only highlights belong to the host's marks.
Maps a viewport point (the space gesture callbacks like onTap report in) to the page under it, or null when it lands on background/spacing.
The previous page in reading order, crossing back a chapter if needed.
Restores a page and scroll offset. Continuous layouts apply position's offset on their scroll axis; the other layouts navigate to its page. Calls before composition are retained for the initial list measurement.
Jumps to a saved reading position, laying out only its chapter.
Jumps to location, laying out its chapter first if needed.
Jumps to slot page (coerced into range) without animation.