|
| 1 | +use iced::widget::{Row, Text}; |
| 2 | +use iced::{Alignment::Center, Font, Length::Fixed, font}; |
| 3 | +use iced::{Color, Element}; |
| 4 | + |
| 5 | +use super::THEME_ICON_SIZE; |
| 6 | + |
| 7 | +pub(crate) fn load_fonts() -> Vec<std::borrow::Cow<'static, [u8]>> { |
| 8 | + vec![include_bytes!("./plume_icons.ttf").as_slice().into()] |
| 9 | +} |
| 10 | + |
| 11 | +pub(crate) const GEAR: &str = "\u{e800}"; |
| 12 | +pub(crate) const CHEVRON_BACK: &str = "\u{e801}"; |
| 13 | +pub(crate) const DOWNLOAD: &str = "\u{e802}"; |
| 14 | +pub(crate) const STAR: &str = "\u{e803}"; |
| 15 | +pub(crate) const WRENCH: &str = "\u{e804}"; |
| 16 | +pub(crate) const PLUS: &str = "\u{e805}"; |
| 17 | +pub(crate) const MINUS: &str = "\u{e806}"; |
| 18 | +pub(crate) const SHARE: &str = "\u{e807}"; |
| 19 | +pub(crate) const FILE: &str = "\u{f15b}"; |
| 20 | + |
| 21 | +pub(crate) fn icon_text<M: 'static>( |
| 22 | + icon: &'static str, |
| 23 | + label: &'static str, |
| 24 | + color: Option<Color>, |
| 25 | +) -> Element<'static, M> { |
| 26 | + let icon_font = Font { |
| 27 | + family: iced::font::Family::Name("plume_icons".into()), |
| 28 | + weight: iced::font::Weight::Normal, |
| 29 | + stretch: iced::font::Stretch::Normal, |
| 30 | + style: iced::font::Style::Normal, |
| 31 | + }; |
| 32 | + |
| 33 | + let mut row = Row::new().spacing(10).align_y(Center); |
| 34 | + |
| 35 | + let mut icon_text_widget = Text::new(icon) |
| 36 | + .font(icon_font) |
| 37 | + .width(Fixed(THEME_ICON_SIZE)); |
| 38 | + if let Some(c) = color { |
| 39 | + icon_text_widget = icon_text_widget.color(c); |
| 40 | + } |
| 41 | + row = row.push(icon_text_widget); |
| 42 | + |
| 43 | + let mut label_widget = Text::new(label); |
| 44 | + if let Some(c) = color { |
| 45 | + label_widget = label_widget.color(c); |
| 46 | + } |
| 47 | + row = row.push(label_widget); |
| 48 | + |
| 49 | + row.into() |
| 50 | +} |
| 51 | + |
| 52 | +pub(crate) fn icon(icon: &'static str) -> Text<'static> { |
| 53 | + let icon_font = Font { |
| 54 | + family: font::Family::Name("plume_icons".into()), |
| 55 | + weight: font::Weight::Normal, |
| 56 | + stretch: font::Stretch::Normal, |
| 57 | + style: font::Style::Normal, |
| 58 | + }; |
| 59 | + |
| 60 | + Text::new(icon) |
| 61 | + .font(icon_font) |
| 62 | + .align_x(Center) |
| 63 | + .width(Fixed(THEME_ICON_SIZE)) |
| 64 | +} |
0 commit comments