BlueGit

ict rusty-teams

Files

rusty-teams / crates / app / src / views / conversation / absence.rs

absence.rs

chore: cargo fmt the workspace
metis Daniel Däschle · pushed by metis · 2 weeks ago
a6592765 History
absence.rs 2.4 KiB Download Raw
1use gpui_kit::assets::IconName;
2use gpui_kit::component::h_flex;
3use gpui_kit::*;
4
5use super::ConversationView;
6use crate::theme;
7use crate::views::widgets::icon;
8
9pub const ABSENCE_NOTICE_TAG: &str = "conversation/absence-notice";
10const NOTICE_MARGIN_X: f32 = 20.;
11const NOTICE_MARGIN_BOTTOM: f32 = 8.;
12const NOTICE_PADDING: f32 = 12.;
13const NOTICE_HEIGHT: f32 = 36.;
14const NOTICE_RADIUS: f32 = 10.;
15const CLOSE_SIZE: f32 = 24.;
16const NOTICE_TINT: f32 = 0.18;
17
18impl ConversationView {
19 pub(super) fn render_absence_notice(&self, cx: &App) -> Option<AnyElement> {
20 if self.draft_active {
21 return None;
22 }
23 let conversation_id = self.conversation_id()?;
24 let notice = self.app.read(cx).absence_notice(&conversation_id)?;
25 let app = self.app.clone();
26 Some(
27 h_flex()
28 .flex_none()
29 .mx(px(NOTICE_MARGIN_X))
30 .mb(px(NOTICE_MARGIN_BOTTOM))
31 .pl(px(NOTICE_PADDING))
32 .pr(px(NOTICE_PADDING - (CLOSE_SIZE - 14.) / 2.))
33 .h(px(NOTICE_HEIGHT))
34 .gap(px(8.))
35 .items_center()
36 .rounded(px(NOTICE_RADIUS))
37 .bg(theme::accent().opacity(NOTICE_TINT))
38 .debug_selector(|| ABSENCE_NOTICE_TAG.into())
39 .child(
40 div()
41 .flex_1()
42 .min_w_0()
43 .truncate()
44 .text_size(px(13.))
45 .text_color(theme::text())
46 .child(notice.text()),
47 )
48 .child(
49 div()
50 .id("absence-notice-close")
51 .size(px(CLOSE_SIZE))
52 .flex_none()
53 .flex()
54 .items_center()
55 .justify_center()
56 .rounded(px(6.))
57 .cursor_pointer()
58 .hover(|button| button.bg(theme::row_hover()))
59 .child(icon(IconName::Close, 14., theme::text_muted()))
60 .on_click(move |_, _, cx| {
61 app.update(cx, |state, cx| {
62 state.dismiss_absence_notice(&conversation_id, cx)
63 });
64 }),
65 )
66 .into_any_element(),
67 )
68 }
69}