| 1 | use gpui_kit::assets::IconName; |
| 2 | use gpui_kit::component::button::{Button, ButtonVariants as _}; |
| 3 | use gpui_kit::component::{h_flex, v_flex}; |
| 4 | use gpui_kit::prelude::FluentBuilder as _; |
| 5 | use gpui_kit::*; |
| 6 | |
| 7 | use super::avatar::person_avatar; |
| 8 | use super::widgets::icon; |
| 9 | use crate::app_state::AppState; |
| 10 | use crate::call::end_screen::{CallEndScreen, DISMISS_LABEL}; |
| 11 | use crate::theme; |
| 12 | |
| 13 | const CONTENT_WIDTH: f32 = 400.; |
| 14 | const AVATAR_SIZE: f32 = 96.; |
| 15 | const ICON_SIZE: f32 = 40.; |
| 16 | const PANE_PADDING: f32 = 12.; |
| 17 | const SECTION_GAP: f32 = 16.; |
| 18 | const TEXT_GAP: f32 = 8.; |
| 19 | const BUTTON_GAP: f32 = 8.; |
| 20 | |
| 21 | pub fn render_call_end(app: &Entity<AppState>, state: &AppState) -> Option<AnyElement> { |
| 22 | let screen = state.call_end.as_ref()?; |
| 23 | let dismiss_app = app.clone(); |
| 24 | let retry_app = app.clone(); |
| 25 | let actions = h_flex() |
| 26 | .debug_selector(|| "shell/islands/main/call-end/actions".into()) |
| 27 | .flex_none() |
| 28 | .gap(px(BUTTON_GAP)) |
| 29 | .justify_center() |
| 30 | .child( |
| 31 | Button::new("call-end-dismiss") |
| 32 | .outline() |
| 33 | .label(DISMISS_LABEL) |
| 34 | .on_click(move |_, _, cx| { |
| 35 | dismiss_app.update(cx, |state, cx| state.dismiss_call_end(cx)) |
| 36 | }), |
| 37 | ) |
| 38 | .when(screen.can_retry(), |row| { |
| 39 | row.child( |
| 40 | Button::new("call-end-retry") |
| 41 | .primary() |
| 42 | .label(screen.retry_label()) |
| 43 | .on_click(move |_, _, cx| { |
| 44 | retry_app.update(cx, |state, cx| state.retry_call_end(cx)) |
| 45 | }), |
| 46 | ) |
| 47 | }); |
| 48 | Some( |
| 49 | v_flex() |
| 50 | .debug_selector(|| "shell/islands/main".into()) |
| 51 | .flex_1() |
| 52 | .min_w_0() |
| 53 | .h_full() |
| 54 | .p(px(PANE_PADDING)) |
| 55 | .items_center() |
| 56 | .justify_center() |
| 57 | .rounded(px(10.)) |
| 58 | .bg(theme::surface()) |
| 59 | .overflow_hidden() |
| 60 | .child( |
| 61 | v_flex() |
| 62 | .debug_selector(|| "shell/islands/main/call-end".into()) |
| 63 | .w(px(CONTENT_WIDTH)) |
| 64 | .max_w_full() |
| 65 | .items_center() |
| 66 | .gap(px(SECTION_GAP)) |
| 67 | .child(badge(state, screen)) |
| 68 | .child( |
| 69 | v_flex() |
| 70 | .w_full() |
| 71 | .items_center() |
| 72 | .gap(px(TEXT_GAP)) |
| 73 | .child( |
| 74 | div() |
| 75 | .text_size(px(20.)) |
| 76 | .font_weight(FontWeight::SEMIBOLD) |
| 77 | .text_color(theme::text_strong()) |
| 78 | .text_center() |
| 79 | .child(screen.heading()), |
| 80 | ) |
| 81 | .child( |
| 82 | div() |
| 83 | .w_full() |
| 84 | .text_size(px(14.)) |
| 85 | .text_color(theme::text_muted()) |
| 86 | .text_center() |
| 87 | .child(screen.description()), |
| 88 | ), |
| 89 | ) |
| 90 | .child(actions), |
| 91 | ) |
| 92 | .into_any_element(), |
| 93 | ) |
| 94 | } |
| 95 | |
| 96 | fn badge(state: &AppState, screen: &CallEndScreen) -> AnyElement { |
| 97 | match &screen.peer { |
| 98 | Some(peer) => person_avatar( |
| 99 | &state.directory, |
| 100 | peer.user_id.as_deref(), |
| 101 | &peer.name, |
| 102 | AVATAR_SIZE, |
| 103 | ), |
| 104 | None => div() |
| 105 | .size(px(AVATAR_SIZE)) |
| 106 | .flex_none() |
| 107 | .rounded_full() |
| 108 | .bg(theme::surface_raised()) |
| 109 | .flex() |
| 110 | .items_center() |
| 111 | .justify_center() |
| 112 | .child(icon(IconName::PhoneOff, ICON_SIZE, theme::text_muted())) |
| 113 | .into_any_element(), |
| 114 | } |
| 115 | } |