Add push_maybe to Column and Row
This commit is contained in:
parent
e57668d677
commit
feab96f323
9 changed files with 144 additions and 95 deletions
|
|
@ -56,22 +56,18 @@ impl Sandbox for Tour {
|
|||
fn view(&self) -> Element<Message> {
|
||||
let Tour { steps, .. } = self;
|
||||
|
||||
let mut controls = row![];
|
||||
|
||||
if steps.has_previous() {
|
||||
controls = controls.push(
|
||||
let controls = row![]
|
||||
.push_maybe(steps.has_previous().then(|| {
|
||||
button("Back")
|
||||
.on_press(Message::BackPressed)
|
||||
.style(theme::Button::Secondary),
|
||||
.style(theme::Button::Secondary)
|
||||
}))
|
||||
.push(horizontal_space())
|
||||
.push_maybe(
|
||||
steps
|
||||
.can_continue()
|
||||
.then(|| button("Next").on_press(Message::NextPressed)),
|
||||
);
|
||||
}
|
||||
|
||||
controls = controls.push(horizontal_space());
|
||||
|
||||
if steps.can_continue() {
|
||||
controls =
|
||||
controls.push(button("Next").on_press(Message::NextPressed));
|
||||
}
|
||||
|
||||
let content: Element<_> = column![
|
||||
steps.view(self.debug).map(Message::StepMessage),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue