Pager
A pager presents related content as separate pages within the same area. It suits collections where people move between distinct items or steps while keeping each page’s content together.
Use pager to keep a fixed set
of page slots alive while changing which page is selected.
Add to your app
This control is included in day-pieces
and re-exported through day::prelude::*. No additional crate or control feature is required.
Selection and lifetime
pager(state, busy, pages, settled) takes two signals, a vector of AnyPiece pages, and a
callback. PagerState
contains the ordered slot identities, selected slot, and presentation epoch. The order indexes
the fixed page vector. Changing the order or selection preserves the pages’ reactive scopes.
On UIKit, Android, and ArkUI, native paging gestures update busy and call the supplied callback with the settled slot
when a page settles. Increment the epoch when changing the presentation; stale completions
are rejected. Defer replacing slot contents until busy is false.
Other toolkits use a composed container. Only the selected slot in the active order is shown; inactive pages remain mounted, with their native subtree hidden from input and accessibility. This fallback supports programmatic selection but supplies no swipe gesture.
day::pager::support() reports Native or Emulated after the runtime starts. A dayscript
select event uses the logical position in the current order, while settled callbacks use the
stable slot identity. Applications should use the callback to update their selected state.
Progress
let progress = Signal::new(0.0);
column((
pager(state, busy, pages, settle).progress(progress),
page_dots(pages_len, progress),
))
.progress(binding)
follows the pager’s position in reading order, in pages: 0.0 is the first page and 1.5 is
halfway from the second to the third. A page indicator drawn from it tracks the finger.
Where Cap::PagerProgress is Native, the pager writes the position continuously while a
page is dragged, at most once per display frame. Everywhere else the value steps to the
selected page’s position when the selection changes, so the same indicator still shows the
right page.
| Toolkit | Progress |
|---|---|
| UIKit | Native: the page view controller’s own scroll view, observed |
| Android | Native: the pager’s onPageScrolled, once per frame and once at rest |
| ArkUI | Native: the swiper’s content-scroll event, a whole page when it settles |
| AppKit | steps with the selection (composed pager) |
| GTK | steps with the selection (composed pager) |
| Qt | steps with the selection (composed pager) |
| WinUI | steps with the selection (composed pager) |
| Web | steps with the selection (composed pager) |
The navigation guide covers route and back-stack presentation. A pager does not create routes or manage navigation history.