summaryrefslogtreecommitdiffstats
path: root/examples/component/src/main.rs
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón <hector@hecrj.dev>2024-07-12 21:40:46 +0200
committerLibravatar GitHub <noreply@github.com>2024-07-12 21:40:46 +0200
commit8cadd3b99485c344feb18b774c8e6fd6c1ea9dd7 (patch)
tree826fa9e0acdf3a4e003f882c94ff24a4ac9f50e4 /examples/component/src/main.rs
parentbe06060117da061ad8cad94ab0830c06def6b147 (diff)
parent3f480d3d18c41188bf40ead0a3dc4497316f11ae (diff)
downloadiced-8cadd3b99485c344feb18b774c8e6fd6c1ea9dd7.tar.gz
iced-8cadd3b99485c344feb18b774c8e6fd6c1ea9dd7.tar.bz2
iced-8cadd3b99485c344feb18b774c8e6fd6c1ea9dd7.zip
Merge pull request #2504 from iced-rs/view-ergonomics
Improved `view` ergonomics
Diffstat (limited to 'examples/component/src/main.rs')
-rw-r--r--examples/component/src/main.rs19
1 files changed, 6 insertions, 13 deletions
diff --git a/examples/component/src/main.rs b/examples/component/src/main.rs
index 5625f12a..a5d2e508 100644
--- a/examples/component/src/main.rs
+++ b/examples/component/src/main.rs
@@ -34,9 +34,8 @@ impl Component {
}
mod numeric_input {
- use iced::alignment::{self, Alignment};
use iced::widget::{button, component, row, text, text_input, Component};
- use iced::{Element, Length, Size};
+ use iced::{Center, Element, Fill, Length, Size};
pub struct NumericInput<Message> {
value: Option<u32>,
@@ -104,16 +103,10 @@ mod numeric_input {
fn view(&self, _state: &Self::State) -> Element<'_, Event, Theme> {
let button = |label, on_press| {
- button(
- text(label)
- .width(Length::Fill)
- .height(Length::Fill)
- .horizontal_alignment(alignment::Horizontal::Center)
- .vertical_alignment(alignment::Vertical::Center),
- )
- .width(40)
- .height(40)
- .on_press(on_press)
+ button(text(label).width(Fill).height(Fill).center())
+ .width(40)
+ .height(40)
+ .on_press(on_press)
};
row![
@@ -130,7 +123,7 @@ mod numeric_input {
.padding(10),
button("+", Event::IncrementPressed),
]
- .align_items(Alignment::Center)
+ .align_y(Center)
.spacing(10)
.into()
}