From 1d83e59e8ab51d403baee0daa878644c6a37be3f Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Mon, 1 Apr 2024 21:36:08 +0200 Subject: Specialize `widget::text` helper with custom `IntoContent` trait --- examples/tour/src/main.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'examples/tour/src') diff --git a/examples/tour/src/main.rs b/examples/tour/src/main.rs index a88c0dba..e3a2ca87 100644 --- a/examples/tour/src/main.rs +++ b/examples/tour/src/main.rs @@ -357,7 +357,7 @@ impl<'a> Step { .into() } - fn container(title: &str) -> Column<'a, StepMessage> { + fn container(title: &str) -> Column<'_, StepMessage> { column![text(title).size(50)].spacing(20) } @@ -589,7 +589,7 @@ impl<'a> Step { value: &str, is_secure: bool, is_showing_icon: bool, - ) -> Column<'a, StepMessage> { + ) -> Column<'_, StepMessage> { let mut text_input = text_input("Type something to continue...", value) .on_input(StepMessage::InputChanged) .padding(10) @@ -674,7 +674,7 @@ fn ferris<'a>( .center_x() } -fn padded_button<'a, Message: Clone>(label: &str) -> Button<'a, Message> { +fn padded_button(label: &str) -> Button<'_, Message> { button(text(label)).padding([12, 24]) } -- cgit From 15057a05c118dafcb8cf90d4119e66caaa6026c5 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Fri, 3 May 2024 09:11:46 +0200 Subject: Introduce `center` widget helper ... and also make `center_x` and `center_y` set `width` and `height` to `Length::Fill`, respectively. This targets the most common use case when centering things and removes a bunch of boilerplate as a result. --- examples/tour/src/main.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'examples/tour/src') diff --git a/examples/tour/src/main.rs b/examples/tour/src/main.rs index e3a2ca87..bae6490d 100644 --- a/examples/tour/src/main.rs +++ b/examples/tour/src/main.rs @@ -76,11 +76,10 @@ impl Tour { } else { content }) - .width(Length::Fill) .center_x(), ); - container(scrollable).height(Length::Fill).center_y().into() + container(scrollable).center_y().into() } } @@ -670,7 +669,6 @@ fn ferris<'a>( .filter_method(filter_method) .width(width), ) - .width(Length::Fill) .center_x() } -- cgit From 05f69f495e9b52e9a7d7bada420558d4c4f6730c Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Mon, 13 May 2024 17:56:02 +0200 Subject: Ask for explicit `Length` in `center_*` methods --- examples/tour/src/main.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'examples/tour/src') diff --git a/examples/tour/src/main.rs b/examples/tour/src/main.rs index bae6490d..59107258 100644 --- a/examples/tour/src/main.rs +++ b/examples/tour/src/main.rs @@ -76,10 +76,10 @@ impl Tour { } else { content }) - .center_x(), + .center_x(Length::Fill), ); - container(scrollable).center_y().into() + container(scrollable).center_y(Length::Fill).into() } } @@ -669,7 +669,7 @@ fn ferris<'a>( .filter_method(filter_method) .width(width), ) - .center_x() + .center_x(Length::Fill) } fn padded_button(label: &str) -> Button<'_, Message> { -- cgit