Build an interactive canvas for iOS

Arrange user-created inspection checks on the built-in canvas whilst keeping document positions separate from pan and zoom.
iOS

What you will build

Select and move stable inspection nodes without turning viewport gestures into changes to the plan's records.
Create real checks with allocated node identities, including duplicate titles
Decode actual canvas selection and move events into document state
Provide a labelled selection alternative and test native touch separately
Moving a card and moving the view are different operations. A dragged inspection check changes the plan's document data. Panning or zooming changes how we look at that plan; it should not rewrite the checks' positions.
We will build a small inspection-planning board with checks entered by the user. It starts empty on iOS and Web, supports stable node selection and movement, and offers a labelled selection list for people who do not want to target a small canvas card. Arranging a plan does not certify that an inspection has happened.

Create the app

Complete iOS setup first.
cargo install cargo-fission
fission init ios-build-an-interactive-canvas-for-ios
cd ios-build-an-interactive-canvas-for-ios
fission add-target ios --project-dir .
cargo add serde_yaml
The iOS and Web Fission features enable interactive canvas support. Keep the generated src/main.rs and replace the shared library below; no separate native scene is needed.

Run the finished example

fission run --target ios --project-dir .

1. Give every check a document identity

A node's ID is allocated when the user creates it, not when the list is rendered. Repeated titles remain distinct checks. The initial offset is only placement geometry; it is not identity and it is never recomputed after a drag.
The built-in InfiniteCanvas owns the pan/zoom interaction. The app owns the selected node and document bounds. A named card draws each node, whilst a small event reducer accepts selection and move updates from the actual canvas interaction payload.
{"id":"fission-tabs-1","tabs":[{"index":0,"label":"src/app.rs","value":"src-app-rs"},{"index":1,"label":"src/app/state.rs","value":"src-app-state-rs"},{"index":2,"label":"src/app/card.rs","value":"src-app-card-rs"},{"index":3,"label":"src/app/screen.rs","value":"src-app-screen-rs"},{"index":4,"label":"src/i18n.rs","value":"src-i18n-rs"},{"index":5,"label":"src/lib.rs","value":"src-lib-rs"},{"index":6,"label":"preview/lib.rs","value":"preview-lib-rs"},{"index":7,"label":"i18n/en-US.yaml","value":"i18n-en-us-yaml"},{"index":8,"label":"i18n/es-ES.yaml","value":"i18n-es-es-yaml"}]}
{"id":"fission-tabs-1","index":0,"label":"src/app.rs","value":"src-app-rs"}
mod card;
mod screen;
pub mod state;
pub use screen::PlanScreen;
pub use state::PlanState;
{"id":"fission-tabs-1","index":1,"label":"src/app/state.rs","value":"src-app-state-rs"}
use fission::prelude::*;

#[derive(Clone, Debug, PartialEq)]
pub struct PlanItem {
    pub id: u64,
    pub title: String,
    pub bounds: LayoutRect,
}
impl PlanItem {
    pub fn canvas_id(&self) -> CanvasNodeId {
        CanvasNodeId::from_u128(u128::from(self.id))
    }
}
#[derive(Clone, Debug, PartialEq)]
pub struct PlanState {
    pub items: Vec<PlanItem>,
    pub next_id: u64,
    pub selected: Option<u64>,
    pub locale: Locale,
}
impl Default for PlanState {
    fn default() -> Self {
        Self {
            items: Vec::new(),
            next_id: 1,
            selected: None,
            locale: Locale::from("en-US"),
        }
    }
}
impl GlobalState for PlanState {}

pub fn add_item(state: &mut PlanState, title: &str) -> bool {
    let title = title.trim();
    if title.is_empty() || title.chars().count() > 80 {
        return false;
    }
    let Some(next_id) = state.next_id.checked_add(1) else {
        return false;
    };
    let offset = (state.items.len() % 8) as f32 * 24.0;
    state.items.push(PlanItem {
        id: state.next_id,
        title: title.to_owned(),
        bounds: LayoutRect::new(offset, offset, 220.0, 132.0),
    });
    state.selected = Some(state.next_id);
    state.next_id = next_id;
    true
}

#[fission_reducer(EditPlan)]
pub fn edit_plan(state: &mut PlanState, cx: &mut ReducerContext<PlanState>) {
    let Some(event) = cx.input.canvas_interaction() else {
        return;
    };
    match event.kind {
        CanvasInteractionKind::SelectNode { node_id }
            if event.phase == CanvasInteractionPhase::Activate =>
        {
            state.selected = state
                .items
                .iter()
                .find(|item| item.canvas_id().0 == node_id)
                .map(|item| item.id);
        }
        CanvasInteractionKind::MoveNode { .. } if event.phase == CanvasInteractionPhase::Update => {
            for change in &event.node_changes {
                if let Some(item) = state
                    .items
                    .iter_mut()
                    .find(|item| item.canvas_id().0 == change.node_id)
                {
                    let bounds = change.after;
                    if bounds.x().is_finite() && bounds.y().is_finite() {
                        item.bounds = bounds;
                    }
                }
            }
        }
        _ => {}
    }
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn repeated_titles_still_have_distinct_stable_ids() {
        let mut state = PlanState::default();
        assert!(add_item(&mut state, "Inspect the seal"));
        assert!(add_item(&mut state, "Inspect the seal"));
        let first = state.items[0].canvas_id();
        state.items.reverse();
        assert_eq!(state.items[1].canvas_id(), first);
        assert_ne!(state.items[0].canvas_id(), first);
        assert!(!add_item(&mut state, " "));
    }
}
{"id":"fission-tabs-1","index":2,"label":"src/app/card.rs","value":"src-app-card-rs"}
use fission::prelude::*;

fission_component! {
    pub PlanCard<()> { props { title: String, selected: bool } }
    view(card, _state, cx) {
        let tokens = &cx.view.env().theme.tokens;
    } => Container(Column(gap: tokens.spacing.s, children: [
        Text(card.title.clone()).weight(tokens.typography.font_weight_semibold),
        Text(cx.tr(if card.selected { "plan.selected_card" } else { "plan.card_hint" })),
    ])).padding_all(tokens.spacing.m)
        .bg(if card.selected { tokens.colors.primary_subtle } else { tokens.colors.surface })
        .border(tokens.colors.border, 1.0).border_radius(tokens.radii.medium)
}
{"id":"fission-tabs-1","index":3,"label":"src/app/screen.rs","value":"src-app-screen-rs"}
use super::card::PlanCard;
use super::state::{add_item, edit_plan, EditPlan, PlanState};
use fission::prelude::*;

fission_component! {
    pub PlanScreen<PlanState> {
        state { draft: String = String::new(), attempted: bool = false }
    }
    view(form, state, cx) {
        let tokens = &cx.view.env().theme.tokens;
        let edit = with_reducer!(cx.build, EditPlan, edit_plan);
        let nodes: Vec<InfiniteCanvasNode> = state.items.iter().map(|item| {
            let mut node = InfiniteCanvasNode::new(
                item.canvas_id(), item.bounds,
                PlanCard::new(item.title.clone(), state.selected == Some(item.id)),
            );
            node.resizable = false;
            node
        }).collect();
        let selected_nodes: std::collections::BTreeSet<CanvasNodeId> = state.items.iter()
            .filter(|item| state.selected == Some(item.id)).map(|item| item.canvas_id()).collect();
        let error = (form.attempted && (form.draft.trim().is_empty() || form.draft.trim().chars().count() > 80))
            .then(|| cx.tr("plan.title_error"));
    } => SafeArea(child: Scroll(child: Container(Column(gap: tokens.spacing.m, children: [
        Text(cx.tr("plan.title")).size(tokens.typography.heading2_size),
        Text(cx.tr("plan.explanation")),
        Row(gap: tokens.spacing.s, children: [
            Button(child: Text(cx.tr("language.english")), key: "english",
                on_press: reduce { state.locale = Locale::from("en-US"); }),
            Button(child: Text(cx.tr("language.spanish")), key: "spanish",
                on_press: reduce { state.locale = Locale::from("es-ES"); }),
        ]),
        FormControl(label: Some(cx.tr("plan.new_item")), error: error, required: true,
            child: TextInput(value: form.draft.clone(), bind(on_input): to(form.draft))),
        Button(child: Text(cx.tr("plan.add")), key: "add-item", disabled: state.next_id == u64::MAX,
            on_press: reduce {
                form.attempted = true;
                if add_item(state, &form.draft) {
                    form.draft.clear();
                    form.attempted = false;
                }
            }),
        if state.items.is_empty() { Text(cx.tr("plan.empty")) },
        Container(InfiniteCanvas(
            id: Some(WidgetId::explicit("inspection.plan")),
            nodes: nodes,
            selected_nodes: selected_nodes,
            selection_policy: CanvasSelectionPolicy::Single,
            initial_transform: ViewportTransform::new(24.0, 24.0, 1.0),
            min_scale: 0.4,
            max_scale: 2.5,
            grid: Some(CanvasGrid::lines(32.0, tokens.colors.border, 1.0)),
            actions: InfiniteCanvasActions {
                on_selection_change: Some(edit.clone()),
                on_node_move: Some(edit),
                ..Default::default()
            },
        )).height(360.0).bg(tokens.colors.background)
            .border(tokens.colors.border, 1.0).border_radius(tokens.radii.medium),
        Text(cx.tr("plan.list")).weight(tokens.typography.font_weight_semibold),
        for item in &state.items {
            PlanSelectionRow(item.id, key: item.id)
        },
        Text(cx.tr("plan.scope")).color(tokens.colors.text_secondary),
    ])).padding_all(tokens.spacing.l)))
}

fission_component! {
    pub PlanSelectionRow<PlanState> { props { item_id: u64 } }
    view(row, state, cx) {
        let item = state.items.iter().find(|item| item.id == row.item_id);
    } => if let Some(item) = item {
        Button(
            child: Text(format!("{}: {}", cx.tr(if state.selected == Some(item.id) { "plan.selected" } else { "plan.select" }), item.title)),
            key: "select-item",
            on_press: reduce {
                if state.items.iter().any(|item| item.id == row.item_id) {
                    state.selected = Some(row.item_id);
                }
            },
        ).semantics_identifier(format!("plan.select.{}", row.item_id))
    } else { Text(cx.tr("plan.missing")) }
}
{"id":"fission-tabs-1","index":4,"label":"src/i18n.rs","value":"src-i18n-rs"}
use fission::i18n::{Locale, TranslationBundle};
use fission::prelude::*;
use std::collections::HashMap;

pub fn create_env() -> Env {
    let mut env = Env::default();
    env.locale = Locale::from("en-US");
    for (locale, source) in [
        ("en-US", include_str!("../i18n/en-US.yaml")),
        ("es-ES", include_str!("../i18n/es-ES.yaml")),
    ] {
        let messages: HashMap<String, String> =
            serde_yaml::from_str(source).expect("valid task translations");
        env.i18n.add_bundle(TranslationBundle {
            locale: Locale::from(locale),
            messages,
        });
    }
    env
}

pub fn sync_env(state: &crate::app::PlanState, env: &mut Env) {
    env.locale = state.locale.clone();
}
{"id":"fission-tabs-1","index":5,"label":"src/lib.rs","value":"src-lib-rs"}
pub mod app;
mod i18n;

use app::{PlanScreen, PlanState};
use fission::prelude::*;

#[cfg(not(any(target_arch = "wasm32", target_os = "android", target_os = "ios")))]
pub fn run_desktop() -> anyhow::Result<()> {
    DesktopApp::<PlanState, _>::new(PlanScreen)
        .with_env(i18n::create_env())
        .with_sync_env(i18n::sync_env)
        .run()
}

#[cfg(any(target_os = "android", target_os = "ios"))]
pub fn run_mobile() -> anyhow::Result<()> {
    MobileApp::<PlanState, _>::new(PlanScreen)
        .with_env(i18n::create_env())
        .with_sync_env(i18n::sync_env)
        .run()
}

#[cfg(target_os = "android")]
#[no_mangle]
fn android_main(app_handle: AndroidApp) {
    let _ = MobileApp::<PlanState, _>::new(PlanScreen)
        .with_env(i18n::create_env())
        .with_sync_env(i18n::sync_env)
        .run_with_android_app(app_handle);
}

#[cfg(target_arch = "wasm32")]
#[wasm_bindgen::prelude::wasm_bindgen(start)]
pub fn run_web() -> Result<(), wasm_bindgen::JsValue> {
    console_error_panic_hook::set_once();
    WebApp::<PlanState, _>::new(PlanScreen)
        .with_env(i18n::create_env())
        .with_sync_env(i18n::sync_env)
        .run()
        .map_err(|error| wasm_bindgen::JsValue::from_str(&error.to_string()))
}
{"id":"fission-tabs-1","index":6,"label":"preview/lib.rs","value":"preview-lib-rs"}
mod app;
mod i18n;

use fission::prelude::*;
use wasm_bindgen::prelude::*;

#[wasm_bindgen(start)]
pub fn run() -> Result<(), JsValue> {
    console_error_panic_hook::set_once();
    WebApp::<app::PlanState, _>::new(app::PlanScreen)
        .with_env(i18n::create_env())
        .with_sync_env(i18n::sync_env)
        .mount("#fission-web-mount")
        .run()
        .map_err(|error| JsValue::from_str(&error.to_string()))
}
{"id":"fission-tabs-1","index":7,"label":"i18n/en-US.yaml","value":"i18n-en-us-yaml"}
plan.title: "Arrange an inspection plan"
plan.explanation: "Add the checks you need, select a card and drag it into place. Pan and zoom change the view, not the inspection record."
plan.new_item: "Inspection check"
plan.title_error: "Enter a check of 1–80 characters."
plan.add: "Add check to plan"
plan.empty: "The plan is empty. Add your first check."
plan.selected_card: "Selected check"
plan.card_hint: "Select or drag this card."
plan.list: "Select a check without dragging"
plan.select: "Select"
plan.selected: "Selected"
plan.missing: "This check is no longer in the plan."
plan.scope: "Positions and checks are kept in memory for this session. This plan does not certify that any inspection has been performed."
language.english: "English"
language.spanish: "Español"
{"id":"fission-tabs-1","index":8,"label":"i18n/es-ES.yaml","value":"i18n-es-es-yaml"}
plan.title: "Organizar un plan de inspección"
plan.explanation: "Añade las comprobaciones, selecciona una tarjeta y arrástrala. Desplazar o ampliar cambia la vista, no el registro."
plan.new_item: "Comprobación"
plan.title_error: "Introduce una comprobación de 1 a 80 caracteres."
plan.add: "Añadir comprobación al plan"
plan.empty: "El plan está vacío. Añade la primera comprobación."
plan.selected_card: "Comprobación seleccionada"
plan.card_hint: "Selecciona o arrastra esta tarjeta."
plan.list: "Seleccionar sin arrastrar"
plan.select: "Seleccionar"
plan.selected: "Seleccionada"
plan.missing: "Esta comprobación ya no está en el plan."
plan.scope: "Las posiciones y comprobaciones permanecen en memoria durante esta sesión. El plan no certifica que se haya realizado una inspección."
language.english: "Inglés"
language.spanish: "Español"
{"id":"fission-tabs-1"}
Add two checks with the same title. Select one using the list, then drag it on the canvas. Its selected identity must not move to the other record.
Show the app preview
Hide the app preview

2. Keep interaction state and the plan separate

initial_transform sets the starting view; the canvas runtime retains later pan/zoom interaction. Node movement updates the corresponding record's bounds. Selection accepts only an ID which still belongs to the document. Unknown or unrelated interaction kinds do not create records.
The app registers its reusable event reducer when building the canvas and supplies that action to both selection and move callbacks. This is a legitimate shared handler boundary, not an excuse to create one action type per simple button.
The labelled list invokes the same application selection state without relying on coordinates. It is a selection alternative, not a claim of a complete non-gesture movement editor. A product needing equivalent keyboard-only placement should add named movement commands or coordinate fields and test them with the intended assistive tools.
cargo test --lib
The test checks stable identity under reversal and rejects an empty check. It cannot establish that a finger drag, pinch or VoiceOver interaction behaves correctly on iOS.
Pan and zoom, then select the check from the labelled list. Pan/zoom must not change its stored bounds. Recreate the app and observe that the session-local plan resets; no persistence has been added.
Show the app preview
Hide the app preview

3. Verify touch and small-screen interaction

On macOS, launch an installed simulator:
fission doctor ios --project-dir .
fission devices --project-dir .
fission run --target ios --project-dir .
fission test --target ios --project-dir .
Repeat on a small iPhone layout and a wider iPad layout. Check dragging near the canvas edge, pan versus selection, pinch zoom limits, an open keyboard, long translated labels and a denser plan. The canvas has its own bounded viewport inside the page's scrolling region; inspect how their gestures interact rather than assuming two scrollable surfaces will feel right.
Use a physical iPhone for final touch and accessibility checks. A browser drag does not establish native gesture behaviour. A passing host smoke test says nothing about whether the right node moved.