pub struct FlexView<State: 'static> { /* private fields */ }Expand description
A declarative flex container. See the module docs.
Implementations§
Source§impl<State: 'static> FlexView<State>
impl<State: 'static> FlexView<State>
Sourcepub fn new(direction: Axis, children: Vec<FlexChild<State>>) -> Self
pub fn new(direction: Axis, children: Vec<FlexChild<State>>) -> Self
Create a flex laying children out along direction, cross-aligned to
the start and main-aligned to the start.
Sourcepub fn child<V: View<State>>(self, view: V) -> Self
pub fn child<V: View<State>>(self, view: V) -> Self
Append an inflexible child. Accepts any View; erasure happens
internally, so no any() is needed.
Sourcepub fn flex<V: View<State>>(self, flex: u32, view: V) -> Self
pub fn flex<V: View<State>>(self, flex: u32, view: V) -> Self
Append a flexible child taking flex proportional shares of the free
main-axis space.
Sourcepub fn children<M>(self, children: impl ViewSeq<State, M>) -> Self
pub fn children<M>(self, children: impl ViewSeq<State, M>) -> Self
Append every element of children as an inflexible child.
Accepts any ViewSeq: a Vec/array of views, a tuple of mixed view
types, an Option, nested sequences, or views(iter) for an iterator.
Tuples are positional: a None element drops its slot and nested
sequences flatten in order. For a keyed list use FlexView::keyed per
child (the all-or-nothing rule of keyed still applies; a tuple does
not carry keys).
Sourcepub fn push(self, child: FlexChild<State>) -> Self
pub fn push(self, child: FlexChild<State>) -> Self
Append a pre-built FlexChild (escape hatch for flexible /
inflexible / keyed values built elsewhere).
Sourcepub fn when(self, cond: bool, f: impl FnOnce(Self) -> Self) -> Self
pub fn when(self, cond: bool, f: impl FnOnce(Self) -> Self) -> Self
Apply f to the builder only when cond is true.
Sourcepub fn when_some<T>(
self,
opt: Option<T>,
f: impl FnOnce(Self, T) -> Self,
) -> Self
pub fn when_some<T>( self, opt: Option<T>, f: impl FnOnce(Self, T) -> Self, ) -> Self
Apply f with the contained value when opt is Some.
Sourcepub fn cross_axis(self, cross: CrossAxisAlignment) -> Self
pub fn cross_axis(self, cross: CrossAxisAlignment) -> Self
Set the cross-axis alignment.
Sourcepub fn main_axis(self, main: MainAxisAlignment) -> Self
pub fn main_axis(self, main: MainAxisAlignment) -> Self
Set the main-axis alignment.
Trait Implementations§
Source§impl<State: 'static> View<State> for FlexView<State>
impl<State: 'static> View<State> for FlexView<State>
Source§type Element = FlexWidget
type Element = FlexWidget
Source§fn build(&self, ctx: &mut BuildCtx<'_>) -> FlexWidget
fn build(&self, ctx: &mut BuildCtx<'_>) -> FlexWidget
Source§fn rebuild(
&self,
prev: &Self,
element: &mut FlexWidget,
ctx: &mut BuildCtx<'_>,
) -> ChangeFlags
fn rebuild( &self, prev: &Self, element: &mut FlexWidget, ctx: &mut BuildCtx<'_>, ) -> ChangeFlags
prev (the previous view of the same type) against the live
element, mutating it in place and reporting what changed.