summaryrefslogtreecommitdiffstats
path: root/examples/stopwatch/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/stopwatch/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 '')
-rw-r--r--examples/stopwatch/src/main.rs16
1 files changed, 4 insertions, 12 deletions
diff --git a/examples/stopwatch/src/main.rs b/examples/stopwatch/src/main.rs
index bd56785a..0d824d36 100644
--- a/examples/stopwatch/src/main.rs
+++ b/examples/stopwatch/src/main.rs
@@ -1,8 +1,7 @@
-use iced::alignment;
use iced::keyboard;
use iced::time;
use iced::widget::{button, center, column, row, text};
-use iced::{Alignment, Element, Subscription, Theme};
+use iced::{Center, Element, Subscription, Theme};
use std::time::{Duration, Instant};
@@ -101,13 +100,8 @@ impl Stopwatch {
)
.size(40);
- let button = |label| {
- button(
- text(label).horizontal_alignment(alignment::Horizontal::Center),
- )
- .padding(10)
- .width(80)
- };
+ let button =
+ |label| button(text(label).align_x(Center)).padding(10).width(80);
let toggle_button = {
let label = match self.state {
@@ -124,9 +118,7 @@ impl Stopwatch {
let controls = row![toggle_button, reset_button].spacing(20);
- let content = column![duration, controls]
- .align_items(Alignment::Center)
- .spacing(20);
+ let content = column![duration, controls].align_x(Center).spacing(20);
center(content).into()
}