Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Widget catalog

The framework crates are not yet published to crates.io (only the flui-cli tool is), so there is no docs.rs page for the widgets to link to yet — until there is, this page points at the source tree instead of listing every widget by name here (a hand-maintained list would go stale the moment a widget is added; the source directories do not). This page has no screenshots yet.

Controlled values: Slider and Disclosure

Slider and Disclosure report proposed values through on_changed; the parent decides whether to commit them. Their displayed and accessible state changes when the parent rebuilds with the new value. Without a callback, the control is disabled.

The view below keeps both values in signals its state is born with, reads them in build and writes them from the event callbacks, as in the first run counter:

#![allow(unused)]
fn main() {
use flui::prelude::*;

#[derive(Clone, StatefulView)]
struct SoundSettings;

struct SoundSettingsState {
    volume: Signal<f64>,
    expansion: Signal<ExpansionState>,
}

impl StatefulView for SoundSettings {
    type State = SoundSettingsState;

    fn create_state(&self, ctx: &dyn LifecycleContext) -> SoundSettingsState {
        SoundSettingsState {
            volume: ctx.signal(50.0),
            expansion: ctx.signal(ExpansionState::Collapsed),
        }
    }
}

impl ViewState<SoundSettings> for SoundSettingsState {
    fn build(&self, _view: &SoundSettings, ctx: &dyn BuildContext) -> impl IntoView {
        let volume = self.volume;
        let expansion = self.expansion;
        let range = match NumericRange::try_new(volume.get(ctx), 0.0, 100.0, 5.0) {
            Ok(range) => range,
            Err(error) => return Text::new(format!("Invalid volume range: {error}")).boxed(),
        };

        Column::new((
            Semantics::new().label("Volume").child(
                Slider::new(range).on_changed(move |ctx, proposed| volume.set(ctx, proposed)),
            ),
            Disclosure::new(
                expansion.get(ctx),
                Text::new("Details"),
                Text::new("Additional settings"),
            )
            .on_changed(move |ctx, proposed| expansion.set(ctx, proposed)),
        ))
        .boxed()
    }
}
}

NumericRange::try_new(value, min, max, step) returns a Result: every argument must be finite, the bounds must admit the current value, and step must be positive. The step governs keyboard and increment/decrement proposals; an admitted exact numeric value from an assistive setter is not rounded to a step boundary. A zero-span range is valid but inert for adjustments.

Give Disclosure a passive header such as Text; Disclosure owns header activation. Collapsing unmounts the body, removing its layout, input, focus and accessibility contributions. It does not guarantee retention of child-local state; keep data that must survive collapse in the parent. See Lifecycle for ownership.

Source, by crate

  • flui-widgets — the core, theme-independent catalog: layout (flex, stack, wrap, clip, physical model), scrolling, text, images, icons, animation/transitions, overlays, navigation, and the app-level container/app scaffolding. crates/flui-widgets/src/
  • flui-material — Material Design widgets (buttons, app bar, scaffold, cards, dialogs, navigation, form controls) built on flui-widgets plus ColorScheme/ThemeData, an official package on flui-sdk. packages/flui-material/src/
  • flui-cupertino — iOS-style widgets (buttons, nav bar, page/tab scaffold, theming) built on flui-widgets plus CupertinoTheme, an official package on flui-sdk. packages/flui-cupertino/src/

Once the framework crates publish, this page becomes a thin index into docs.rs instead of the source tree directly.