Skip to main content

cosmic_applet_avestruz/views/components/
icons.rs

1// SPDX-License-Identifier: MIT
2
3//! Icons embedded in the binary.
4
5use cosmic::widget::icon;
6
7/// The app icon. Embedded rather than looked up by name in the icon theme, so
8/// it is there before the applet is installed.
9const APP_ICON_SVG: &[u8] = include_bytes!("../../../resources/icon.svg");
10
11/// The icons of a note's actions. The icon theme has none for a zap, and
12/// those it has for the others don't make a set with it.
13const REPLY_ICON_SVG: &[u8] = include_bytes!("../../../resources/icons/reply-symbolic.svg");
14const REPOST_ICON_SVG: &[u8] = include_bytes!("../../../resources/icons/repost-symbolic.svg");
15const LIKE_ICON_SVG: &[u8] = include_bytes!("../../../resources/icons/like-symbolic.svg");
16const LIKED_ICON_SVG: &[u8] = include_bytes!("../../../resources/icons/liked-symbolic.svg");
17const BOOKMARK_ICON_SVG: &[u8] = include_bytes!("../../../resources/icons/bookmark-symbolic.svg");
18const BOOKMARKED_ICON_SVG: &[u8] = include_bytes!("../../../resources/icons/bookmarked-symbolic.svg");
19const ZAP_ICON_SVG: &[u8] = include_bytes!("../../../resources/icons/zap-symbolic.svg");
20const RELAYS_ICON_SVG: &[u8] = include_bytes!("../../../resources/icons/relays-symbolic.svg");
21const LINK_ICON_SVG: &[u8] = include_bytes!("../../../resources/icons/link-symbolic.svg");
22
23/// A bell: what the account is told of. The icon theme's are filled or
24/// outlined as the theme likes, and this one goes with the others here.
25const BELL_ICON_SVG: &[u8] = include_bytes!("../../../resources/icons/bell-symbolic.svg");
26
27/// The icons of the way to the rest of a long note, and back. The icon
28/// theme has arrows that go one way, and these go two.
29const SHOW_MORE_ICON_SVG: &[u8] = include_bytes!("../../../resources/icons/show-more-symbolic.svg");
30const SHOW_LESS_ICON_SVG: &[u8] = include_bytes!("../../../resources/icons/show-less-symbolic.svg");
31
32/// An embedded icon that is drawn in whatever colour it is given.
33fn symbolic(svg: &'static [u8]) -> icon::Handle {
34    let mut handle = icon::from_svg_bytes(svg);
35    handle.symbolic = true;
36    handle
37}
38
39/// A speech bubble: answering a note.
40pub fn reply_icon() -> icon::Handle {
41    symbolic(REPLY_ICON_SVG)
42}
43
44/// Two arrows, each after the other: passing a note on.
45pub fn repost_icon() -> icon::Handle {
46    symbolic(REPOST_ICON_SVG)
47}
48
49/// A heart: in outline for a note that can be liked, filled for one that is.
50pub fn like_icon(liked: bool) -> icon::Handle {
51    symbolic(if liked { LIKED_ICON_SVG } else { LIKE_ICON_SVG })
52}
53
54/// A bolt of lightning: what a note was zapped.
55pub fn zap_icon() -> icon::Handle {
56    symbolic(ZAP_ICON_SVG)
57}
58
59/// A ribbon: in outline for a note that can be bookmarked, filled for one
60/// that is.
61pub fn bookmark_icon(bookmarked: bool) -> icon::Handle {
62    symbolic(if bookmarked { BOOKMARKED_ICON_SVG } else { BOOKMARK_ICON_SVG })
63}
64
65/// Two links of a chain: a link to a note, to give to someone.
66pub fn link_icon() -> icon::Handle {
67    symbolic(LINK_ICON_SVG)
68}
69
70/// Two arrowheads: pointing apart, for showing more of a long note, or at
71/// each other, for showing `less` of it.
72pub fn fold_icon(less: bool) -> icon::Handle {
73    symbolic(if less { SHOW_LESS_ICON_SVG } else { SHOW_MORE_ICON_SVG })
74}
75
76/// A bell: the way to what the account is told of.
77pub fn bell_icon() -> icon::Handle {
78    symbolic(BELL_ICON_SVG)
79}
80
81/// Two machines, one on the other: the relays a note was seen on.
82pub fn relays_icon() -> icon::Handle {
83    symbolic(RELAYS_ICON_SVG)
84}
85
86/// The app icon. A symbolic icon wherever it is shown: drawn in the theme's
87/// foreground colour, which can be told from a dark ground and from a light
88/// one, as the colour in the file cannot.
89pub fn app_icon() -> icon::Handle {
90    symbolic(APP_ICON_SVG)
91}