[dependencies]
fission = "0.15.1"
fission-onboarding = "0.1"
use fission::prelude::*;
use fission_onboarding::{OnboardingAnchor, OnboardingFlow, OnboardingHost, OnboardingStep};
#[derive(Clone, Debug, Default)]
struct State { finished: bool }
impl GlobalState for State {}
#[fission_reducer(FinishTour)]
fn finish_tour(state: &mut State) { state.finished = true; }
#[derive(Clone)]
struct App;
impl From<App> for Widget {
fn from(_: App) -> Widget {
let (ctx, view) = fission::build::current::<State>();
let finish = ctx.bind(FinishTour, reduce_with!(finish_tour));
let target = WidgetId::explicit("demo.create");
let flow = OnboardingFlow::new("first-use", 1, vec![OnboardingStep {
id: "create".into(),
anchor: target,
route: None,
title: "Make your first item".into(),
body: "Use this button to start. You can revisit the tour later.".into(),
}]).expect("valid tour");
let mut children = widgets![OnboardingAnchor {
id: target,
child: Button {
child: Some(Text::new("Create item").into()),
on_press: Some(finish.clone()),
..Default::default()
}.into(),
}];
if !view.state().finished {
children.push(OnboardingHost::new(
"first-use", flow, 0, finish.clone(), finish,
).into());
}
Column { children, ..Default::default() }.into()
}
}
fn main() {
DesktopApp::<State, _>::new(App).run().expect("start app");
}
cargo run --example minimal --features desktop-demo
let mut host = OnboardingHost::new(
"first-task", flow, state.step,
ctx.bind(NextStep, reduce_with!(next_step)),
ctx.bind(FinishTour, reduce_with!(finish_tour)),
);
host.continue_enabled = state.created_item.is_some();
host.on_skip = Some(ctx.bind(SkipTour, reduce_with!(skip_tour)));
host.labels.progress = format!("Step {} of 3", state.step + 1).into();
host.style = my_app_onboarding_style(&view.env().theme);
cargo run --example guided_task --features desktop-demo
Concern | Owner |
|---|---|
Spotlight, anchored callout, buttons, accessible dialog | This crate |
Target widgets and stable IDs | Your app |
Text, translation, colours, spacing | Your app |
Step conditions, navigation, scrolling | Your app |
Progress storage and restart policy | Your app |
[dependencies]
fission = "0.15.1"
fission-onboarding = "0.1"
use fission::prelude::*;
use fission_onboarding::{OnboardingAnchor, OnboardingFlow, OnboardingHost, OnboardingStep};
#[derive(Clone, Debug, Default)]
struct State { finished: bool }
impl GlobalState for State {}
#[fission_reducer(FinishTour)]
fn finish_tour(state: &mut State) { state.finished = true; }
#[derive(Clone)]
struct App;
impl From<App> for Widget {
fn from(_: App) -> Widget {
let (ctx, view) = fission::build::current::<State>();
let finish = ctx.bind(FinishTour, reduce_with!(finish_tour));
let target = WidgetId::explicit("demo.create");
let flow = OnboardingFlow::new("first-use", 1, vec![OnboardingStep {
id: "create".into(),
anchor: target,
route: None,
title: "Make your first item".into(),
body: "Use this button to start. You can revisit the tour later.".into(),
}]).expect("valid tour");
let mut children = widgets![OnboardingAnchor {
id: target,
child: Button {
child: Some(Text::new("Create item").into()),
on_press: Some(finish.clone()),
..Default::default()
}.into(),
}];
if !view.state().finished {
children.push(OnboardingHost::new(
"first-use", flow, 0, finish.clone(), finish,
).into());
}
Column { children, ..Default::default() }.into()
}
}
fn main() {
DesktopApp::<State, _>::new(App).run().expect("start app");
}
cargo run --example minimal --features desktop-demo
let mut host = OnboardingHost::new(
"first-task", flow, state.step,
ctx.bind(NextStep, reduce_with!(next_step)),
ctx.bind(FinishTour, reduce_with!(finish_tour)),
);
host.continue_enabled = state.created_item.is_some();
host.on_skip = Some(ctx.bind(SkipTour, reduce_with!(skip_tour)));
host.labels.progress = format!("Step {} of 3", state.step + 1).into();
host.style = my_app_onboarding_style(&view.env().theme);
cargo run --example guided_task --features desktop-demo
Concern | Owner |
|---|---|
Spotlight, anchored callout, buttons, accessible dialog | This crate |
Target widgets and stable IDs | Your app |
Text, translation, colours, spacing | Your app |
Step conditions, navigation, scrolling | Your app |
Progress storage and restart policy | Your app |