The pass condition for android-view backend (RUST.md's I2) is that the tabs example itself, text field included, runs there -- not a second demo with the same shape. tabs-ui/src/lib.rs is that widget tree moved out of examples/tabs/main.rs into a small crate generic over `Rsc: HasEvents` and `Rsc::State: FocusHost`, so the winit example and the upcoming android-app cdylib both call the same `build()` rather than carrying two copies. Nothing in it names either backend. Verified: the winit tabs example still renders pixel-identically via run-headless.sh (27266 bytes, unchanged), tabs-ui cross-compiles clean for x86_64-linux-android alongside iris, and host build/clippy/fmt/ tests are unaffected. Co-Authored-By: Claude Sonnet <noreply@anthropic.com>
48 lines
1.2 KiB
Rust
48 lines
1.2 KiB
Rust
use iris::prelude::*;
|
|
use winit::event::WindowEvent;
|
|
|
|
fn main() {
|
|
DefaultApp::<Client>::run();
|
|
}
|
|
|
|
/// The tabs example: five demo panes plus a message composer, built by
|
|
/// `tabs_ui::build` and driven here through the winit backend. The same
|
|
/// widget tree also runs on the android-view backend, through
|
|
/// `iris-android-app` -- see RUST.md's I2.
|
|
#[derive(DefaultUiState)]
|
|
pub struct Client {
|
|
ui_state: DefaultUiState,
|
|
info: WeakWidget<Text>,
|
|
}
|
|
|
|
impl DefaultAppState for Client {
|
|
fn new(
|
|
mut ui_state: DefaultUiState,
|
|
rsc: &mut DefaultRsc<Self>,
|
|
_: Proxy<Self::Event>,
|
|
) -> Self {
|
|
let widgets = tabs_ui::build(rsc, &mut ui_state);
|
|
Self {
|
|
ui_state,
|
|
info: widgets.info,
|
|
}
|
|
}
|
|
|
|
fn window_event(
|
|
&mut self,
|
|
_: WindowEvent,
|
|
rsc: &mut DefaultRsc<Self>,
|
|
render: &mut UiRenderState,
|
|
) {
|
|
let new = format!(
|
|
"widgets: {}\nactive: {}\nviews: {}",
|
|
rsc.widgets().len(),
|
|
render.active_widgets(),
|
|
self.ui_state.renderer.ui.view_count(),
|
|
);
|
|
if new != *rsc.widgets()[self.info].content {
|
|
*rsc.widgets_mut()[self.info].content = new;
|
|
}
|
|
}
|
|
}
|