Macro impl_flex_builders

Source
macro_rules! impl_flex_builders {
    ($ty:ident) => { ... };
}
Expand description

Implements FlexLayoutExt and consuming container-flex builders for a generic widget with a flex field.

The invocation scope must import [FlexStyle] because the generated trait implementation names that type directly.

ยงExamples

use std::marker::PhantomData;
use ailloli_ui_core::style::{AlignItems, FlexStyle};
use ailloli_ui_widgets::impl_flex_builders;
use ailloli_ui_widgets::layout::FlexLayoutExt;

struct Example<A> {
    flex: FlexStyle,
    action: PhantomData<A>,
}
impl_flex_builders!(Example);
let widget = Example::<()> {
    flex: FlexStyle::default(),
    action: PhantomData,
}.align_items(AlignItems::Center);
assert_eq!(widget.flex.align_items, AlignItems::Center);