From 999ad2d288a9354f045bb2e1b838014b3d302779 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Sat, 23 Mar 2024 19:23:08 +0100 Subject: Try catalog theming approach with `Button` --- examples/component/src/main.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'examples/component/src') diff --git a/examples/component/src/main.rs b/examples/component/src/main.rs index 43ba3187..d5626087 100644 --- a/examples/component/src/main.rs +++ b/examples/component/src/main.rs @@ -74,7 +74,7 @@ mod numeric_input { impl Component for NumericInput where Theme: text::DefaultStyle - + button::DefaultStyle + + button::Catalog + text_input::DefaultStyle + 'static, { @@ -152,7 +152,7 @@ mod numeric_input { for Element<'a, Message, Theme> where Theme: text::DefaultStyle - + button::DefaultStyle + + button::Catalog + text_input::DefaultStyle + 'static, Message: 'a, -- cgit From f0ae9a0c38c2532220a7460916604914db94c078 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Sun, 24 Mar 2024 05:03:09 +0100 Subject: Use `Catalog` approach for all widgets --- examples/component/src/main.rs | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'examples/component/src') diff --git a/examples/component/src/main.rs b/examples/component/src/main.rs index d5626087..b2c71b3f 100644 --- a/examples/component/src/main.rs +++ b/examples/component/src/main.rs @@ -73,10 +73,7 @@ mod numeric_input { impl Component for NumericInput where - Theme: text::DefaultStyle - + button::Catalog - + text_input::DefaultStyle - + 'static, + Theme: text::Catalog + button::Catalog + text_input::Catalog + 'static, { type State = (); type Event = Event; @@ -151,10 +148,7 @@ mod numeric_input { impl<'a, Message, Theme> From> for Element<'a, Message, Theme> where - Theme: text::DefaultStyle - + button::Catalog - + text_input::DefaultStyle - + 'static, + Theme: text::Catalog + button::Catalog + text_input::Catalog + 'static, Message: 'a, { fn from(numeric_input: NumericInput) -> Self { -- 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/component/src/main.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'examples/component/src') diff --git a/examples/component/src/main.rs b/examples/component/src/main.rs index b2c71b3f..5625f12a 100644 --- a/examples/component/src/main.rs +++ b/examples/component/src/main.rs @@ -1,5 +1,5 @@ -use iced::widget::container; -use iced::{Element, Length}; +use iced::widget::center; +use iced::Element; use numeric_input::numeric_input; @@ -27,10 +27,8 @@ impl Component { } fn view(&self) -> Element { - container(numeric_input(self.value, Message::NumericInputChanged)) + center(numeric_input(self.value, Message::NumericInputChanged)) .padding(20) - .height(Length::Fill) - .center_y() .into() } } -- cgit