/// spawns a container with a folder icon and some text
pub fn spawn_folder(commands: &mut ChildBuilder, font: &Handle<Font>, icon: &Handle<Image>, name: &str) {
commands.spawn(NodeBundle {
style: Style {
size: Size::new(Val::Px(60.0), Val::Px(80.0)),
align_items: AlignItems::Center,
justify_content: JustifyContent::FlexStart,
flex_direction: FlexDirection::Column,
margin: UiRect {
left: Val::Px(2.0),
right: Val::Px(2.0),
top: Val::Px(5.0),
bottom: Val::Px(5.0),
},
// flex_wrap: FlexWrap::WrapReverse,
align_content: AlignContent::FlexStart,
..default()
},
background_color: Color::rgb(0.15, 0.15, 0.15).into(),
..default()
})
.with_children(|parent| {
parent.spawn(CoolButton::new(icon.clone()));
parent.spawn(NodeBundle {
background_color: Color::rgb(0.5, 0.5, 0.5).into(),
style: Style {
flex_wrap: FlexWrap::Wrap,
align_content: AlignContent::FlexStart,
size: Size::new(Val::Percent(100.0), Val::Px(32.0)),
..default()
},
..default()
})
.with_children(|parent| {
parent.spawn(TextBundle {
text: Text::from_section(name, TextStyle {
font: font.clone(),
font_size: 12.0,
color: Color::rgb(0.9, 0.9, 0.9),
}),
style: Style {
size: Size::new(Val::Percent(100.0), Val::Percent(100.0)),
max_size: Size::new(Val::Percent(100.0), Val::Percent(100.0)),
flex_wrap: FlexWrap::Wrap,
align_content: AlignContent::FlexStart,
..default()
},
background_color: Color::rgb(0.7, 0.7, 0.7).into(),
..default()
});
});
});
}
not really sure what's going on here, it seems no matter what flex settings i try it never works. The light background color under folder image is the container which is the parent of the TextBundle