Skip to main content

pull_refresh

Function pull_refresh 

Source
pub fn pull_refresh() -> PullRefreshBuilder
Expand description

§pull_refresh

Wraps a scrollable child and adds pull-to-refresh interaction for lists and feeds.

§Usage

Use for feeds or lists that need to reload data when pulled from the top.

§Parameters

  • modifier — optional modifier chain applied to the pull-refresh container.
  • on_refresh — optional callback invoked when a refresh is triggered.
  • refreshing — whether a refresh is currently in progress.
  • enabled — whether pull-to-refresh interactions are enabled.
  • refresh_threshold — optional pull distance required to trigger a refresh.
  • refreshing_offset — optional resting offset while refreshing.
  • indicator_size — optional indicator container size.
  • indicator_background_color — optional indicator background color.
  • indicator_content_color — optional indicator content color.
  • indicator_track_color — optional indicator track color.
  • indicator_stroke_width — optional indicator stroke width.
  • indicator_elevation — optional indicator elevation.
  • controller — optional external refresh controller.
  • indicator — optional custom indicator content; uses indicator_size and follows the controller position.
  • child — optional content rendered inside the pull-refresh container.

§Examples

use tessera_components::theme::{MaterialTheme, material_theme};
use tessera_components::{
    column::column,
    modifier::ModifierExt as _,
    pull_refresh::{PullRefreshController, pull_refresh},
    scrollable::ScrollableController,
    text::text,
};
use tessera_ui::{Modifier, layout::layout, remember, tessera};

#[tessera]
fn demo() {
    material_theme()
        .theme(|| MaterialTheme::default())
        .child(|| {
            let refresh_controller = remember(PullRefreshController::new);
            let scroll = remember(ScrollableController::new);
            pull_refresh()
                .on_refresh(|| {})
                .refreshing(false)
                .controller(refresh_controller)
                .child(move || {
                    layout()
                        .modifier(Modifier::new().vertical_scroll(scroll))
                        .child(move || {
                            column().children(|| {
                                text("Pull down to refresh");
                            });
                        });
                });
        });
}