pub fn responsive_render<'a, Message, F>(build: F) -> Element<'a, Message>Expand description
Renders an AppLayout that may depend on the available width.
build receives the width available to the layout (in logical
pixels) and returns the AppLayout to render at that width. It may
be called again whenever the available size changes — see
iced::widget::Responsive’s own documentation for the underlying
mechanism.
A sibling to crate::render::render, not a replacement — this is
engine capability, not design-gated, so it lives in the default
surface next to render. Applications not calling this entry point
are unaffected; render’s own behavior and signature are unchanged.
ⓘ
use snora::{AppLayout, responsive_render};
fn view(state: &State) -> Element<'_, Message> {
responsive_render(move |width| {
let layout = AppLayout::new(body(state));
if width < 600.0 {
layout // application's own choice: no sidebar below 600px
} else {
layout.side_bar(sidebar(state))
}
})
}