1use gpui::{
2 color::Color,
3 elements::{MouseEventHandler, Svg},
4 Appearance, Element, ElementBox, Entity, MouseButton, RenderContext, View,
5};
6
7use crate::ToggleScreenSharing;
8
9pub struct SharingStatusIndicator;
10
11impl Entity for SharingStatusIndicator {
12 type Event = ();
13}
14
15impl View for SharingStatusIndicator {
16 fn ui_name() -> &'static str {
17 "SharingStatusIndicator"
18 }
19
20 fn render(&mut self, cx: &mut RenderContext<'_, Self>) -> ElementBox {
21 let color = match cx.appearance {
22 Appearance::Light | Appearance::VibrantLight => Color::black(),
23 Appearance::Dark | Appearance::VibrantDark => Color::white(),
24 };
25
26 MouseEventHandler::<Self>::new(0, cx, |_, _| {
27 Svg::new("icons/disable_screen_sharing_12.svg")
28 .with_color(color)
29 .constrained()
30 .with_width(18.)
31 .aligned()
32 .boxed()
33 })
34 .on_click(MouseButton::Left, |_, cx| {
35 cx.dispatch_action(ToggleScreenSharing);
36 })
37 .boxed()
38 }
39}