fix: Make popup child a closure

This commit is contained in:
demenik
2025-12-09 13:06:01 +01:00
parent 667cc127ba
commit c50601c23a
3 changed files with 124 additions and 160 deletions

View File

@@ -3,127 +3,83 @@ use super::timer_settings::timer_settings;
use crate::prelude::*;
pub fn open_settings(commands: &mut Commands) {
commands
.spawn((
RootMarker::Settings,
Node {
position_type: PositionType::Absolute,
width: percent(100),
height: percent(100),
..Node::center()
},
ZIndex(1),
BackgroundColor(Color::srgba(0.0, 0.0, 0.0, 0.8)),
GlobalTransform::default(),
))
.with_children(|parent| {
parent
.spawn((
Node {
width: px(700),
padding: UiRect::all(px(20.0)),
..Node::vstack(px(20))
},
BackgroundColor(Color::srgb(0.2, 0.2, 0.2)),
BorderRadius::all(px(10.0)),
))
.with_children(|parent| {
parent.spawn((
spawn_popup(
commands,
RootMarker::Settings,
"Spiel Einstellungen",
Node {
width: px(700),
..default()
},
|parent| {
parent.spawn((
Node::vstack(px(10)),
children![
button(
ButtonType::SettingsExit,
ButtonVariant::Secondary,
Node::from_padding(UiRect::all(px(10))),
|color| text("Spiel verlassen", 24.0, color)
),
button(
ButtonType::SettingsSave,
ButtonVariant::Secondary,
Node::from_padding(UiRect::all(px(10))),
|color| text("Spiel speichern", 24.0, color)
),(
Node {
justify_content: JustifyContent::SpaceBetween,
..Node::hstack(px(20))
justify_content: JustifyContent::Center,
..Node::hstack(px(30))
},
children![
text("Spiel Einstellungen", 40.0, Color::WHITE),
pill_button(
ButtonType::SettingsClose,
ButtonVariant::Destructive,
(
Node {
width: px(40),
height: px(40),
..default()
},
|color| text("X", 24.0, color)
),
],
));
parent
.spawn(Node::vstack(px(10)))
.with_children(|parent| {
parent.spawn(button(
ButtonType::SettingsExit,
ButtonVariant::Secondary,
Node {
padding: UiRect::all(px(10)),
..default()
},
|color| text("Spiel verlassen", 24.0, color)
));
parent.spawn(button(
ButtonType::SettingsSave,
ButtonVariant::Secondary,
Node {
padding: UiRect::all(px(10)),
..default()
},
|color| text("Spiel speichern", 24.0, color)
));
parent.spawn((
Node {
justify_content: JustifyContent::Center,
..Node::hstack(px(30))
width: percent(40),
..Node::vstack(px(10))
},
children![
(
Node {
width: percent(40),
..Node::vstack(px(10))
},
children![
text("Spiel Einstellungen", 18.0, Color::WHITE),
text(
"Tipp: Benutze [Umstellen] um in 10er Schritten zu inkrementieren oder dekrementieren!",
16.0,
Color::WHITE
),
]
text("Spiel Einstellungen", 18.0, Color::WHITE),
text(
"Tipp: Benutze [Umstellen] um in 10er Schritten zu inkrementieren oder dekrementieren!",
16.0,
Color::WHITE
),
(
Node {
align_items: AlignItems::Center,
..Node::vstack(px(10))
},
children![
text("Fokus Phase", 12.0, Color::WHITE),
timer_settings(TimerType::Focus)
]
),
(
Node {
align_items: AlignItems::Center,
..Node::vstack(px(10))
},
children![
text("Kurze Pause", 12.0, Color::WHITE),
timer_settings(TimerType::ShortBreak)
]
),
(
Node {
align_items: AlignItems::Center,
..Node::vstack(px(10))
},
children![
text("Lange Pause", 12.0, Color::WHITE),
timer_settings(TimerType::LongBreak)
]
)
],
));
});
});
});
]
),
(
Node {
align_items: AlignItems::Center,
..Node::vstack(px(10))
},
children![
text("Fokus Phase", 12.0, Color::WHITE),
timer_settings(TimerType::Focus)
]
),
(
Node {
align_items: AlignItems::Center,
..Node::vstack(px(10))
},
children![
text("Kurze Pause", 12.0, Color::WHITE),
timer_settings(TimerType::ShortBreak)
]
),
(
Node {
align_items: AlignItems::Center,
..Node::vstack(px(10))
},
children![
text("Lange Pause", 12.0, Color::WHITE),
timer_settings(TimerType::LongBreak)
]
)
],
)
],
));
},
);
}