diff options
author | 2024-02-15 02:57:52 +0100 | |
---|---|---|
committer | 2024-02-15 02:57:52 +0100 | |
commit | 84cc9f130b4e29219d47db42cdb76548b054c66b (patch) | |
tree | 5758716b7ca1a35e589969efd9537f5e56dd1e27 /examples/toast | |
parent | 5827023ccc3f80012b17dbfe778fbd8b63186c99 (diff) | |
parent | 777e2e34f50c440f59d9a407f75be80fbbfaccae (diff) | |
download | iced-84cc9f130b4e29219d47db42cdb76548b054c66b.tar.gz iced-84cc9f130b4e29219d47db42cdb76548b054c66b.tar.bz2 iced-84cc9f130b4e29219d47db42cdb76548b054c66b.zip |
Merge pull request #2253 from iced-rs/improve-ergonomics
Improve some widget ergonomics
Diffstat (limited to 'examples/toast')
-rw-r--r-- | examples/toast/src/main.rs | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/examples/toast/src/main.rs b/examples/toast/src/main.rs index 7f067e2f..c1d29193 100644 --- a/examples/toast/src/main.rs +++ b/examples/toast/src/main.rs @@ -111,11 +111,10 @@ impl Application for App { column![text(title).size(14), content].spacing(5) }; - let mut add_toast = button("Add Toast"); - - if !self.editing.body.is_empty() && !self.editing.title.is_empty() { - add_toast = add_toast.on_press(Message::Add); - } + let add_toast = button("Add Toast").on_press_maybe( + (!self.editing.body.is_empty() && !self.editing.title.is_empty()) + .then_some(Message::Add), + ); let content = container( column![ @@ -274,7 +273,7 @@ mod toast { container( row![ text(toast.title.as_str()), - horizontal_space(Length::Fill), + horizontal_space(), button("X") .on_press((on_close)(index)) .padding(3), |