feat: support app-defined icon sets
This commit is contained in:
+10
-11
@@ -6,7 +6,7 @@ use gpui::{
|
||||
ParentElement as _, RenderOnce, Role, SharedString, StatefulInteractiveElement as _,
|
||||
Styled as _, Window, div,
|
||||
};
|
||||
use gpui_native_icons::{IconRole, icon};
|
||||
use gpui_native_icons::Icon;
|
||||
use gpui_native_theme::ActiveTheme as _;
|
||||
use gpui_native_utils::{nav_key, paint_selectable_row, selectable_label_color};
|
||||
|
||||
@@ -17,7 +17,7 @@ type ItemsFn = Box<dyn Fn(&mut Window, &mut App) -> Vec<ListItem>>;
|
||||
/// One row of a [`List`].
|
||||
pub struct ListItem {
|
||||
label: SharedString,
|
||||
icon: Option<IconRole>,
|
||||
icon: Option<Icon>,
|
||||
detail: Option<SharedString>,
|
||||
disabled: bool,
|
||||
}
|
||||
@@ -36,9 +36,12 @@ impl ListItem {
|
||||
}
|
||||
}
|
||||
|
||||
/// Shows an icon leading the label.
|
||||
pub fn icon(mut self, role: IconRole) -> Self {
|
||||
self.icon = Some(role);
|
||||
/// Shows an icon leading the label, a role or any custom [`IconNamed`].
|
||||
pub fn icon<I>(mut self, icon: I) -> Self
|
||||
where
|
||||
I: Into<Icon>,
|
||||
{
|
||||
self.icon = Some(icon.into());
|
||||
self
|
||||
}
|
||||
|
||||
@@ -222,12 +225,8 @@ fn render_row(
|
||||
}
|
||||
})
|
||||
})
|
||||
.when_some(item.icon, |row, role| {
|
||||
row.child(
|
||||
icon(role)
|
||||
.size(theme.sizes.medium.icon_size)
|
||||
.color(label_color),
|
||||
)
|
||||
.when_some(item.icon.clone(), |row, icon| {
|
||||
row.child(icon.size(theme.sizes.medium.icon_size).color(label_color))
|
||||
})
|
||||
.child(
|
||||
div()
|
||||
|
||||
Reference in New Issue
Block a user