From c741688b4c52dd2397880ca05b5f9a997d762246 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Wed, 11 Sep 2024 00:17:16 +0200 Subject: Add disabled state and `on_toggle` handler to `Toggler` Co-authored-by: Your Name here only --- examples/editor/src/main.rs | 7 ++----- examples/styling/src/main.rs | 9 +++------ examples/tour/src/main.rs | 9 ++++----- 3 files changed, 9 insertions(+), 16 deletions(-) (limited to 'examples') diff --git a/examples/editor/src/main.rs b/examples/editor/src/main.rs index 068782ba..c7d7eb26 100644 --- a/examples/editor/src/main.rs +++ b/examples/editor/src/main.rs @@ -150,11 +150,8 @@ impl Editor { self.is_dirty.then_some(Message::SaveFile) ), horizontal_space(), - toggler( - Some("Word Wrap"), - self.word_wrap, - Message::WordWrapToggled - ), + toggler(Some("Word Wrap"), self.word_wrap) + .on_toggle(Message::WordWrapToggled), pick_list( highlighter::Theme::ALL, Some(self.theme), diff --git a/examples/styling/src/main.rs b/examples/styling/src/main.rs index e19d5cf7..222ab79d 100644 --- a/examples/styling/src/main.rs +++ b/examples/styling/src/main.rs @@ -77,12 +77,9 @@ impl Styling { let checkbox = checkbox("Check me!", self.checkbox_value) .on_toggle(Message::CheckboxToggled); - let toggler = toggler( - Some("Toggle me!"), - self.toggler_value, - Message::TogglerToggled, - ) - .spacing(10); + let toggler = toggler(Some("Toggle me!"), self.toggler_value) + .on_toggle(Message::TogglerToggled) + .spacing(10); let content = column![ choose_theme, diff --git a/examples/tour/src/main.rs b/examples/tour/src/main.rs index 0dd588fe..fad5f0b1 100644 --- a/examples/tour/src/main.rs +++ b/examples/tour/src/main.rs @@ -357,11 +357,10 @@ impl Tour { Self::container("Toggler") .push("A toggler is mostly used to enable or disable something.") .push( - Container::new(toggler( - Some("Toggle me to continue..."), - self.toggler, - Message::TogglerChanged, - )) + Container::new( + toggler(Some("Toggle me to continue..."), self.toggler) + .on_toggle(Message::TogglerChanged), + ) .padding([0, 40]), ) } -- cgit From 6e4970c01a9e42621a0ded340dcdccb4204ab5d2 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Wed, 11 Sep 2024 00:20:23 +0200 Subject: Add `label` method to `Toggler` --- examples/editor/src/main.rs | 3 ++- examples/styling/src/main.rs | 3 ++- examples/tour/src/main.rs | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) (limited to 'examples') diff --git a/examples/editor/src/main.rs b/examples/editor/src/main.rs index c7d7eb26..d55f9bdf 100644 --- a/examples/editor/src/main.rs +++ b/examples/editor/src/main.rs @@ -150,7 +150,8 @@ impl Editor { self.is_dirty.then_some(Message::SaveFile) ), horizontal_space(), - toggler(Some("Word Wrap"), self.word_wrap) + toggler(self.word_wrap) + .label("Word Wrap") .on_toggle(Message::WordWrapToggled), pick_list( highlighter::Theme::ALL, diff --git a/examples/styling/src/main.rs b/examples/styling/src/main.rs index 222ab79d..534f5e32 100644 --- a/examples/styling/src/main.rs +++ b/examples/styling/src/main.rs @@ -77,7 +77,8 @@ impl Styling { let checkbox = checkbox("Check me!", self.checkbox_value) .on_toggle(Message::CheckboxToggled); - let toggler = toggler(Some("Toggle me!"), self.toggler_value) + let toggler = toggler(self.toggler_value) + .label("Toggle me!") .on_toggle(Message::TogglerToggled) .spacing(10); diff --git a/examples/tour/src/main.rs b/examples/tour/src/main.rs index fad5f0b1..d8c0b29a 100644 --- a/examples/tour/src/main.rs +++ b/examples/tour/src/main.rs @@ -358,7 +358,8 @@ impl Tour { .push("A toggler is mostly used to enable or disable something.") .push( Container::new( - toggler(Some("Toggle me to continue..."), self.toggler) + toggler(self.toggler) + .label("Toggle me to continue...") .on_toggle(Message::TogglerChanged), ) .padding([0, 40]), -- cgit