BlueGit

ict rusty-teams

Files

rusty-teams / crates / app / src / views / call_mini.rs

call_mini.rs

call_mini.rs 3.9 KiB Download Raw
1use std::time::Instant;
2
3use gpui_kit::assets::IconName;
4use gpui_kit::component::{h_flex, v_flex};
5use gpui_kit::prelude::FluentBuilder as _;
6use gpui_kit::*;
7
8use super::call_view::{leave_button, mute_button, status_line};
9use super::widgets::icon;
10use crate::app_state::AppState;
11use crate::theme;
12
13pub const MINI_WIDTH: f32 = 220.;
14const MINI_RIGHT: f32 = 16.;
15const MINI_BOTTOM: f32 = 40.;
16const MUTE_SIZE: f32 = 28.;
17
18fn sharing_badge(app: &Entity<AppState>) -> Stateful<Div> {
19 let stop_app = app.clone();
20 h_flex()
21 .id("call-mini-sharing")
22 .gap(px(8.))
23 .items_center()
24 .justify_between()
25 .child(
26 h_flex()
27 .gap(px(6.))
28 .items_center()
29 .text_size(px(12.))
30 .font_weight(FontWeight::SEMIBOLD)
31 .text_color(theme::red())
32 .child(icon(IconName::ScreenShare, 14., theme::red()))
33 .child("Sharing"),
34 )
35 .child(
36 div()
37 .id("call-mini-stop-sharing")
38 .h(px(24.))
39 .px(px(10.))
40 .flex()
41 .items_center()
42 .rounded_full()
43 .bg(theme::red())
44 .text_color(theme::white())
45 .text_size(px(12.))
46 .font_weight(FontWeight::SEMIBOLD)
47 .cursor_pointer()
48 .hover(|button| button.opacity(0.85))
49 .child("Stop")
50 .on_click(move |_, _, cx| {
51 cx.stop_propagation();
52 stop_app.update(cx, |state, cx| state.stop_call_share(cx));
53 }),
54 )
55}
56
57pub fn render_call_mini(app: &Entity<AppState>, state: &AppState) -> Option<AnyElement> {
58 let call = state.call.as_ref().filter(|call| !call.viewing)?;
59 let model = &call.model;
60 let (status, status_color) = status_line(model, Instant::now());
61 let open_app = app.clone();
62 let speaking = model.remote_speaking;
63 Some(
64 v_flex()
65 .id("call-mini")
66 .occlude()
67 .absolute()
68 .right(px(MINI_RIGHT))
69 .bottom(px(MINI_BOTTOM))
70 .w(px(MINI_WIDTH))
71 .p(px(10.))
72 .gap(px(8.))
73 .rounded(px(10.))
74 .bg(theme::surface_raised())
75 .border_1()
76 .border_color(if speaking {
77 theme::green()
78 } else {
79 theme::border_strong()
80 })
81 .shadow_lg()
82 .cursor_pointer()
83 .on_click(move |_, _, cx| {
84 open_app.update(cx, |state, cx| state.show_call(true, cx));
85 })
86 .child(
87 h_flex()
88 .gap(px(8.))
89 .items_center()
90 .child(icon(IconName::Phone, 14., theme::accent_text()))
91 .child(
92 div()
93 .flex_1()
94 .min_w_0()
95 .truncate()
96 .text_size(px(13.))
97 .font_weight(FontWeight::SEMIBOLD)
98 .child(model.title.clone()),
99 )
100 .child(
101 div()
102 .text_size(px(12.))
103 .text_color(status_color)
104 .child(status),
105 ),
106 )
107 .when(model.local_share.is_some(), |mini| {
108 mini.child(sharing_badge(app))
109 })
110 .child(
111 h_flex()
112 .gap(px(8.))
113 .items_center()
114 .justify_between()
115 .child(mute_button(app, model, "call-mini-mute", MUTE_SIZE))
116 .child(leave_button(app, model, "call-mini-leave", true)),
117 )
118 .into_any_element(),
119 )
120}