feat: support app-defined icon sets
This commit is contained in:
@@ -9,7 +9,7 @@ use gpui::{
|
||||
IntoElement, ParentElement as _, RenderOnce, SharedString, StatefulInteractiveElement as _,
|
||||
Styled as _, Task, Window, deferred, div, ease_out_quint, px,
|
||||
};
|
||||
use gpui_native_icons::{IconRole, icon};
|
||||
use gpui_native_icons::{Icon, IconRole, icon};
|
||||
use gpui_native_theme::ActiveTheme as _;
|
||||
|
||||
use crate::button::{Button, ButtonVariant};
|
||||
@@ -43,7 +43,7 @@ impl ToastAction {
|
||||
#[derive(Clone)]
|
||||
pub struct Toast {
|
||||
message: SharedString,
|
||||
icon: Option<IconRole>,
|
||||
icon: Option<Icon>,
|
||||
action: Option<ToastAction>,
|
||||
duration: Option<Duration>,
|
||||
on_dismiss: Option<DismissHandler>,
|
||||
@@ -68,8 +68,11 @@ impl Toast {
|
||||
}
|
||||
|
||||
/// Shows this glyph before the content.
|
||||
pub fn icon(mut self, role: IconRole) -> Self {
|
||||
self.icon = Some(role);
|
||||
pub fn icon<I>(mut self, icon: I) -> Self
|
||||
where
|
||||
I: Into<Icon>,
|
||||
{
|
||||
self.icon = Some(icon.into());
|
||||
self
|
||||
}
|
||||
|
||||
@@ -285,14 +288,14 @@ fn pill(entry: &ToastEntry, toasts: &Entity<Toasts>, cx: &App) -> gpui::Stateful
|
||||
.border_color(border)
|
||||
.rounded(radius)
|
||||
.shadow(shadows.clone())
|
||||
.when_some(toast.icon, |pill, icon_role| {
|
||||
.when_some(toast.icon.clone(), |pill, icon| {
|
||||
pill.child(
|
||||
div()
|
||||
.flex_none()
|
||||
.mr_2()
|
||||
.flex()
|
||||
.items_center()
|
||||
.child(icon(icon_role).size(icon_size).color(foreground)),
|
||||
.child(icon.size(icon_size).color(foreground)),
|
||||
)
|
||||
})
|
||||
.child(
|
||||
|
||||
Reference in New Issue
Block a user