diff options
author | 2025-04-22 18:23:29 +0100 | |
---|---|---|
committer | 2025-04-22 18:23:29 +0100 | |
commit | 8d159c86349803658e2b531ea7ca8e0471a7cc9c (patch) | |
tree | c7bcd671a00f1d5add7d1dbde10a13fda6984216 /src/icons.rs | |
parent | 14f6aaf18a3311fee63b11d0ec9c12ba76b70fa1 (diff) | |
download | macaw-8d159c86349803658e2b531ea7ca8e0471a7cc9c.tar.gz macaw-8d159c86349803658e2b531ea7ca8e0471a7cc9c.tar.bz2 macaw-8d159c86349803658e2b531ea7ca8e0471a7cc9c.zip |
Diffstat (limited to 'src/icons.rs')
-rw-r--r-- | src/icons.rs | 93 |
1 files changed, 78 insertions, 15 deletions
diff --git a/src/icons.rs b/src/icons.rs index 934a0c8..63e7708 100644 --- a/src/icons.rs +++ b/src/icons.rs @@ -1,6 +1,7 @@ +use filamento::chat::Delivery; use iced::widget::svg; use iced::widget::{svg::Handle, Svg}; -use iced::Element; +use iced::{color, Element, Theme}; pub enum Icon { AddContact24, @@ -23,6 +24,12 @@ pub enum Icon { Sent16, } +impl Icon { + pub fn svg(self) -> Svg<'static> { + self.into() + } +} + impl From<Icon> for Svg<'_> { fn from(value: Icon) -> Self { match value { @@ -30,17 +37,26 @@ impl From<Icon> for Svg<'_> { "../assets/icons/addcontact24.svg" ))) .width(24) - .height(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), + .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), + .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" ))) @@ -50,7 +66,10 @@ impl From<Icon> for Svg<'_> { "../assets/icons/bubble16.svg" ))) .width(16) - .height(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" ))) @@ -60,22 +79,34 @@ impl From<Icon> for Svg<'_> { "../assets/icons/bubble24.svg" ))) .width(24) - .height(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), + .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), + .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), + .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" ))) @@ -90,32 +121,50 @@ impl From<Icon> for Svg<'_> { "../assets/icons/forward24.svg" ))) .width(24) - .height(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), + .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), + .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), + .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), + .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), + .height(16) + .style(|theme: &Theme, _status| svg::Style { + color: Some(theme.extended_palette().background.base.text), + }), } } } @@ -125,3 +174,17 @@ impl<Message> From<Icon> for Element<'_, Message> { 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()), + } +} |