Make clicking ListHeader
labels toggle the disclosure (#4140)
This PR makes clicking the label inside of a `ListHeader` with a disclosure also toggle the disclosure. Release Notes: - Added support for clicking the "Online", "Offline", and "Requests" headers in the contact list to toggle their expansion.
This commit is contained in:
parent
f3a76c8636
commit
0691ad480b
3 changed files with 18 additions and 8 deletions
|
@ -1,3 +1,5 @@
|
|||
use std::sync::Arc;
|
||||
|
||||
use gpui::ClickEvent;
|
||||
|
||||
use crate::{prelude::*, Color, IconButton, IconName, IconSize};
|
||||
|
@ -6,7 +8,7 @@ use crate::{prelude::*, Color, IconButton, IconName, IconSize};
|
|||
pub struct Disclosure {
|
||||
id: ElementId,
|
||||
is_open: bool,
|
||||
on_toggle: Option<Box<dyn Fn(&ClickEvent, &mut WindowContext) + 'static>>,
|
||||
on_toggle: Option<Arc<dyn Fn(&ClickEvent, &mut WindowContext) + 'static>>,
|
||||
}
|
||||
|
||||
impl Disclosure {
|
||||
|
@ -20,7 +22,7 @@ impl Disclosure {
|
|||
|
||||
pub fn on_toggle(
|
||||
mut self,
|
||||
handler: impl Into<Option<Box<dyn Fn(&ClickEvent, &mut WindowContext) + 'static>>>,
|
||||
handler: impl Into<Option<Arc<dyn Fn(&ClickEvent, &mut WindowContext) + 'static>>>,
|
||||
) -> Self {
|
||||
self.on_toggle = handler.into();
|
||||
self
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue