fn event_list() -> impl Widget<AppState> {
    // Because this would be a HUGE block of repeated code with constants
    // we just use a loop to generate the header.
    let mut header = Flex::row().with_child(
        Label::new(PROPERTIES[0].0)
            .fix_width(PROPERTIES[0].1)
            .background(HEADER_BACKGROUND),
    );

    for (name, size) in PROPERTIES.iter().skip(1) {
        // Keep in mind that later on, in the main function,
        // we set the default spacer values. Without explicitly
        // setting them the default spacer is bigger, and is
        // probably not desirable for your purposes.
        header.add_default_spacer();
        header.add_child(
            Label::new(*name)
                .fix_width(*size)
                .background(HEADER_BACKGROUND),
        );
    }
    Scroll::new(
        Flex::column()
            .cross_axis_alignment(CrossAxisAlignment::Start)
            .with_child(header)
            .with_default_spacer()
            .with_flex_child(
                // `List::new` generates a list entry for every element in the `Vec`.
                // In this case it shows a log entry for every element in `AppState::events`.
                // `make_list_item` generates this new log entry.
                Scroll::new(List::new(make_list_item).lens(AppState::events)).vertical(),
                1.0,
            )
            .background(Color::WHITE),
    )
    .horizontal()
    .padding(10.0)
}
/// The bottom part of the application, a list of received events.
The bottom part of the application, a list of received events.
The bottom part of the application a list of received events .
fn event_list() -> impl Widget<AppState> {
    // Because this would be a HUGE block of repeated code with constants
    // we just use a loop to generate the header.
    let mut header = Flex::row().with_child(
        Label::new(PROPERTIES[0].0)
            .fix_width(PROPERTIES[0].1)
            .background(HEADER_BACKGROUND),
    );
    for (name, size) in PROPERTIES.iter().skip(1) {
        // Keep in mind that later on, in the main function,
        // we set the default spacer values. Without explicitly
        // setting them the default spacer is bigger, and is
        // probably not desirable for your purposes.
        header.add_default_spacer();
        header.add_child(
            Label::new(*name)
                .fix_width(*size)
                .background(HEADER_BACKGROUND),
        );
    }
    Scroll::new(
        Flex::column()
            .cross_axis_alignment(CrossAxisAlignment::Start)
            .with_child(header)
            .with_default_spacer()
            .with_flex_child(
                // `List::new` generates a list entry for every element in the `Vec`.
                // In this case it shows a log entry for every element in `AppState::events`.
                // `make_list_item` generates this new log entry.
                Scroll::new(List::new(make_list_item).lens(AppState::events)).vertical(),
                1.0,
            )
            .background(Color::WHITE),
    )
    .horizontal()
    .padding(10.0)
}
fn event_list ( ) -> impl Widget < AppState > { // Because this would be a HUGE block of repeated code with constants // we just use a loop to generate the header. let mut header = Flex :: row ( ) . with_child ( Label :: new ( PROPERTIES [ 0 ] . 0 ) . fix_width ( PROPERTIES [ 0 ] . 1 ) . background ( HEADER_BACKGROUND ) , ) ; for ( name , size ) in PROPERTIES . iter ( ) . skip ( 1 ) { // Keep in mind that later on, in the main function, // we set the default spacer values. Without explicitly // setting them the default spacer is bigger, and is // probably not desirable for your purposes. header . add_default_spacer ( ) ; header . add_child ( Label :: new ( * name ) . fix_width ( * size ) . background ( HEADER_BACKGROUND ) , ) ; } Scroll :: new ( Flex :: column ( ) . cross_axis_alignment ( CrossAxisAlignment :: Start ) . with_child ( header ) . with_default_spacer ( ) . with_flex_child ( // `List::new` generates a list entry for every element in the `Vec`. // In this case it shows a log entry for every element in `AppState::events`. // `make_list_item` generates this new log entry. Scroll :: new ( List :: new ( make_list_item ) . lens ( AppState :: events ) ) . vertical ( ) , 1.0 , ) . background ( Color :: WHITE ) , ) . horizontal ( ) . padding ( 10.0 ) }
The bottom part of the application, a list of received events.
The bottom part of the application a list of received events .