@@ -24,17 +24,17 @@ pub use iced_style::toggler::{Appearance, StyleSheet};
2424/// TogglerToggled(bool),
2525/// }
2626///
27- /// let is_active = true;
27+ /// let is_checked = true;
2828///
29- /// Toggler::new(is_active, String::from("Toggle me!"), |b| Message::TogglerToggled(b));
29+ /// Toggler::new(String::from("Toggle me!"), is_checked , |b| Message::TogglerToggled(b));
3030/// ```
3131#[ allow( missing_debug_implementations) ]
3232pub struct Toggler < ' a , Message , Renderer >
3333where
3434 Renderer : text:: Renderer ,
3535 Renderer :: Theme : StyleSheet ,
3636{
37- is_active : bool ,
37+ is_checked : bool ,
3838 on_toggle : Box < dyn Fn ( bool ) -> Message + ' a > ,
3939 label : Option < String > ,
4040 width : Length ,
@@ -63,15 +63,15 @@ where
6363 /// will receive the new state of the [`Toggler`] and must produce a
6464 /// `Message`.
6565 pub fn new < F > (
66- is_active : bool ,
6766 label : impl Into < Option < String > > ,
67+ is_checked : bool ,
6868 f : F ,
6969 ) -> Self
7070 where
7171 F : ' a + Fn ( bool ) -> Message ,
7272 {
7373 Toggler {
74- is_active ,
74+ is_checked ,
7575 on_toggle : Box :: new ( f) ,
7676 label : label. into ( ) ,
7777 width : Length :: Fill ,
@@ -193,7 +193,7 @@ where
193193 let mouse_over = layout. bounds ( ) . contains ( cursor_position) ;
194194
195195 if mouse_over {
196- shell. publish ( ( self . on_toggle ) ( !self . is_active ) ) ;
196+ shell. publish ( ( self . on_toggle ) ( !self . is_checked ) ) ;
197197
198198 event:: Status :: Captured
199199 } else {
@@ -260,9 +260,9 @@ where
260260 let is_mouse_over = bounds. contains ( cursor_position) ;
261261
262262 let style = if is_mouse_over {
263- theme. hovered ( & self . style , self . is_active )
263+ theme. hovered ( & self . style , self . is_checked )
264264 } else {
265- theme. active ( & self . style , self . is_active )
265+ theme. active ( & self . style , self . is_checked )
266266 } ;
267267
268268 let border_radius = bounds. height / BORDER_RADIUS_RATIO ;
@@ -289,7 +289,7 @@ where
289289
290290 let toggler_foreground_bounds = Rectangle {
291291 x : bounds. x
292- + if self . is_active {
292+ + if self . is_checked {
293293 bounds. width - 2.0 * space - ( bounds. height - ( 4.0 * space) )
294294 } else {
295295 2.0 * space
0 commit comments