use filamento::chat::Delivery;
use iced::widget::svg;
use iced::widget::{svg::Handle, Svg};
use iced::{color, Element, Theme};
pub enum Icon {
AddContact24,
Attachment24,
Away16,
Away16Color,
Bubble16,
Bubble16Color,
Bubble24,
Contact24,
Delivered16,
Dnd16,
Dnd16Color,
Error16Color,
Forward24,
Heart24,
NewBubble24,
Reply24,
Sending16,
Sent16,
}
impl Icon {
pub fn svg(self) -> Svg<'static> {
self.into()
}
}
impl From<Icon> for Svg<'_> {
fn from(value: Icon) -> Self {
match value {
Icon::AddContact24 => svg(Handle::from_memory(include_bytes!(
"../assets/icons/addcontact24.svg"
)))
.width(24)
.height(24)
.style(|theme: &Theme, _status| svg::Style {
color: Some(theme.extended_palette().background.base.text),
}),
Icon::Attachment24 => svg(Handle::from_memory(include_bytes!(
"../assets/icons/attachment24.svg"
)))
.width(24)
.height(24)
.style(|theme: &Theme, _status| svg::Style {
color: Some(theme.extended_palette().background.base.text),
}),
Icon::Away16 => svg(Handle::from_memory(include_bytes!(
"../assets/icons/away16.svg"
)))
.width(16)
.height(16)
.style(|theme: &Theme, _status| svg::Style {
color: Some(theme.extended_palette().background.base.text),
}),
Icon::Away16Color => svg(Handle::from_memory(include_bytes!(
"../assets/icons/away16color.svg"
)))
.width(16)
.height(16),
Icon::Bubble16 => svg(Handle::from_memory(include_bytes!(
"../assets/icons/bubble16.svg"
)))
.width(16)
.height(16)
.style(|theme: &Theme, _status| svg::Style {
color: Some(theme.extended_palette().background.base.text),
}),
Icon::Bubble16Color => svg(Handle::from_memory(include_bytes!(
"../assets/icons/bubble16color.svg"
)))
.width(16)
.height(16),
Icon::Bubble24 => svg(Handle::from_memory(include_bytes!(
"../assets/icons/bubble24.svg"
)))
.width(24)
.height(24)
.style(|theme: &Theme, _status| svg::Style {
color: Some(theme.extended_palette().background.base.text),
}),
Icon::Contact24 => svg(Handle::from_memory(include_bytes!(
"../assets/icons/contact24.svg"
)))
.width(24)
.height(24)
.style(|theme: &Theme, _status| svg::Style {
color: Some(theme.extended_palette().background.base.text),
}),
Icon::Delivered16 => svg(Handle::from_memory(include_bytes!(
"../assets/icons/delivered16.svg"
)))
.width(16)
.height(16)
.style(|theme: &Theme, _status| svg::Style {
color: Some(theme.extended_palette().background.base.text),
}),
Icon::Dnd16 => svg(Handle::from_memory(include_bytes!(
"../assets/icons/dnd16.svg"
)))
.width(16)
.height(16)
.style(|theme: &Theme, _status| svg::Style {
color: Some(theme.extended_palette().background.base.text),
}),
Icon::Dnd16Color => svg(Handle::from_memory(include_bytes!(
"../assets/icons/dnd16color.svg"
)))
.width(16)
.height(16),
Icon::Error16Color => svg(Handle::from_memory(include_bytes!(
"../assets/icons/error16color.svg"
)))
.width(16)
.height(16),
Icon::Forward24 => svg(Handle::from_memory(include_bytes!(
"../assets/icons/forward24.svg"
)))
.width(24)
.height(24)
.style(|theme: &Theme, _status| svg::Style {
color: Some(theme.extended_palette().background.base.text),
}),
Icon::Heart24 => svg(Handle::from_memory(include_bytes!(
"../assets/icons/heart24.svg"
)))
.width(24)
.height(24)
.style(|theme: &Theme, _status| svg::Style {
color: Some(theme.extended_palette().background.base.text),
}),
Icon::NewBubble24 => svg(Handle::from_memory(include_bytes!(
"../assets/icons/newbubble24.svg"
)))
.width(24)
.height(24)
.style(|theme: &Theme, _status| svg::Style {
color: Some(theme.extended_palette().background.base.text),
}),
Icon::Reply24 => svg(Handle::from_memory(include_bytes!(
"../assets/icons/reply24.svg"
)))
.width(24)
.height(24)
.style(|theme: &Theme, _status| svg::Style {
color: Some(theme.extended_palette().background.base.text),
}),
Icon::Sending16 => svg(Handle::from_memory(include_bytes!(
"../assets/icons/sending16.svg"
)))
.width(16)
.height(16)
.style(|theme: &Theme, _status| svg::Style {
color: Some(theme.extended_palette().background.base.text),
}),
Icon::Sent16 => svg(Handle::from_memory(include_bytes!(
"../assets/icons/sent16.svg"
)))
.width(16)
.height(16)
.style(|theme: &Theme, _status| svg::Style {
color: Some(theme.extended_palette().background.base.text),
}),
}
}
}
impl<Message> From<Icon> for Element<'_, Message> {
fn from(value: Icon) -> Self {
Into::<Svg>::into(value).into()
}
}
pub fn delivery_to_icon_svg(delivery: Delivery) -> Option<Svg<'static>> {
match delivery {
Delivery::Sending => Some(Icon::Sending16.into()),
Delivery::Written => None,
Delivery::Sent => Some(Icon::Sent16.into()),
Delivery::Delivered => Some(Icon::Delivered16.into()),
Delivery::Read => Some(Icon::Delivered16.svg().style(|_theme, _| svg::Style {
color: Some(color!(0x52cf6e)),
})),
Delivery::Failed => Some(Icon::Error16Color.into()),
Delivery::Queued => Some(Icon::Sending16.into()),
}
}