fix clippy issues
This commit is contained in:
@@ -23,6 +23,13 @@ impl SidebarFooter {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for SidebarFooter {
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
}
|
||||
}
|
||||
|
||||
impl Selectable for SidebarFooter {
|
||||
fn selected(mut self, selected: bool) -> Self {
|
||||
self.selected = selected;
|
||||
@@ -33,6 +40,7 @@ impl Selectable for SidebarFooter {
|
||||
&self.id
|
||||
}
|
||||
}
|
||||
|
||||
impl Collapsible for SidebarFooter {
|
||||
fn is_collapsed(&self) -> bool {
|
||||
self.is_collapsed
|
||||
@@ -43,17 +51,21 @@ impl Collapsible for SidebarFooter {
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
impl ParentElement for SidebarFooter {
|
||||
fn extend(&mut self, elements: impl IntoIterator<Item = gpui::AnyElement>) {
|
||||
self.base.extend(elements);
|
||||
}
|
||||
}
|
||||
|
||||
impl Styled for SidebarFooter {
|
||||
fn style(&mut self) -> &mut gpui::StyleRefinement {
|
||||
self.base.style()
|
||||
}
|
||||
}
|
||||
|
||||
impl PopupMenuExt for SidebarFooter {}
|
||||
|
||||
impl RenderOnce for SidebarFooter {
|
||||
fn render(self, cx: &mut gpui::WindowContext) -> impl gpui::IntoElement {
|
||||
h_flex()
|
||||
|
||||
@@ -33,6 +33,7 @@ impl<E: Collapsible + IntoElement> SidebarGroup<E> {
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
impl<E: Collapsible + IntoElement> Collapsible for SidebarGroup<E> {
|
||||
fn is_collapsed(&self) -> bool {
|
||||
self.is_collapsed
|
||||
@@ -43,6 +44,7 @@ impl<E: Collapsible + IntoElement> Collapsible for SidebarGroup<E> {
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
impl<E: Collapsible + IntoElement> RenderOnce for SidebarGroup<E> {
|
||||
fn render(self, cx: &mut WindowContext) -> impl IntoElement {
|
||||
v_flex()
|
||||
|
||||
@@ -23,6 +23,13 @@ impl SidebarHeader {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for SidebarHeader {
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
}
|
||||
}
|
||||
|
||||
impl Selectable for SidebarHeader {
|
||||
fn selected(mut self, selected: bool) -> Self {
|
||||
self.selected = selected;
|
||||
@@ -33,6 +40,7 @@ impl Selectable for SidebarHeader {
|
||||
&self.id
|
||||
}
|
||||
}
|
||||
|
||||
impl Collapsible for SidebarHeader {
|
||||
fn is_collapsed(&self) -> bool {
|
||||
self.is_collapsed
|
||||
@@ -43,17 +51,21 @@ impl Collapsible for SidebarHeader {
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
impl ParentElement for SidebarHeader {
|
||||
fn extend(&mut self, elements: impl IntoIterator<Item = gpui::AnyElement>) {
|
||||
self.base.extend(elements);
|
||||
}
|
||||
}
|
||||
|
||||
impl Styled for SidebarHeader {
|
||||
fn style(&mut self) -> &mut gpui::StyleRefinement {
|
||||
self.base.style()
|
||||
}
|
||||
}
|
||||
|
||||
impl PopupMenuExt for SidebarHeader {}
|
||||
|
||||
impl RenderOnce for SidebarHeader {
|
||||
fn render(self, cx: &mut gpui::WindowContext) -> impl gpui::IntoElement {
|
||||
h_flex()
|
||||
|
||||
@@ -58,6 +58,13 @@ impl SidebarMenu {
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for SidebarMenu {
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
}
|
||||
}
|
||||
|
||||
impl Collapsible for SidebarMenu {
|
||||
fn is_collapsed(&self) -> bool {
|
||||
self.is_collapsed
|
||||
@@ -84,20 +91,22 @@ impl RenderOnce for SidebarMenu {
|
||||
}
|
||||
}
|
||||
|
||||
type Handler = Rc<dyn Fn(&ClickEvent, &mut WindowContext)>;
|
||||
|
||||
/// A sidebar menu item
|
||||
#[derive(IntoElement)]
|
||||
enum SidebarMenuItem {
|
||||
Item {
|
||||
icon: Option<Icon>,
|
||||
label: SharedString,
|
||||
handler: Rc<dyn Fn(&ClickEvent, &mut WindowContext)>,
|
||||
handler: Handler,
|
||||
active: bool,
|
||||
is_collapsed: bool,
|
||||
},
|
||||
Submenu {
|
||||
icon: Option<Icon>,
|
||||
label: SharedString,
|
||||
handler: Rc<dyn Fn(&ClickEvent, &mut WindowContext)>,
|
||||
handler: Handler,
|
||||
items: Vec<SidebarMenuItem>,
|
||||
is_open: bool,
|
||||
is_collapsed: bool,
|
||||
|
||||
@@ -106,13 +106,15 @@ impl<E: Collapsible + IntoElement> Sidebar<E> {
|
||||
}
|
||||
}
|
||||
|
||||
type OnClick = Option<Rc<dyn Fn(&ClickEvent, &mut WindowContext)>>;
|
||||
|
||||
/// Sidebar collapse button with Icon.
|
||||
#[derive(IntoElement)]
|
||||
pub struct SidebarToggleButton {
|
||||
btn: Button,
|
||||
is_collapsed: bool,
|
||||
side: Side,
|
||||
on_click: Option<Rc<dyn Fn(&ClickEvent, &mut WindowContext)>>,
|
||||
on_click: OnClick,
|
||||
}
|
||||
|
||||
impl SidebarToggleButton {
|
||||
@@ -158,12 +160,10 @@ impl RenderOnce for SidebarToggleButton {
|
||||
} else {
|
||||
IconName::PanelRightOpen
|
||||
}
|
||||
} else if self.side.is_left() {
|
||||
IconName::PanelLeftClose
|
||||
} else {
|
||||
if self.side.is_left() {
|
||||
IconName::PanelLeftClose
|
||||
} else {
|
||||
IconName::PanelRightClose
|
||||
}
|
||||
IconName::PanelRightClose
|
||||
};
|
||||
|
||||
self.btn
|
||||
|
||||
Reference in New Issue
Block a user