BlueGit

ict rusty-teams

Files

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

assets.rs

assets.rs 2.5 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]); 75] = 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 "status_available",
47 "status_offline",
48 "zoom_in",
49 "zoom_out",
50 "rotate_right",
51 "forward",
52 "open_in_new",
53 "chevron_left",
54 "chevron_right",
55 "fullscreen",
56 "spinner_track",
57 "spinner_arc",
58 "shield",
59 "call",
60 "call_missed",
61 "videocam",
62 "fluent_video",
63 "fluent_record",
64 "fluent_record_stop",
65 "fluent_cloud_arrow_up",
66 "fluent_share",
67 "fluent_clock",
68 "fluent_document_text",
69 "fluent_text_edit_style",
70 "fluent_text_edit_style_filled",
71 "fluent_table_add",
72 "fluent_table_dismiss",
73 "fluent_important",
74 "fluent_important_filled",
75 "fluent_alert_urgent",
76 "fluent_alert_urgent_filled",
77 "fluent_chat",
78 "fluent_text_color",
79 "fluent_highlight",
80 "fluent_text_indent_increase",
81 "fluent_text_indent_decrease",
82 "fluent_line_horizontal_1",
83 "fluent_text_clear_formatting",
84 "fluent_code_block",
85 "fluent_text_header_1",
86 "fluent_text_font_size",
87];
88
89pub struct AppAssets;
90
91impl AssetSource for AppAssets {
92 fn load(&self, path: &str) -> Result<Option<Cow<'static, [u8]>>> {
93 if let Some((_, bytes)) = SYMBOLS.iter().find(|(name, _)| *name == path) {
94 return Ok(Some(Cow::Borrowed(bytes)));
95 }
96 gpui_kit::assets::AllAssets.load(path)
97 }
98
99 fn list(&self, path: &str) -> Result<Vec<SharedString>> {
100 let mut names = gpui_kit::assets::AllAssets.list(path)?;
101 names.extend(
102 SYMBOLS
103 .iter()
104 .filter(|(name, _)| name.starts_with(path))
105 .map(|(name, _)| SharedString::from(*name)),
106 );
107 Ok(names)
108 }
109}