Primitives · Icon::from_path draws an application's SVG with the theme's size and color; a path the asset source lacks fails at render
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
2f02c82c6a
commit
2fb505ee98
9 files changed
+145
-17
No files matched your search
@@ -0,0 +1,25 @@
|
||||
use std::borrow::Cow;
|
||||
|
||||
use ely_gpui_component::Assets;
|
||||
use gpui::{AssetSource, SharedString};
|
||||
|
||||
pub const CUSTOM_ICON: &str = "app-icons/mark.svg";
|
||||
|
||||
pub struct GalleryAssets;
|
||||
|
||||
impl AssetSource for GalleryAssets {
|
||||
fn load(&self, path: &str) -> gpui::Result<Option<Cow<'static, [u8]>>> {
|
||||
if path == CUSTOM_ICON {
|
||||
return Ok(Some(Cow::Borrowed(include_bytes!("../assets/mark.svg"))));
|
||||
}
|
||||
Assets.load(path)
|
||||
}
|
||||
|
||||
fn list(&self, path: &str) -> gpui::Result<Vec<SharedString>> {
|
||||
let mut assets = Assets.list(path)?;
|
||||
if CUSTOM_ICON.starts_with(path) {
|
||||
assets.push(CUSTOM_ICON.into());
|
||||
}
|
||||
Ok(assets)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user