aboutsummaryrefslogtreecommitdiffstats
path: root/src/icons.rs
blob: 63e7708c6c3c496a8781f884e98d75c650f8829c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
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()),
    }
}