This complete example reuses the editable checklist rather than presenting a different fake work order for each target. Keep the generated src/main.rs; the shared src/lib.rs below supplies its normal target entrypoints. state.rs owns the records and creation rule. row.rs is a named reusable component, and screen.rs composes the workflow. The i18n setup is also shared. A larger app would put routes and services alongside these modules, not inside generated platform packaging files.
{"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/row.rs","value":"src-app-row-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"}
pub mod row;
pub mod screen;
pub mod state;
pub use screen::ChecklistScreen;
pub use state::ChecklistState;
{"id":"fission-tabs-1","index":1,"label":"src/app/state.rs","value":"src-app-state-rs"}
use fission::prelude::*;
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct ChecklistItem {
pub id: u64,
pub title: String,
pub complete: bool,
}
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct ChecklistState {
pub items: Vec<ChecklistItem>,
pub next_id: u64,
pub locale: Locale,
}
impl Default for ChecklistState {
fn default() -> Self {
Self {
items: Vec::new(),
next_id: 1,
locale: Locale::from("en-US"),
}
}
}
impl GlobalState for ChecklistState {}
pub fn add_item(state: &mut ChecklistState, title: &str) {
let title = title.trim();
if title.is_empty() {
return;
}
let Some(next) = state.next_id.checked_add(1) else {
return;
};
state.items.push(ChecklistItem {
id: state.next_id,
title: title.to_owned(),
complete: false,
});
state.next_id = next;
}
{"id":"fission-tabs-1","index":2,"label":"src/app/row.rs","value":"src-app-row-rs"}
use super::state::ChecklistState;
use fission::prelude::*;
fission_component! {
pub ChecklistRow<ChecklistState> {
props {
item_id: u64,
title: String,
complete: bool,
}
state {
expanded: bool = false,
}
}
view(row, state, cx) {
let tokens = &cx.view.env().theme.tokens;
let status = if row.complete {
cx.tr("item.complete")
} else {
cx.tr("item.pending")
};
} => SemanticsRegion(
identifier: Some(format!("checklist.item.{}", row.item_id)),
child: Container(
Column(gap: tokens.spacing.s, children: [
Text(row.title.clone()).weight(tokens.typography.font_weight_semibold),
Text(status),
Row(gap: tokens.spacing.s, wrap: ir_op::FlexWrap::Wrap, children: [
Button(
child: Text(if row.complete { cx.tr("item.reopen") } else { cx.tr("item.finish") }),
key: "toggle-completion",
on_press: reduce {
if let Some(item) = state.items.iter_mut().find(|item| item.id == row.item_id) {
item.complete = !item.complete;
}
},
),
Button(
child: Text(if row.expanded { cx.tr("item.hide") } else { cx.tr("item.details") }),
key: "toggle-details",
on_press: reduce { row.expanded = !row.expanded; },
),
]),
if row.expanded {
Text(cx.tr("item.detail_summary").replace("{title}", &row.title))
},
]),
)
.padding_all(tokens.spacing.m)
.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::row::ChecklistRow;
use super::state::{add_item, ChecklistState};
use fission::prelude::*;
fission_component! {
pub ChecklistScreen<ChecklistState> {
state {
draft: String = String::new(),
filter: String = String::new(),
reversed: bool = false,
}
}
view(screen, state, cx) {
let tokens = &cx.view.env().theme.tokens;
let query = screen.filter.to_lowercase();
let mut visible: Vec<_> = state.items.iter()
.filter(|item| item.title.to_lowercase().contains(&query))
.collect();
if screen.reversed {
visible.reverse();
}
} => SafeArea(
child: Scroll(
child: Container(
Column(gap: tokens.spacing.m, children: [
Text(cx.tr("list.title")).size(tokens.typography.heading2_size),
Text(cx.tr("list.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("list.new_item")),
required: true,
child: TextInput(
value: screen.draft.clone(),
bind(on_input): to(screen.draft),
),
),
Button(
child: Text(cx.tr("list.add")),
key: "add-item",
disabled: screen.draft.trim().is_empty() || state.next_id == u64::MAX,
on_press: reduce {
add_item(state, &screen.draft);
screen.draft.clear();
},
),
TextInput(
value: screen.filter.clone(),
bind(on_input): to(screen.filter),
label: Some(TextContent::Key("list.filter".into())),
),
Button(
child: Text(cx.tr("list.reverse")),
key: "reverse-order",
on_press: reduce { screen.reversed = !screen.reversed; },
),
if visible.is_empty() {
Text(cx.tr("list.empty"))
},
for item in visible {
ChecklistRow(
item.id,
item.title.clone(),
item.complete,
key: item.id,
)
},
]),
)
.padding_all(tokens.spacing.l)
.bg(tokens.colors.surface),
),
)
}
{"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 checklist translations");
env.i18n.add_bundle(TranslationBundle {
locale: Locale::from(locale),
messages,
});
}
env
}
pub fn sync_env(state: &crate::app::ChecklistState, 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::{ChecklistScreen, ChecklistState};
use fission::prelude::*;
#[cfg(not(any(target_arch = "wasm32", target_os = "android", target_os = "ios")))]
pub fn run_desktop() -> anyhow::Result<()> {
DesktopApp::<ChecklistState, _>::new(ChecklistScreen)
.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::<ChecklistState, _>::new(ChecklistScreen)
.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::<ChecklistState, _>::new(ChecklistScreen)
.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::<ChecklistState, _>::new(ChecklistScreen)
.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::ChecklistState, _>::new(app::ChecklistScreen)
.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"}
list.title: "Your inspection checklist"
list.explanation: "Add your own checks, open one row's details, then reverse the order. The details must not move to another item."
list.new_item: "New inspection check"
list.add: "Add check"
list.filter: "Filter checks by title"
list.reverse: "Reverse displayed order"
list.empty: "No checks match. Add a check or clear the filter."
item.complete: "Complete"
item.pending: "Not complete"
item.reopen: "Reopen check"
item.finish: "Mark complete"
item.details: "Show details"
item.hide: "Hide details"
item.detail_summary: "Details for: {title}. Completion belongs to the checklist record; whether this panel is open belongs to this row."
language.english: "English"
language.spanish: "Español"
{"id":"fission-tabs-1","index":8,"label":"i18n/es-ES.yaml","value":"i18n-es-es-yaml"}
list.title: "Tu lista de inspección"
list.explanation: "Añade tus comprobaciones, abre los detalles de una fila e invierte el orden. Los detalles no deben pasar a otro elemento."
list.new_item: "Nueva comprobación"
list.add: "Añadir comprobación"
list.filter: "Filtrar comprobaciones por título"
list.reverse: "Invertir el orden mostrado"
list.empty: "No hay coincidencias. Añade una comprobación o borra el filtro."
item.complete: "Completada"
item.pending: "Sin completar"
item.reopen: "Reabrir comprobación"
item.finish: "Marcar como completada"
item.details: "Mostrar detalles"
item.hide: "Ocultar detalles"
item.detail_summary: "Detalles de: {title}. La finalización pertenece al registro; el estado abierto de este panel pertenece a esta fila."
language.english: "Inglés"
language.spanish: "Español"
{"id":"fission-tabs-1"}