The native splash ends when the first frame is ready. That makes it unsuitable for onboarding or for showing progress on a network request. Our first frame is the visit arrival screen; starting a visit changes retained local state rather than holding the splash open.
Replace the generated src/lib.rs as well as src/app.rs. Otherwise fission run --target android would still launch the scaffold counter whilst the embedded Web preview showed a different app. The two shells below use the same screen and translation bundles.
{"id":"fission-tabs-1","tabs":[{"index":0,"label":"src/app.rs","value":"src-app-rs"},{"index":1,"label":"src/lib.rs","value":"src-lib-rs"},{"index":2,"label":"src/translations.rs","value":"src-translations-rs"},{"index":3,"label":"preview/lib.rs","value":"preview-lib-rs"},{"index":4,"label":"i18n/en-US.yaml","value":"i18n-en-us-yaml"},{"index":5,"label":"i18n/es-ES.yaml","value":"i18n-es-es-yaml"}]}
{"id":"fission-tabs-1","index":0,"label":"src/app.rs","value":"src-app-rs"}
use fission::prelude::*;
fission_component! {
pub VisitArrival<()> {
state { started: bool = false }
}
view(visit, _state, cx) {
let tokens = &cx.view.env().theme.tokens;
} =>
SemanticsRegion(
identifier: Some("android-add-an-android-app-icon-and-native-splash-screen".to_string()),
label: Some(cx.tr("preview.title")),
child: SafeArea(child: Scroll(child: Container(
Column(gap: tokens.spacing.m, children: [
Row(gap: tokens.spacing.m, align_items: ir_op::AlignItems::Center, children: [
Column(gap: tokens.spacing.xs, children: [
Text(cx.tr("preview.app.name"))
.weight(tokens.typography.font_weight_bold),
Text(cx.tr("preview.route"))
.color(tokens.colors.text_secondary),
]),
Spacer(flex_grow: 1.0),
Badge(text: cx.tr("preview.status.ready")),
]),
Divider(),
Text(cx.tr("preview.title"))
.size(tokens.typography.heading2_size),
Text(cx.tr("preview.summary"))
.color(tokens.colors.text_secondary),
Container(
Column(gap: tokens.spacing.s, children: [
Text(cx.tr("preview.context.title"))
.weight(tokens.typography.font_weight_semibold),
Text(cx.tr("preview.context.one")),
Text(cx.tr("preview.context.two")),
Text(cx.tr("preview.result"))
.color(tokens.colors.text_secondary),
])
)
.padding_all(tokens.spacing.m)
.bg(tokens.colors.background)
.border(tokens.colors.border, 1.0)
.border_radius(tokens.radii.medium),
Button(
child: Text(cx.tr(if visit.started { "visit.reopen" } else { "visit.start" })),
key: "visit-start",
on_press: reduce { visit.started = !visit.started; },
).semantics_identifier("visit.start"),
Text(cx.tr(if visit.started { "visit.started" } else { "visit.waiting" })),
Text(cx.tr("preview.footer"))
.color(tokens.colors.text_secondary),
])
)
.padding_all(tokens.spacing.l)
.bg(tokens.colors.surface)
.border(tokens.colors.border, 1.0)
.border_radius(tokens.radii.large))),
)
}
{"id":"fission-tabs-1","index":1,"label":"src/lib.rs","value":"src-lib-rs"}
pub mod app;
mod translations;
use app::VisitArrival;
use fission::prelude::*;
#[cfg(not(any(target_arch = "wasm32", target_os = "android", target_os = "ios")))]
pub fn run_desktop() -> anyhow::Result<()> {
DesktopApp::<(), _>::new(VisitArrival::new())
.with_env(translations::create_env())
.run()
}
#[cfg(any(target_os = "android", target_os = "ios"))]
fn mobile_app() -> MobileApp<(), VisitArrival> {
let app = MobileApp::<(), _>::new(VisitArrival::new())
.with_env(translations::create_env());
#[cfg(all(target_os = "android", debug_assertions))]
let app = app.with_test_control_port(48761);
app
}
#[cfg(any(target_os = "android", target_os = "ios"))]
pub fn run_mobile() -> anyhow::Result<()> {
mobile_app().run()
}
#[cfg(target_os = "android")]
#[no_mangle]
fn android_main(app_handle: AndroidApp) {
let _ = mobile_app().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::<(), _>::new(VisitArrival::new())
.with_env(translations::create_env())
.run()
.map_err(|error| wasm_bindgen::JsValue::from_str(&error.to_string()))
}
{"id":"fission-tabs-1","index":2,"label":"src/translations.rs","value":"src-translations-rs"}
use std::collections::HashMap;
use fission::prelude::*;
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 checked-in translations");
env.i18n.add_bundle(TranslationBundle {
locale: Locale::from(locale),
messages,
});
}
env
}
{"id":"fission-tabs-1","index":3,"label":"preview/lib.rs","value":"preview-lib-rs"}
mod app;
mod translations;
use fission::prelude::*;
use wasm_bindgen::prelude::*;
#[wasm_bindgen(start)]
pub fn run() -> Result<(), JsValue> {
console_error_panic_hook::set_once();
WebApp::<(), _>::new(app::VisitArrival::new())
.with_env(translations::create_env())
.mount("#fission-web-mount")
.run()
.map_err(|error| JsValue::from_str(&error.to_string()))
}
{"id":"fission-tabs-1","index":4,"label":"i18n/en-US.yaml","value":"i18n-en-us-yaml"}
preview.app.name: "Northbank Field Service"
preview.route: "Service visit · Android"
preview.title: "Start the service visit"
preview.summary: "Check the launcher identity, the short native splash, and the first Fission screen as separate parts of one launch."
preview.context.title: "Launch sequence"
preview.context.one: "Launcher icon: Northbank Field Service"
preview.context.two: "Native splash appears before the app draws its first frame."
preview.result: "This is the first Fission frame after the native splash. The browser cannot inspect generated Android assets."
preview.footer: "Cold-launch the Android app to verify the packaged launcher icon and splash resources."
preview.status.ready: "On-site visit"
visit.start: "Start visit"
visit.reopen: "Return to arrival"
visit.started: "Visit started. Continue with the inspection."
visit.waiting: "Start the visit when you arrive at the site."
{"id":"fission-tabs-1","index":5,"label":"i18n/es-ES.yaml","value":"i18n-es-es-yaml"}
preview.app.name: "Northbank Field Service"
preview.route: "Visita de servicio · Android"
preview.title: "Iniciar la visita de servicio"
preview.summary: "Comprueba la identidad del icono, la breve pantalla nativa y la primera pantalla de Fission como partes distintas del inicio."
preview.context.title: "Secuencia de inicio"
preview.context.one: "Icono de la app: Northbank Field Service"
preview.context.two: "La pantalla nativa aparece antes del primer fotograma de la app."
preview.result: "Este es el primer fotograma de Fission después de la pantalla inicial nativa. El navegador no puede inspeccionar los recursos generados de Android."
preview.footer: "Inicia Android en frío para comprobar el icono y los recursos de la pantalla inicial empaquetados."
preview.status.ready: "Visita presencial"
visit.start: "Iniciar visita"
visit.reopen: "Volver a la llegada"
visit.started: "Visita iniciada. Continúa con la inspección."
visit.waiting: "Inicia la visita cuando llegues al lugar."
{"id":"fission-tabs-1"}