BlueGit

ict rusty-teams

Files

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

call_mini.rs

call_mini.rs 2.4 KiB Download Raw
1use std::time::Instant;
2
3use gpui_kit::assets::IconName;
4use gpui_kit::component::{h_flex, v_flex};
5use gpui_kit::*;
6
7use super::call_view::{leave_button, mute_button, status_line};
8use super::widgets::icon;
9use crate::app_state::AppState;
10use crate::theme;
11
12pub const MINI_WIDTH: f32 = 220.;
13const MINI_RIGHT: f32 = 16.;
14const MINI_BOTTOM: f32 = 40.;
15const MUTE_SIZE: f32 = 28.;
16
17pub fn render_call_mini(app: &Entity<AppState>, state: &AppState) -> Option<AnyElement> {
18 let call = state.call.as_ref().filter(|call| !call.viewing)?;
19 let model = &call.model;
20 let (status, status_color) = status_line(model, Instant::now());
21 let open_app = app.clone();
22 let speaking = model.remote_speaking;
23 Some(
24 v_flex()
25 .id("call-mini")
26 .occlude()
27 .absolute()
28 .right(px(MINI_RIGHT))
29 .bottom(px(MINI_BOTTOM))
30 .w(px(MINI_WIDTH))
31 .p(px(10.))
32 .gap(px(8.))
33 .rounded(px(10.))
34 .bg(theme::surface_raised())
35 .border_1()
36 .border_color(if speaking {
37 theme::green()
38 } else {
39 theme::border_strong()
40 })
41 .shadow_lg()
42 .cursor_pointer()
43 .on_click(move |_, _, cx| {
44 open_app.update(cx, |state, cx| state.show_call(true, cx));
45 })
46 .child(
47 h_flex()
48 .gap(px(8.))
49 .items_center()
50 .child(icon(IconName::Phone, 14., theme::accent_text()))
51 .child(
52 div()
53 .flex_1()
54 .min_w_0()
55 .truncate()
56 .text_size(px(13.))
57 .font_weight(FontWeight::SEMIBOLD)
58 .child(model.title.clone()),
59 )
60 .child(div().text_size(px(12.)).text_color(status_color).child(status)),
61 )
62 .child(
63 h_flex()
64 .gap(px(8.))
65 .items_center()
66 .justify_between()
67 .child(mute_button(app, model, "call-mini-mute", MUTE_SIZE))
68 .child(leave_button(app, model, "call-mini-leave", true)),
69 )
70 .into_any_element(),
71 )
72}