BlueGit

ict rusty-teams

Files

rusty-teams / crates / app-base / src / assets.rs

assets.rs

assets.rs 2.4 KiB Download Raw
1use std::borrow::Cow;
2
3use gpui_kit::{AssetSource, Result, SharedString};
4
5macro_rules! symbols {
6 ($($name:literal),* $(,)?) => {
7 [$((concat!("symbols/", $name, ".svg"), include_bytes!(concat!("../../app/assets/symbols/", $name, ".svg")) as &[u8])),*]
8 };
9}
10
11const SYMBOLS: [(&str, &[u8]); 73] = symbols![
12 "bot",
13 "done",
14 "table",
15 "done_all",
16 "keyboard_return",
17 "schedule",
18 "schedule_send",
19 "event",
20 "wb_sunny",
21 "work",
22 "close",
23 "reply",
24 "group",
25 "tag",
26 "image",
27 "check_circle",
28 "error",
29 "notifications",
30 "content_copy",
31 "attach_file",
32 "upload",
33 "download",
34 "folder_open",
35 "refresh",
36 "code",
37 "link",
38 "format_list_bulleted",
39 "format_list_numbered",
40 "format_quote",
41 "mood",
42 "status_dot",
43 "status_dnd",
44 "status_away",
45 "status_ring",
46 "zoom_in",
47 "zoom_out",
48 "rotate_right",
49 "forward",
50 "open_in_new",
51 "chevron_left",
52 "chevron_right",
53 "fullscreen",
54 "spinner_track",
55 "spinner_arc",
56 "shield",
57 "call",
58 "call_missed",
59 "videocam",
60 "fluent_video",
61 "fluent_record",
62 "fluent_record_stop",
63 "fluent_cloud_arrow_up",
64 "fluent_share",
65 "fluent_clock",
66 "fluent_document_text",
67 "fluent_text_edit_style",
68 "fluent_text_edit_style_filled",
69 "fluent_table_add",
70 "fluent_table_dismiss",
71 "fluent_important",
72 "fluent_important_filled",
73 "fluent_alert_urgent",
74 "fluent_alert_urgent_filled",
75 "fluent_chat",
76 "fluent_text_color",
77 "fluent_highlight",
78 "fluent_text_indent_increase",
79 "fluent_text_indent_decrease",
80 "fluent_line_horizontal_1",
81 "fluent_text_clear_formatting",
82 "fluent_code_block",
83 "fluent_text_header_1",
84 "fluent_text_font_size",
85];
86
87pub struct AppAssets;
88
89impl AssetSource for AppAssets {
90 fn load(&self, path: &str) -> Result<Option<Cow<'static, [u8]>>> {
91 if let Some((_, bytes)) = SYMBOLS.iter().find(|(name, _)| *name == path) {
92 return Ok(Some(Cow::Borrowed(bytes)));
93 }
94 gpui_kit::assets::AllAssets.load(path)
95 }
96
97 fn list(&self, path: &str) -> Result<Vec<SharedString>> {
98 let mut names = gpui_kit::assets::AllAssets.list(path)?;
99 names.extend(
100 SYMBOLS
101 .iter()
102 .filter(|(name, _)| name.starts_with(path))
103 .map(|(name, _)| SharedString::from(*name)),
104 );
105 Ok(names)
106 }
107}