Page
page(title) lays out a screen: a header row, then the body padded and
filling the window. .back(f) puts an arrow before the title and runs f
on Escape and the Android back button too; .menu(f) puts a menu button
there instead, e.g. to show a drawer. The title is any widget: heading
for bold text, or tabs.
The arrow, menu and close shapes are in dfui::icons, for icon and
icon_button elsewhere.
use dfui::Element;
use dfui::widgets::{Styled, button, drawer, heading, overlays, page, stateful, text};
fn view() -> Element {
overlays(|ov| {
stateful(move |open: &bool, h| -> Element {
if *open {
page(heading("Details"))
.back(move |cx| cx.update(h, |o: &mut bool| *o = false))
.child(text("Back, Escape or the Android back button return."))
.into()
} else {
page(heading("Home"))
.menu(move |cx| ov.show(cx, |_| drawer(text("Menu"))))
.child(
button(text("Open details"))
.on_click(move |cx| cx.update(h, |o: &mut bool| *o = true)),
)
.into()
}
})
.fill()
})
.into()
}
fn main() {
dfui::run(view);
}
Run it natively: cargo run -p dfui-site --example page