feat(icon): optimize & bundle icons with crabtime for non-unix platforms
This commit is contained in:
parent
ce0868582b
commit
639326fcc3
27 changed files with 128 additions and 189 deletions
|
|
@ -2,7 +2,7 @@
|
|||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use super::{Handle, Icon};
|
||||
use std::{borrow::Cow, path::PathBuf, sync::Arc};
|
||||
use std::{borrow::Cow, ffi::OsStr, path::PathBuf, sync::Arc};
|
||||
|
||||
#[derive(Debug, Clone, Default, Hash)]
|
||||
/// Fallback icon to use if the icon was not found.
|
||||
|
|
@ -116,9 +116,21 @@ impl Named {
|
|||
|
||||
#[inline]
|
||||
pub fn handle(self) -> Handle {
|
||||
let name = self.name.clone();
|
||||
Handle {
|
||||
symbolic: self.symbolic,
|
||||
data: super::Data::Name(self),
|
||||
data: if let Some(path) = self.path() {
|
||||
if path.extension().is_some_and(|ext| ext == OsStr::new("svg")) {
|
||||
super::Data::Svg(iced_core::svg::Handle::from_path(path))
|
||||
} else {
|
||||
super::Data::Image(iced_core::image::Handle::from_path(path))
|
||||
}
|
||||
} else {
|
||||
super::bundle::get(&name).unwrap_or_else(|| {
|
||||
let bytes: &'static [u8] = &[];
|
||||
super::Data::Svg(iced_core::svg::Handle::from_memory(bytes))
|
||||
})
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue