From 9dd20ead085ff3b9b4bd441b5e4938cf8e813f35 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Thu, 15 Feb 2024 02:01:56 +0100 Subject: Rename `password` method in `TextInput` to `secure` --- examples/tour/src/main.rs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'examples/tour') diff --git a/examples/tour/src/main.rs b/examples/tour/src/main.rs index 6d24b5ec..15d37896 100644 --- a/examples/tour/src/main.rs +++ b/examples/tour/src/main.rs @@ -613,11 +613,7 @@ impl<'a> Step { Self::container("Text input") .push("Use a text input to ask for different kinds of information.") - .push(if is_secure { - text_input.password() - } else { - text_input - }) + .push(text_input.secure(is_secure)) .push( checkbox("Enable password mode", is_secure) .on_toggle(StepMessage::ToggleSecureInput), -- cgit From e8049af23dbf4988ff24b75b90104295f61098a2 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Thu, 15 Feb 2024 02:08:22 +0100 Subject: Make `horizontal_space` and `vertical_space` fill by default --- examples/tour/src/main.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'examples/tour') diff --git a/examples/tour/src/main.rs b/examples/tour/src/main.rs index 15d37896..509f46e7 100644 --- a/examples/tour/src/main.rs +++ b/examples/tour/src/main.rs @@ -66,7 +66,7 @@ impl Sandbox for Tour { ); } - controls = controls.push(horizontal_space(Length::Fill)); + controls = controls.push(horizontal_space()); if steps.can_continue() { controls = @@ -574,14 +574,14 @@ impl<'a> Step { text("Tip: You can use the scrollbar to scroll down faster!") .size(16), ) - .push(vertical_space(4096)) + .push(vertical_space().height(4096)) .push( text("You are halfway there!") .width(Length::Fill) .size(30) .horizontal_alignment(alignment::Horizontal::Center), ) - .push(vertical_space(4096)) + .push(vertical_space().height(4096)) .push(ferris(300, image::FilterMethod::Linear)) .push( text("You made it!") -- cgit From feab96f323189ebae070a5d025531f86e436e21f Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Thu, 15 Feb 2024 02:38:07 +0100 Subject: Add `push_maybe` to `Column` and `Row` --- examples/tour/src/main.rs | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) (limited to 'examples/tour') diff --git a/examples/tour/src/main.rs b/examples/tour/src/main.rs index 509f46e7..588abbe8 100644 --- a/examples/tour/src/main.rs +++ b/examples/tour/src/main.rs @@ -56,22 +56,18 @@ impl Sandbox for Tour { fn view(&self) -> Element { 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), -- cgit