Make toggle
method accept impl Into<Option<bool>>
(#3446)
This PR makes the `toggle` method on the various list components accept an `impl Into<Option<bool>>` instead of just an `Option<bool>`. This allows a caller with just a `bool` avoid having to wrap the `Option` themselves. Release Notes: - N/A
This commit is contained in:
parent
fb377aed73
commit
df5de47a78
5 changed files with 10 additions and 11 deletions
|
@ -2505,7 +2505,7 @@ impl CollabPanel {
|
||||||
.when_some(button, |el, button| el.right_button(button))
|
.when_some(button, |el, button| el.right_button(button))
|
||||||
.selected(is_selected)
|
.selected(is_selected)
|
||||||
.when(can_collapse, |el| {
|
.when(can_collapse, |el| {
|
||||||
el.toggle(Some(is_collapsed)).on_toggle(
|
el.toggle(is_collapsed).on_toggle(
|
||||||
cx.listener(move |this, _, cx| this.toggle_section_expanded(section, cx)),
|
cx.listener(move |this, _, cx| this.toggle_section_expanded(section, cx)),
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
|
|
|
@ -34,10 +34,9 @@ impl RenderOnce for Disclosure {
|
||||||
fn render(self, _cx: &mut WindowContext) -> Self::Rendered {
|
fn render(self, _cx: &mut WindowContext) -> Self::Rendered {
|
||||||
IconButton::new(
|
IconButton::new(
|
||||||
"toggle",
|
"toggle",
|
||||||
if self.is_open {
|
match self.is_open {
|
||||||
Icon::ChevronDown
|
true => Icon::ChevronDown,
|
||||||
} else {
|
false => Icon::ChevronRight,
|
||||||
Icon::ChevronRight
|
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
.color(Color::Muted)
|
.color(Color::Muted)
|
||||||
|
|
|
@ -44,8 +44,8 @@ impl List {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn toggle(mut self, toggle: Option<bool>) -> Self {
|
pub fn toggle(mut self, toggle: impl Into<Option<bool>>) -> Self {
|
||||||
self.toggle = toggle;
|
self.toggle = toggle.into();
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,8 +36,8 @@ impl ListHeader {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn toggle(mut self, toggle: Option<bool>) -> Self {
|
pub fn toggle(mut self, toggle: impl Into<Option<bool>>) -> Self {
|
||||||
self.toggle = toggle;
|
self.toggle = toggle.into();
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -70,8 +70,8 @@ impl ListItem {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn toggle(mut self, toggle: Option<bool>) -> Self {
|
pub fn toggle(mut self, toggle: impl Into<Option<bool>>) -> Self {
|
||||||
self.toggle = toggle;
|
self.toggle = toggle.into();
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue