| 1 | use std::sync::Arc; |
| 2 | use std::time::{Duration, Instant, SystemTime, UNIX_EPOCH}; |
| 3 | |
| 4 | use calling::{DeviceEntry, Reaction, VideoKey}; |
| 5 | use gpui_kit::assets::IconName; |
| 6 | use gpui_kit::component::{ |
| 7 | button::{Button, ButtonVariants as _}, |
| 8 | h_flex, |
| 9 | menu::{DropdownMenu as _, PopupMenu, PopupMenuItem}, |
| 10 | popover::Popover, |
| 11 | switch::Switch, |
| 12 | tooltip::Tooltip, |
| 13 | v_flex, |
| 14 | }; |
| 15 | use gpui_kit::prelude::FluentBuilder as _; |
| 16 | use gpui_kit::*; |
| 17 | |
| 18 | use super::avatar::person_avatar; |
| 19 | use super::call_extras::{ |
| 20 | BackgroundMenu, consent_overlay, consult_banner, hold_panel, recording_chip, return_button, |
| 21 | room_chip, whiteboard_stage, |
| 22 | }; |
| 23 | use super::call_health::{health_banner, health_indicator}; |
| 24 | use super::call_organizer::{ |
| 25 | camera_menu_button, captions_hint_chip, captions_overlay, chevron_button, lobby_banner, |
| 26 | more_button, pin_chip, render_focus_stage, spotlight_chip, with_tile_menu, |
| 27 | }; |
| 28 | use super::call_stage::render_stage; |
| 29 | use super::conversation::ConversationView; |
| 30 | use super::shell::ISLAND_GAP; |
| 31 | use super::widgets::{Corner, corner_badge, count_badge, icon}; |
| 32 | use crate::app_state::AppState; |
| 33 | use crate::call::REACTION_SHOWN; |
| 34 | use crate::call::TileSize; |
| 35 | use crate::call::{ |
| 36 | CHAT_OPEN_TILES, CallKind, CallModel, GridLayout, MAX_TILES, Tile, TileState, grid_layout, |
| 37 | tile_size, |
| 38 | }; |
| 39 | use crate::rows::reaction_glyph as chat_reaction_glyph; |
| 40 | use crate::theme; |
| 41 | |
| 42 | const HEADER_HEIGHT: f32 = 60.; |
| 43 | const RING_WIDTH: f32 = 3.; |
| 44 | const RING_GAP: f32 = 4.; |
| 45 | pub(super) const CONTROL_SIZE: f32 = 44.; |
| 46 | const CONTROL_ICON: f32 = 20.; |
| 47 | pub(super) const MENU_WIDTH: f32 = 280.; |
| 48 | const PULSE_PERIOD: Duration = Duration::from_millis(1400); |
| 49 | const BLINK_HALF_PERIOD: Duration = Duration::from_millis(500); |
| 50 | const BLINK_DIMMED_OPACITY: f32 = 0.45; |
| 51 | const DISABLED_OPACITY: f32 = 0.4; |
| 52 | const TILE_GAP: f32 = 20.; |
| 53 | const GRID_PADDING: f32 = 24.; |
| 54 | const STRIP_TILE: TileSize = TileSize { |
| 55 | width: 232., |
| 56 | height: 131., |
| 57 | avatar: 56., |
| 58 | }; |
| 59 | const STRIP_GAP: f32 = 12.; |
| 60 | const STRIP_VISIBLE: f32 = 4.; |
| 61 | const TILE_RADIUS: f32 = 12.; |
| 62 | const NAME_PLATE_BACKGROUND: f32 = 0.6; |
| 63 | pub const NO_MICROPHONE_HINT: &str = "No microphone found"; |
| 64 | pub const NO_CAMERA_HINT: &str = "No camera found"; |
| 65 | pub const NO_SHARE_HINT: &str = "Sharing starts once the call is connected"; |
| 66 | pub const NO_WINDOWS_HINT: &str = "No windows found"; |
| 67 | pub(super) const BANNER_HEIGHT: f32 = 40.; |
| 68 | const MAX_WINDOW_ITEMS: usize = 12; |
| 69 | pub const LOBBY_TEXT: &str = "Waiting in the lobby..."; |
| 70 | pub const CHAT_PANEL_WIDTH: f32 = 320.; |
| 71 | const CHAT_HEADER_HEIGHT: f32 = 48.; |
| 72 | const REACTION_RISE: f32 = 24.; |
| 73 | const REACTION_FADE_FROM: f32 = 0.75; |
| 74 | const REACTION_CELL: f32 = 40.; |
| 75 | const SHARE_SOUND_LABEL: &str = "Include computer sound"; |
| 76 | |
| 77 | pub fn reaction_glyph(reaction: Reaction) -> String { |
| 78 | match reaction { |
| 79 | Reaction::Applause => "\u{1F44F}".to_owned(), |
| 80 | other => chat_reaction_glyph(other.name()), |
| 81 | } |
| 82 | } |
| 83 | |
| 84 | #[derive(Default)] |
| 85 | struct TileExtras { |
| 86 | hand: Option<usize>, |
| 87 | own: bool, |
| 88 | reaction: Option<(Reaction, u64)>, |
| 89 | spotlight: bool, |
| 90 | pinned: bool, |
| 91 | } |
| 92 | |
| 93 | fn hand_badge(position: usize, own: bool) -> Div { |
| 94 | h_flex() |
| 95 | .h(px(24.)) |
| 96 | .px(px(8.)) |
| 97 | .gap(px(4.)) |
| 98 | .items_center() |
| 99 | .rounded_full() |
| 100 | .bg(theme::amber()) |
| 101 | .text_color(hsla(0., 0., 0.08, 1.)) |
| 102 | .text_size(px(12.)) |
| 103 | .font_weight(FontWeight::SEMIBOLD) |
| 104 | .child(if own { |
| 105 | "Hand raised".to_owned() |
| 106 | } else { |
| 107 | format!("Hand {position}") |
| 108 | }) |
| 109 | } |
| 110 | |
| 111 | fn reaction_chip(reaction: Reaction, serial: u64) -> AnyElement { |
| 112 | div() |
| 113 | .absolute() |
| 114 | .right(px(12.)) |
| 115 | .bottom(px(32.)) |
| 116 | .size(px(36.)) |
| 117 | .flex() |
| 118 | .items_center() |
| 119 | .justify_center() |
| 120 | .rounded_full() |
| 121 | .bg(theme::popup()) |
| 122 | .text_size(px(20.)) |
| 123 | .child(reaction_glyph(reaction)) |
| 124 | .with_animation( |
| 125 | ("call-reaction", serial as usize), |
| 126 | Animation::new(REACTION_SHOWN), |
| 127 | |chip, delta| { |
| 128 | let fade = ((delta - REACTION_FADE_FROM) / (1. - REACTION_FADE_FROM)).clamp(0., 1.); |
| 129 | chip.bottom(px(32. + REACTION_RISE * delta)) |
| 130 | .opacity(1. - fade) |
| 131 | }, |
| 132 | ) |
| 133 | .into_any_element() |
| 134 | } |
| 135 | |
| 136 | fn tile_overlays(extras: &TileExtras) -> Vec<AnyElement> { |
| 137 | let badges = (extras.hand.is_some() || extras.spotlight || extras.pinned).then(|| { |
| 138 | h_flex() |
| 139 | .absolute() |
| 140 | .top(px(8.)) |
| 141 | .left(px(8.)) |
| 142 | .gap(px(6.)) |
| 143 | .children(extras.hand.map(|position| hand_badge(position, extras.own))) |
| 144 | .when(extras.spotlight, |row| row.child(spotlight_chip())) |
| 145 | .when(extras.pinned, |row| row.child(pin_chip())) |
| 146 | .into_any_element() |
| 147 | }); |
| 148 | let reaction = extras |
| 149 | .reaction |
| 150 | .map(|(reaction, serial)| reaction_chip(reaction, serial)); |
| 151 | badges.into_iter().chain(reaction).collect() |
| 152 | } |
| 153 | |
| 154 | pub fn status_line(model: &CallModel, now: Instant) -> (String, Hsla) { |
| 155 | if model.lobby { |
| 156 | (LOBBY_TEXT.to_owned(), theme::amber()) |
| 157 | } else if model.is_connecting() { |
| 158 | (model.connecting_text().to_owned(), theme::text_muted()) |
| 159 | } else if model.is_reconnecting() { |
| 160 | ("Reconnecting...".to_owned(), theme::amber()) |
| 161 | } else { |
| 162 | (model.timer_text(now), theme::text_muted()) |
| 163 | } |
| 164 | } |
| 165 | |
| 166 | pub fn pulsing(element: impl IntoElement + 'static, id: &'static str) -> AnyElement { |
| 167 | div() |
| 168 | .child(element) |
| 169 | .with_animation( |
| 170 | id, |
| 171 | Animation::new(PULSE_PERIOD).repeat(), |
| 172 | |element, delta| { |
| 173 | let wave = 1. - (delta * 2. - 1.).abs(); |
| 174 | element.opacity(0.45 + 0.55 * wave) |
| 175 | }, |
| 176 | ) |
| 177 | .into_any_element() |
| 178 | } |
| 179 | |
| 180 | fn blinking(element: impl IntoElement + 'static) -> AnyElement { |
| 181 | let dimmed = SystemTime::now() |
| 182 | .duration_since(UNIX_EPOCH) |
| 183 | .is_ok_and(|elapsed| (elapsed.as_millis() / BLINK_HALF_PERIOD.as_millis()) % 2 == 1); |
| 184 | div() |
| 185 | .child(element) |
| 186 | .opacity(if dimmed { BLINK_DIMMED_OPACITY } else { 1. }) |
| 187 | .into_any_element() |
| 188 | } |
| 189 | |
| 190 | fn speaking_ring(avatar: AnyElement, speaking: bool) -> Div { |
| 191 | div() |
| 192 | .p(px(RING_GAP)) |
| 193 | .rounded_full() |
| 194 | .border(px(RING_WIDTH)) |
| 195 | .border_color(if speaking { |
| 196 | theme::green() |
| 197 | } else { |
| 198 | transparent_black() |
| 199 | }) |
| 200 | .child(avatar) |
| 201 | } |
| 202 | |
| 203 | fn mute_badge() -> Div { |
| 204 | div() |
| 205 | .absolute() |
| 206 | .top(px(8.)) |
| 207 | .right(px(8.)) |
| 208 | .size(px(24.)) |
| 209 | .flex() |
| 210 | .items_center() |
| 211 | .justify_center() |
| 212 | .rounded_full() |
| 213 | .bg(theme::red()) |
| 214 | .child(icon(IconName::MicOff, 13., theme::white())) |
| 215 | } |
| 216 | |
| 217 | fn video_tile( |
| 218 | size: TileSize, |
| 219 | image: Arc<RenderImage>, |
| 220 | name: &str, |
| 221 | speaking: bool, |
| 222 | muted: bool, |
| 223 | extras: &TileExtras, |
| 224 | ) -> Div { |
| 225 | div() |
| 226 | .relative() |
| 227 | .w(px(size.width)) |
| 228 | .h(px(size.height)) |
| 229 | .flex_none() |
| 230 | .overflow_hidden() |
| 231 | .rounded(px(TILE_RADIUS)) |
| 232 | .bg(theme::row_hover()) |
| 233 | .border_2() |
| 234 | .border_color(if speaking { |
| 235 | theme::green() |
| 236 | } else { |
| 237 | transparent_black() |
| 238 | }) |
| 239 | .child( |
| 240 | img(ImageSource::Render(image)) |
| 241 | .size_full() |
| 242 | .object_fit(ObjectFit::Cover) |
| 243 | .rounded(px(TILE_RADIUS)), |
| 244 | ) |
| 245 | .child( |
| 246 | div() |
| 247 | .absolute() |
| 248 | .left(px(8.)) |
| 249 | .bottom(px(8.)) |
| 250 | .max_w(px(size.width - 24.)) |
| 251 | .truncate() |
| 252 | .px(px(8.)) |
| 253 | .py(px(4.)) |
| 254 | .rounded(px(6.)) |
| 255 | .bg(hsla(0., 0., 0., NAME_PLATE_BACKGROUND)) |
| 256 | .text_size(px(12.)) |
| 257 | .font_weight(FontWeight::SEMIBOLD) |
| 258 | .text_color(theme::white()) |
| 259 | .child(name.to_owned()), |
| 260 | ) |
| 261 | .when(muted, |tile| tile.child(mute_badge())) |
| 262 | .children(tile_overlays(extras)) |
| 263 | } |
| 264 | |
| 265 | fn tile( |
| 266 | size: TileSize, |
| 267 | avatar: AnyElement, |
| 268 | name: &str, |
| 269 | speaking: bool, |
| 270 | muted: bool, |
| 271 | caption: Option<AnyElement>, |
| 272 | extras: &TileExtras, |
| 273 | ) -> Div { |
| 274 | let badge = div() |
| 275 | .absolute() |
| 276 | .top(px(8.)) |
| 277 | .right(px(8.)) |
| 278 | .size(px(24.)) |
| 279 | .flex() |
| 280 | .items_center() |
| 281 | .justify_center() |
| 282 | .rounded_full() |
| 283 | .bg(theme::red()) |
| 284 | .child(icon(IconName::MicOff, 13., theme::white())); |
| 285 | v_flex() |
| 286 | .relative() |
| 287 | .w(px(size.width)) |
| 288 | .h(px(size.height)) |
| 289 | .items_center() |
| 290 | .justify_center() |
| 291 | .gap(px(12.)) |
| 292 | .rounded(px(12.)) |
| 293 | .bg(theme::row_hover()) |
| 294 | .child(speaking_ring(avatar, speaking)) |
| 295 | .child( |
| 296 | v_flex() |
| 297 | .items_center() |
| 298 | .gap(px(2.)) |
| 299 | .max_w(px(size.width - 16.)) |
| 300 | .child( |
| 301 | div() |
| 302 | .max_w_full() |
| 303 | .truncate() |
| 304 | .text_size(px(14.)) |
| 305 | .font_weight(FontWeight::SEMIBOLD) |
| 306 | .child(name.to_owned()), |
| 307 | ) |
| 308 | .children(caption), |
| 309 | ) |
| 310 | .when(muted, |tile| tile.child(badge)) |
| 311 | .children(tile_overlays(extras)) |
| 312 | } |
| 313 | |
| 314 | fn overflow_tile(size: TileSize, hidden: usize) -> Div { |
| 315 | v_flex() |
| 316 | .w(px(size.width)) |
| 317 | .h(px(size.height)) |
| 318 | .items_center() |
| 319 | .justify_center() |
| 320 | .rounded(px(12.)) |
| 321 | .bg(theme::row_hover()) |
| 322 | .child( |
| 323 | div() |
| 324 | .text_size(px(size.avatar * 0.5)) |
| 325 | .font_weight(FontWeight::SEMIBOLD) |
| 326 | .text_color(theme::text_muted()) |
| 327 | .child(format!("+{hidden}")), |
| 328 | ) |
| 329 | } |
| 330 | |
| 331 | fn control_shell(id: &'static str, background: Hsla) -> Stateful<Div> { |
| 332 | div() |
| 333 | .id(id) |
| 334 | .size(px(CONTROL_SIZE)) |
| 335 | .flex() |
| 336 | .flex_none() |
| 337 | .items_center() |
| 338 | .justify_center() |
| 339 | .rounded_full() |
| 340 | .bg(background) |
| 341 | .cursor_pointer() |
| 342 | .hover(|button| button.opacity(0.85)) |
| 343 | } |
| 344 | |
| 345 | pub(super) fn round_control( |
| 346 | id: &'static str, |
| 347 | glyph: IconName, |
| 348 | background: Hsla, |
| 349 | foreground: Hsla, |
| 350 | ) -> Stateful<Div> { |
| 351 | control_shell(id, background).child(icon(glyph, CONTROL_ICON, foreground)) |
| 352 | } |
| 353 | |
| 354 | pub fn mute_button( |
| 355 | app: &Entity<AppState>, |
| 356 | model: &CallModel, |
| 357 | id: &'static str, |
| 358 | size: f32, |
| 359 | ) -> Stateful<Div> { |
| 360 | let (glyph, background, foreground) = if model.muted { |
| 361 | (IconName::MicOff, theme::red(), theme::white()) |
| 362 | } else { |
| 363 | (IconName::Mic, theme::surface_raised(), theme::text()) |
| 364 | }; |
| 365 | let button = round_control(id, glyph, background, foreground).size(px(size)); |
| 366 | if !model.can_unmute() { |
| 367 | return button |
| 368 | .opacity(DISABLED_OPACITY) |
| 369 | .cursor_default() |
| 370 | .tooltip(|window, cx| Tooltip::new(NO_MICROPHONE_HINT).build(window, cx)); |
| 371 | } |
| 372 | let app = app.clone(); |
| 373 | button.on_click(move |_, _, cx| { |
| 374 | cx.stop_propagation(); |
| 375 | app.update(cx, |state, cx| state.toggle_call_mute(cx)); |
| 376 | }) |
| 377 | } |
| 378 | |
| 379 | pub fn leave_button( |
| 380 | app: &Entity<AppState>, |
| 381 | model: &CallModel, |
| 382 | id: &'static str, |
| 383 | compact: bool, |
| 384 | ) -> Stateful<Div> { |
| 385 | let label = if model.is_connecting() { |
| 386 | "Cancel" |
| 387 | } else { |
| 388 | "Leave" |
| 389 | }; |
| 390 | let app = app.clone(); |
| 391 | h_flex() |
| 392 | .id(id) |
| 393 | .h(px(if compact { 28. } else { CONTROL_SIZE })) |
| 394 | .px(px(if compact { 10. } else { 20. })) |
| 395 | .gap(px(8.)) |
| 396 | .flex_none() |
| 397 | .items_center() |
| 398 | .justify_center() |
| 399 | .rounded_full() |
| 400 | .bg(theme::red()) |
| 401 | .text_color(theme::white()) |
| 402 | .text_size(px(if compact { 12. } else { 14. })) |
| 403 | .font_weight(FontWeight::SEMIBOLD) |
| 404 | .cursor_pointer() |
| 405 | .hover(|button| button.opacity(0.85)) |
| 406 | .child(icon( |
| 407 | IconName::PhoneOff, |
| 408 | if compact { 14. } else { 18. }, |
| 409 | theme::white(), |
| 410 | )) |
| 411 | .child(label) |
| 412 | .on_click(move |_, _, cx| { |
| 413 | cx.stop_propagation(); |
| 414 | app.update(cx, |state, cx| state.leave_call(cx)); |
| 415 | }) |
| 416 | } |
| 417 | |
| 418 | pub(super) fn camera_button(app: &Entity<AppState>, model: &CallModel) -> Stateful<Div> { |
| 419 | let (glyph, background, foreground) = if model.camera_on { |
| 420 | (IconName::Video, theme::accent(), theme::on_accent()) |
| 421 | } else { |
| 422 | (IconName::VideoOff, theme::surface_raised(), theme::text()) |
| 423 | }; |
| 424 | let button = round_control("call-camera", glyph, background, foreground); |
| 425 | if !model.can_use_camera() { |
| 426 | return button |
| 427 | .opacity(DISABLED_OPACITY) |
| 428 | .cursor_default() |
| 429 | .tooltip(|window, cx| Tooltip::new(NO_CAMERA_HINT).build(window, cx)); |
| 430 | } |
| 431 | let app = app.clone(); |
| 432 | button.on_click(move |_, _, cx| { |
| 433 | cx.stop_propagation(); |
| 434 | app.update(cx, |state, cx| state.toggle_call_camera(cx)); |
| 435 | }) |
| 436 | } |
| 437 | |
| 438 | fn sound_switch_item(app: &Entity<AppState>, sound: bool) -> PopupMenuItem { |
| 439 | let app = app.clone(); |
| 440 | PopupMenuItem::element(move |_, _| { |
| 441 | h_flex() |
| 442 | .id("call-share-sound-row") |
| 443 | .w_full() |
| 444 | .gap(px(16.)) |
| 445 | .items_center() |
| 446 | .justify_between() |
| 447 | .child(SHARE_SOUND_LABEL) |
| 448 | .child(Switch::new("call-share-sound").checked(sound)) |
| 449 | }) |
| 450 | .on_click(move |_, _, cx| app.update(cx, |state, cx| state.set_call_share_sound(!sound, cx))) |
| 451 | } |
| 452 | |
| 453 | fn share_items( |
| 454 | popup: PopupMenu, |
| 455 | app: &Entity<AppState>, |
| 456 | model: &CallModel, |
| 457 | sound: bool, |
| 458 | ) -> PopupMenu { |
| 459 | let screens = model.screens(); |
| 460 | let single_screen = screens.len() == 1; |
| 461 | let mut popup = popup |
| 462 | .min_w(px(MENU_WIDTH)) |
| 463 | .item(sound_switch_item(app, sound)) |
| 464 | .separator(); |
| 465 | for (index, source) in screens.into_iter().enumerate() { |
| 466 | let label = if single_screen { |
| 467 | "Share entire screen".to_owned() |
| 468 | } else { |
| 469 | format!("Share screen {}", index + 1) |
| 470 | }; |
| 471 | let source = source.clone(); |
| 472 | let app = app.clone(); |
| 473 | popup = popup.item(PopupMenuItem::new(label).icon(IconName::Monitor).on_click( |
| 474 | move |_, _, cx| app.update(cx, |state, cx| state.start_call_share(source.clone(), cx)), |
| 475 | )); |
| 476 | } |
| 477 | popup = popup |
| 478 | .separator() |
| 479 | .item(PopupMenuItem::label("Share a window...")); |
| 480 | let windows = model.windows(); |
| 481 | if windows.is_empty() { |
| 482 | return popup.item(PopupMenuItem::new(NO_WINDOWS_HINT).disabled(true)); |
| 483 | } |
| 484 | for source in windows.into_iter().take(MAX_WINDOW_ITEMS) { |
| 485 | let label = source.label(); |
| 486 | let source = source.clone(); |
| 487 | let app = app.clone(); |
| 488 | popup = popup.item( |
| 489 | PopupMenuItem::new(label) |
| 490 | .icon(IconName::AppWindow) |
| 491 | .on_click(move |_, _, cx| { |
| 492 | app.update(cx, |state, cx| state.start_call_share(source.clone(), cx)) |
| 493 | }), |
| 494 | ); |
| 495 | } |
| 496 | popup |
| 497 | } |
| 498 | |
| 499 | fn share_button(app: &Entity<AppState>, model: &CallModel, sound: bool) -> AnyElement { |
| 500 | if model.local_share.is_some() { |
| 501 | let app = app.clone(); |
| 502 | return round_control( |
| 503 | "call-share-stop", |
| 504 | IconName::ScreenShareOff, |
| 505 | theme::accent(), |
| 506 | theme::on_accent(), |
| 507 | ) |
| 508 | .tooltip(|window, cx| Tooltip::new("Stop sharing").build(window, cx)) |
| 509 | .on_click(move |_, _, cx| { |
| 510 | cx.stop_propagation(); |
| 511 | app.update(cx, |state, cx| state.stop_call_share(cx)); |
| 512 | }) |
| 513 | .into_any_element(); |
| 514 | } |
| 515 | let face = round_control( |
| 516 | "call-share-face", |
| 517 | IconName::ScreenShare, |
| 518 | theme::surface_raised(), |
| 519 | theme::text(), |
| 520 | ); |
| 521 | if !model.can_share() { |
| 522 | return face |
| 523 | .opacity(DISABLED_OPACITY) |
| 524 | .cursor_default() |
| 525 | .tooltip(|window, cx| Tooltip::new(NO_SHARE_HINT).build(window, cx)) |
| 526 | .into_any_element(); |
| 527 | } |
| 528 | let app = app.clone(); |
| 529 | let model = model.clone(); |
| 530 | Button::new("call-share") |
| 531 | .ghost() |
| 532 | .p_0() |
| 533 | .size(px(CONTROL_SIZE)) |
| 534 | .rounded_full() |
| 535 | .child(face) |
| 536 | .dropdown_menu_with_anchor(Anchor::BottomLeft, move |popup, _, _| { |
| 537 | share_items(popup, &app, &model, sound) |
| 538 | }) |
| 539 | .into_any_element() |
| 540 | } |
| 541 | |
| 542 | fn sharing_banner(app: &Entity<AppState>, model: &CallModel, sound: bool) -> Option<AnyElement> { |
| 543 | let label = model.local_share.as_ref()?; |
| 544 | let sound_app = app.clone(); |
| 545 | let app = app.clone(); |
| 546 | Some( |
| 547 | h_flex() |
| 548 | .id("call-sharing-banner") |
| 549 | .w_full() |
| 550 | .h(px(BANNER_HEIGHT)) |
| 551 | .flex_none() |
| 552 | .px(px(20.)) |
| 553 | .gap(px(12.)) |
| 554 | .items_center() |
| 555 | .justify_center() |
| 556 | .bg(theme::accent()) |
| 557 | .text_color(theme::on_accent()) |
| 558 | .text_size(px(13.)) |
| 559 | .font_weight(FontWeight::SEMIBOLD) |
| 560 | .child(icon(IconName::ScreenShare, 16., theme::on_accent())) |
| 561 | .child(format!("You are sharing: {label}")) |
| 562 | .child( |
| 563 | div() |
| 564 | .id("call-sharing-sound") |
| 565 | .h(px(26.)) |
| 566 | .px(px(12.)) |
| 567 | .flex() |
| 568 | .items_center() |
| 569 | .rounded_full() |
| 570 | .bg(theme::on_accent().opacity(0.2)) |
| 571 | .cursor_pointer() |
| 572 | .hover(|button| button.opacity(0.9)) |
| 573 | .child(if sound { |
| 574 | "Computer sound on" |
| 575 | } else { |
| 576 | "Computer sound off" |
| 577 | }) |
| 578 | .on_click(move |_, _, cx| { |
| 579 | sound_app.update(cx, |state, cx| state.set_call_share_sound(!sound, cx)) |
| 580 | }), |
| 581 | ) |
| 582 | .child( |
| 583 | div() |
| 584 | .id("call-sharing-stop") |
| 585 | .h(px(26.)) |
| 586 | .px(px(12.)) |
| 587 | .flex() |
| 588 | .items_center() |
| 589 | .rounded_full() |
| 590 | .bg(theme::on_accent()) |
| 591 | .text_color(theme::accent()) |
| 592 | .cursor_pointer() |
| 593 | .hover(|button| button.opacity(0.9)) |
| 594 | .child("Stop sharing") |
| 595 | .on_click(move |_, _, cx| { |
| 596 | app.update(cx, |state, cx| state.stop_call_share(cx)) |
| 597 | }), |
| 598 | ) |
| 599 | .into_any_element(), |
| 600 | ) |
| 601 | } |
| 602 | |
| 603 | fn chat_button(app: &Entity<AppState>, open: bool, unread: u32) -> Stateful<Div> { |
| 604 | let app = app.clone(); |
| 605 | let (background, foreground) = if open { |
| 606 | (theme::accent(), theme::on_accent()) |
| 607 | } else { |
| 608 | (theme::surface_raised(), theme::text()) |
| 609 | }; |
| 610 | round_control("call-chat", IconName::MessageCircle, background, foreground) |
| 611 | .relative() |
| 612 | .tooltip(move |window, cx| { |
| 613 | Tooltip::new(if open { |
| 614 | "Close the chat" |
| 615 | } else { |
| 616 | "Open the chat" |
| 617 | }) |
| 618 | .build(window, cx) |
| 619 | }) |
| 620 | .when(unread > 0, |button| { |
| 621 | button.child(corner_badge(Corner::TopRight, 4.).child(count_badge(unread, false))) |
| 622 | }) |
| 623 | .on_click(move |_, _, cx| app.update(cx, |state, cx| state.toggle_call_chat(cx))) |
| 624 | } |
| 625 | |
| 626 | fn hand_button(app: &Entity<AppState>, model: &CallModel) -> Stateful<Div> { |
| 627 | let raised = model.own_hand.is_some(); |
| 628 | let background = if raised { |
| 629 | theme::accent() |
| 630 | } else { |
| 631 | theme::surface_raised() |
| 632 | }; |
| 633 | let foreground = if raised { |
| 634 | theme::on_accent() |
| 635 | } else { |
| 636 | theme::text() |
| 637 | }; |
| 638 | let button = control_shell("call-hand", background).child(icon( |
| 639 | IconName::Hand, |
| 640 | CONTROL_ICON, |
| 641 | foreground, |
| 642 | )); |
| 643 | let tooltip = if raised { "Lower hand" } else { "Raise hand" }; |
| 644 | let button = button.tooltip(move |window, cx| Tooltip::new(tooltip).build(window, cx)); |
| 645 | if !model.can_react() { |
| 646 | return button.opacity(DISABLED_OPACITY).cursor_default(); |
| 647 | } |
| 648 | let app = app.clone(); |
| 649 | button.on_click(move |_, _, cx| { |
| 650 | cx.stop_propagation(); |
| 651 | app.update(cx, |state, cx| state.toggle_call_hand(cx)); |
| 652 | }) |
| 653 | } |
| 654 | |
| 655 | fn reactions_button(app: &Entity<AppState>, model: &CallModel) -> AnyElement { |
| 656 | let face = control_shell("call-reactions-face", theme::surface_raised()).child(icon( |
| 657 | IconName::FaceSlightlySmiling, |
| 658 | CONTROL_ICON, |
| 659 | theme::text(), |
| 660 | )); |
| 661 | if !model.can_react() { |
| 662 | return face |
| 663 | .opacity(DISABLED_OPACITY) |
| 664 | .cursor_default() |
| 665 | .into_any_element(); |
| 666 | } |
| 667 | let app = app.clone(); |
| 668 | Popover::new("call-reactions-popover") |
| 669 | .anchor(Anchor::BottomLeft) |
| 670 | .offset(px(10.)) |
| 671 | .trigger( |
| 672 | Button::new("call-reactions") |
| 673 | .ghost() |
| 674 | .p_0() |
| 675 | .size(px(CONTROL_SIZE)) |
| 676 | .rounded_full() |
| 677 | .child(face), |
| 678 | ) |
| 679 | .content(move |_, _, cx| { |
| 680 | let popover = cx.entity().downgrade(); |
| 681 | h_flex() |
| 682 | .id("call-reactions-row") |
| 683 | .gap(px(4.)) |
| 684 | .children(Reaction::ALL.into_iter().map(|reaction| { |
| 685 | let app = app.clone(); |
| 686 | let popover = popover.clone(); |
| 687 | div() |
| 688 | .id(reaction.name()) |
| 689 | .size(px(REACTION_CELL)) |
| 690 | .flex() |
| 691 | .items_center() |
| 692 | .justify_center() |
| 693 | .rounded(px(8.)) |
| 694 | .text_size(px(24.)) |
| 695 | .cursor_pointer() |
| 696 | .hover(|cell| cell.bg(theme::border_strong())) |
| 697 | .child(reaction_glyph(reaction)) |
| 698 | .on_click(move |_, window, cx| { |
| 699 | app.update(cx, |state, cx| state.send_call_reaction(reaction, cx)); |
| 700 | popover |
| 701 | .update(cx, |state, cx| state.dismiss(window, cx)) |
| 702 | .ok(); |
| 703 | }) |
| 704 | })) |
| 705 | }) |
| 706 | .into_any_element() |
| 707 | } |
| 708 | |
| 709 | fn leave_menu(app: &Entity<AppState>, model: &CallModel) -> impl IntoElement { |
| 710 | let leave_app = app.clone(); |
| 711 | let end_app = app.clone(); |
| 712 | let can_end = model.can_end_meeting; |
| 713 | let lower_app = app.clone(); |
| 714 | let can_lower_all = model.can_lower_hands() && model.any_hand_raised(); |
| 715 | Button::new("call-leave-menu") |
| 716 | .ghost() |
| 717 | .p_0() |
| 718 | .size(px(CONTROL_SIZE)) |
| 719 | .rounded_full() |
| 720 | .child(round_control( |
| 721 | "call-leave-menu-face", |
| 722 | IconName::ChevronUp, |
| 723 | theme::surface_raised(), |
| 724 | theme::text(), |
| 725 | )) |
| 726 | .dropdown_menu_with_anchor(Anchor::BottomRight, move |popup, _, _| { |
| 727 | let leave_app = leave_app.clone(); |
| 728 | let end_app = end_app.clone(); |
| 729 | let lower_app = lower_app.clone(); |
| 730 | let popup = popup.min_w(px(MENU_WIDTH)).item( |
| 731 | PopupMenuItem::new("Leave") |
| 732 | .icon(IconName::PhoneOff) |
| 733 | .on_click(move |_, _, cx| { |
| 734 | leave_app.update(cx, |state, cx| state.leave_call(cx)) |
| 735 | }), |
| 736 | ); |
| 737 | let popup = if can_lower_all { |
| 738 | popup.item( |
| 739 | PopupMenuItem::new("Lower all hands").on_click(move |_, _, cx| { |
| 740 | lower_app.update(cx, |state, cx| state.lower_all_call_hands(cx)) |
| 741 | }), |
| 742 | ) |
| 743 | } else { |
| 744 | popup |
| 745 | }; |
| 746 | if can_end { |
| 747 | popup.item( |
| 748 | PopupMenuItem::new("End meeting for everyone") |
| 749 | .icon(IconName::PhoneOff) |
| 750 | .on_click(move |_, _, cx| { |
| 751 | end_app.update(cx, |state, cx| state.end_meeting_for_all(cx)) |
| 752 | }), |
| 753 | ) |
| 754 | } else { |
| 755 | popup |
| 756 | } |
| 757 | }) |
| 758 | } |
| 759 | |
| 760 | pub(super) fn device_items( |
| 761 | entries: Vec<DeviceEntry>, |
| 762 | selected: &calling::DeviceChoice, |
| 763 | pick: impl Fn(calling::DeviceChoice, &mut App) + Clone + 'static, |
| 764 | ) -> Vec<PopupMenuItem> { |
| 765 | entries |
| 766 | .into_iter() |
| 767 | .map(|entry| { |
| 768 | let pick = pick.clone(); |
| 769 | let choice = entry.choice.clone(); |
| 770 | PopupMenuItem::new(entry.label) |
| 771 | .checked(&entry.choice == selected) |
| 772 | .on_click(move |_, _, cx| pick(choice.clone(), cx)) |
| 773 | }) |
| 774 | .collect() |
| 775 | } |
| 776 | |
| 777 | fn devices_menu(popup: PopupMenu, app: &Entity<AppState>, model: &CallModel) -> PopupMenu { |
| 778 | let input_app = app.clone(); |
| 779 | let output_app = app.clone(); |
| 780 | let inputs = device_items( |
| 781 | model.devices.input_entries(), |
| 782 | &model.input, |
| 783 | move |choice, cx| { |
| 784 | input_app.update(cx, |state, cx| state.select_call_input(choice, cx)); |
| 785 | }, |
| 786 | ); |
| 787 | let outputs = device_items( |
| 788 | model.devices.output_entries(), |
| 789 | &model.output, |
| 790 | move |choice, cx| { |
| 791 | output_app.update(cx, |state, cx| state.select_call_output(choice, cx)); |
| 792 | }, |
| 793 | ); |
| 794 | let mut popup = popup |
| 795 | .min_w(px(MENU_WIDTH)) |
| 796 | .item(PopupMenuItem::label("Microphone")); |
| 797 | if model.listen_only { |
| 798 | popup = popup.item(PopupMenuItem::new(NO_MICROPHONE_HINT).disabled(true)); |
| 799 | } else { |
| 800 | for item in inputs { |
| 801 | popup = popup.item(item); |
| 802 | } |
| 803 | } |
| 804 | popup = popup.separator().item(PopupMenuItem::label("Speaker")); |
| 805 | for item in outputs { |
| 806 | popup = popup.item(item); |
| 807 | } |
| 808 | popup |
| 809 | } |
| 810 | |
| 811 | fn mic_menu_button(app: &Entity<AppState>, model: &CallModel) -> impl IntoElement { |
| 812 | let app = app.clone(); |
| 813 | let model = model.clone(); |
| 814 | chevron_button("call-mic-menu", "call-mic-menu-face") |
| 815 | .dropdown_menu_with_anchor(Anchor::BottomLeft, move |popup, _, _| { |
| 816 | devices_menu(popup, &app, &model) |
| 817 | }) |
| 818 | } |
| 819 | |
| 820 | fn person_tile( |
| 821 | app: &Entity<AppState>, |
| 822 | state: &AppState, |
| 823 | model: &CallModel, |
| 824 | remote: &Tile, |
| 825 | size: TileSize, |
| 826 | now: Instant, |
| 827 | ) -> AnyElement { |
| 828 | let extras = TileExtras { |
| 829 | hand: remote.hand.map(|rank| model.hand_position(rank)), |
| 830 | own: false, |
| 831 | reaction: model |
| 832 | .chip_of(&remote.mri, now) |
| 833 | .map(|chip| (chip.reaction, chip.serial)), |
| 834 | spotlight: remote.spotlight.is_some(), |
| 835 | pinned: model.is_pinned(&remote.mri), |
| 836 | }; |
| 837 | let element = person_tile_body(state, model, remote, size, now, &extras); |
| 838 | with_tile_menu(app, model, &remote.mri, &remote.name, false, element) |
| 839 | } |
| 840 | |
| 841 | fn person_tile_body( |
| 842 | state: &AppState, |
| 843 | model: &CallModel, |
| 844 | remote: &Tile, |
| 845 | size: TileSize, |
| 846 | now: Instant, |
| 847 | extras: &TileExtras, |
| 848 | ) -> AnyElement { |
| 849 | let video = state |
| 850 | .call |
| 851 | .as_ref() |
| 852 | .filter(|_| remote.has_video || model.is_one_to_one()) |
| 853 | .and_then(|call| { |
| 854 | call.pictures |
| 855 | .live(&VideoKey::Person(remote.mri.clone()), now) |
| 856 | }); |
| 857 | if let Some(image) = video { |
| 858 | return video_tile( |
| 859 | size, |
| 860 | image, |
| 861 | &remote.name, |
| 862 | model.tile_speaking(remote), |
| 863 | remote.muted, |
| 864 | extras, |
| 865 | ) |
| 866 | .into_any_element(); |
| 867 | } |
| 868 | let waiting = remote.state == TileState::Invited; |
| 869 | let avatar = person_avatar( |
| 870 | &state.directory, |
| 871 | remote.user_id.as_deref(), |
| 872 | &remote.name, |
| 873 | size.avatar, |
| 874 | ); |
| 875 | let caption = model.tile_caption(remote).map(|text| { |
| 876 | let label = div() |
| 877 | .text_size(px(12.)) |
| 878 | .text_color(theme::text_muted()) |
| 879 | .child(text); |
| 880 | if waiting { |
| 881 | blinking(label) |
| 882 | } else { |
| 883 | label.into_any_element() |
| 884 | } |
| 885 | }); |
| 886 | tile( |
| 887 | size, |
| 888 | avatar, |
| 889 | &remote.name, |
| 890 | model.tile_speaking(remote), |
| 891 | remote.muted, |
| 892 | caption, |
| 893 | extras, |
| 894 | ) |
| 895 | .into_any_element() |
| 896 | } |
| 897 | |
| 898 | fn own_tile( |
| 899 | app: &Entity<AppState>, |
| 900 | state: &AppState, |
| 901 | model: &CallModel, |
| 902 | size: TileSize, |
| 903 | now: Instant, |
| 904 | ) -> AnyElement { |
| 905 | let own_mri = model.own_mri.clone().unwrap_or_default(); |
| 906 | let extras = TileExtras { |
| 907 | hand: model.own_hand.map(|rank| model.hand_position(rank)), |
| 908 | own: true, |
| 909 | reaction: model.own_chip(now).map(|chip| (chip.reaction, chip.serial)), |
| 910 | spotlight: model.own_spotlight.is_some(), |
| 911 | pinned: model.is_pinned(&own_mri), |
| 912 | }; |
| 913 | let element = own_tile_body(state, model, size, now, &extras); |
| 914 | if own_mri.is_empty() { |
| 915 | return element; |
| 916 | } |
| 917 | with_tile_menu(app, model, &own_mri, "You", true, element) |
| 918 | } |
| 919 | |
| 920 | fn own_tile_body( |
| 921 | state: &AppState, |
| 922 | model: &CallModel, |
| 923 | size: TileSize, |
| 924 | now: Instant, |
| 925 | extras: &TileExtras, |
| 926 | ) -> AnyElement { |
| 927 | let me = state.directory.me.as_ref(); |
| 928 | let self_view = state |
| 929 | .call |
| 930 | .as_ref() |
| 931 | .and_then(|call| call.pictures.live(&VideoKey::LocalCamera, now)); |
| 932 | if let Some(image) = self_view { |
| 933 | return video_tile( |
| 934 | size, |
| 935 | image, |
| 936 | "You", |
| 937 | model.local_speaking, |
| 938 | model.muted, |
| 939 | extras, |
| 940 | ) |
| 941 | .into_any_element(); |
| 942 | } |
| 943 | let avatar = person_avatar( |
| 944 | &state.directory, |
| 945 | me.map(|person| person.user_id.as_str()), |
| 946 | me.map_or("You", |person| person.display_name.as_str()), |
| 947 | size.avatar, |
| 948 | ); |
| 949 | tile( |
| 950 | size, |
| 951 | avatar, |
| 952 | "You", |
| 953 | model.local_speaking, |
| 954 | model.muted, |
| 955 | None, |
| 956 | extras, |
| 957 | ) |
| 958 | .into_any_element() |
| 959 | } |
| 960 | |
| 961 | fn remote_tiles( |
| 962 | app: &Entity<AppState>, |
| 963 | state: &AppState, |
| 964 | model: &CallModel, |
| 965 | size: TileSize, |
| 966 | hidden_cap: GridLayout, |
| 967 | now: Instant, |
| 968 | ) -> Vec<AnyElement> { |
| 969 | let visible = model.visible_tiles(); |
| 970 | let mut cells: Vec<AnyElement> = visible |
| 971 | .iter() |
| 972 | .take(hidden_cap.shown_others) |
| 973 | .map(|remote| person_tile(app, state, model, remote, size, now)) |
| 974 | .collect(); |
| 975 | if hidden_cap.hidden > 0 { |
| 976 | cells.push(overflow_tile(size, hidden_cap.hidden).into_any_element()); |
| 977 | } |
| 978 | cells |
| 979 | } |
| 980 | |
| 981 | fn people_strip( |
| 982 | app: &Entity<AppState>, |
| 983 | state: &AppState, |
| 984 | model: &CallModel, |
| 985 | now: Instant, |
| 986 | focused: Option<&str>, |
| 987 | ) -> Stateful<Div> { |
| 988 | let mut cells: Vec<AnyElement> = model |
| 989 | .strip_tiles() |
| 990 | .into_iter() |
| 991 | .filter(|remote| Some(remote.mri.as_str()) != focused) |
| 992 | .map(|remote| person_tile(app, state, model, remote, STRIP_TILE, now)) |
| 993 | .collect(); |
| 994 | if focused.is_none() || focused != model.own_mri.as_deref() { |
| 995 | let own_index = model.own_cell_index(cells.len()); |
| 996 | cells.insert(own_index, own_tile(app, state, model, STRIP_TILE, now)); |
| 997 | } |
| 998 | v_flex() |
| 999 | .id("call-strip") |
| 1000 | .flex_none() |
| 1001 | .w(px(STRIP_TILE.width)) |
| 1002 | .max_h(px( |
| 1003 | STRIP_VISIBLE * (STRIP_TILE.height + STRIP_GAP) - STRIP_GAP |
| 1004 | )) |
| 1005 | .gap(px(STRIP_GAP)) |
| 1006 | .overflow_y_scroll() |
| 1007 | .children(cells) |
| 1008 | } |
| 1009 | |
| 1010 | pub fn render_call_view( |
| 1011 | app: &Entity<AppState>, |
| 1012 | state: &AppState, |
| 1013 | chat: Option<Entity<ConversationView>>, |
| 1014 | ) -> Option<AnyElement> { |
| 1015 | let call = state.call.as_ref()?; |
| 1016 | let model = &call.model; |
| 1017 | let now = Instant::now(); |
| 1018 | let (status, status_color) = status_line(model, now); |
| 1019 | let header = h_flex() |
| 1020 | .w_full() |
| 1021 | .h(px(HEADER_HEIGHT)) |
| 1022 | .flex_none() |
| 1023 | .px(px(20.)) |
| 1024 | .gap(px(12.)) |
| 1025 | .items_center() |
| 1026 | .child(icon(IconName::Phone, 18., theme::accent_text())) |
| 1027 | .child( |
| 1028 | div() |
| 1029 | .min_w_0() |
| 1030 | .truncate() |
| 1031 | .text_size(px(16.)) |
| 1032 | .font_weight(FontWeight::SEMIBOLD) |
| 1033 | .child(model.title.clone()), |
| 1034 | ) |
| 1035 | .child( |
| 1036 | div() |
| 1037 | .flex_none() |
| 1038 | .text_size(px(13.)) |
| 1039 | .text_color(status_color) |
| 1040 | .child(status), |
| 1041 | ) |
| 1042 | .children(health_indicator(model)) |
| 1043 | .children(recording_chip(model)) |
| 1044 | .children(room_chip(model)) |
| 1045 | .child(div().flex_1()) |
| 1046 | .children(return_button(app, model)); |
| 1047 | |
| 1048 | let max_tiles = if chat.is_some() { |
| 1049 | CHAT_OPEN_TILES |
| 1050 | } else { |
| 1051 | MAX_TILES |
| 1052 | }; |
| 1053 | let layout = grid_layout(model.visible_tiles().len(), max_tiles); |
| 1054 | let cells_for_size = if chat.is_some() { |
| 1055 | MAX_TILES |
| 1056 | } else { |
| 1057 | layout.shown_others + usize::from(layout.hidden > 0) + 1 |
| 1058 | }; |
| 1059 | let size = tile_size(cells_for_size); |
| 1060 | let mut cells = remote_tiles(app, state, model, size, layout, now); |
| 1061 | let own_index = model.own_cell_index(cells.len()); |
| 1062 | cells.insert(own_index, own_tile(app, state, model, size, now)); |
| 1063 | let focus = model.focus().filter(|_| model.screen_sharer.is_none()); |
| 1064 | let stage = render_stage(app, state, false) |
| 1065 | .or_else(|| whiteboard_stage(app, model)) |
| 1066 | .or_else(|| { |
| 1067 | focus |
| 1068 | .as_ref() |
| 1069 | .and_then(|focus| render_focus_stage(app, state, focus, now)) |
| 1070 | }); |
| 1071 | let hold = hold_panel(app, model); |
| 1072 | let focused = focus.as_ref().map(|focus| focus.mri.as_str()); |
| 1073 | |
| 1074 | let controls = h_flex() |
| 1075 | .w_full() |
| 1076 | .flex_none() |
| 1077 | .py(px(16.)) |
| 1078 | .gap(px(12.)) |
| 1079 | .items_center() |
| 1080 | .justify_center() |
| 1081 | .child( |
| 1082 | h_flex() |
| 1083 | .h(px(CONTROL_SIZE)) |
| 1084 | .items_center() |
| 1085 | .rounded_full() |
| 1086 | .bg(theme::surface_raised()) |
| 1087 | .child(mute_button(app, model, "call-mute", CONTROL_SIZE)) |
| 1088 | .child(mic_menu_button(app, model)), |
| 1089 | ) |
| 1090 | .child( |
| 1091 | h_flex() |
| 1092 | .h(px(CONTROL_SIZE)) |
| 1093 | .items_center() |
| 1094 | .rounded_full() |
| 1095 | .bg(theme::surface_raised()) |
| 1096 | .child(camera_button(app, model)) |
| 1097 | .children(camera_menu_button(app, model, BackgroundMenu::of(state))), |
| 1098 | ) |
| 1099 | .child(share_button(app, model, state.call_share_sound)) |
| 1100 | .when(model.has_reaction_controls(), |row| { |
| 1101 | row.child(hand_button(app, model)) |
| 1102 | .child(reactions_button(app, model)) |
| 1103 | }) |
| 1104 | .children(more_button(app, model)) |
| 1105 | .when(call.chat_thread().is_some(), |row| { |
| 1106 | row.child(chat_button(app, call.chat_open, state.call_chat_unread())) |
| 1107 | }) |
| 1108 | .child(leave_button(app, model, "call-leave", false)) |
| 1109 | .when(model.kind == CallKind::Meeting, |row| { |
| 1110 | row.child(leave_menu(app, model)) |
| 1111 | }); |
| 1112 | |
| 1113 | let column = v_flex() |
| 1114 | .relative() |
| 1115 | .flex_1() |
| 1116 | .min_w_0() |
| 1117 | .h_full() |
| 1118 | .rounded(px(10.)) |
| 1119 | .overflow_hidden() |
| 1120 | .bg(theme::surface()) |
| 1121 | .child(header) |
| 1122 | .children(lobby_banner(app, model)) |
| 1123 | .children(health_banner(app, model)) |
| 1124 | .children(sharing_banner(app, model, state.call_share_sound)) |
| 1125 | .children(consult_banner(app, state)) |
| 1126 | .child(match stage { |
| 1127 | _ if hold.is_some() => hold.expect("checked above"), |
| 1128 | Some(stage) => h_flex() |
| 1129 | .flex_1() |
| 1130 | .min_h_0() |
| 1131 | .p(px(GRID_PADDING)) |
| 1132 | .gap(px(TILE_GAP)) |
| 1133 | .items_center() |
| 1134 | .child(stage) |
| 1135 | .child(people_strip(app, state, model, now, focused)) |
| 1136 | .into_any_element(), |
| 1137 | None => h_flex() |
| 1138 | .id("call-grid") |
| 1139 | .flex_1() |
| 1140 | .min_h_0() |
| 1141 | .overflow_y_scroll() |
| 1142 | .flex_wrap() |
| 1143 | .content_center() |
| 1144 | .p(px(GRID_PADDING)) |
| 1145 | .gap(px(TILE_GAP)) |
| 1146 | .items_center() |
| 1147 | .justify_center() |
| 1148 | .children(cells) |
| 1149 | .into_any_element(), |
| 1150 | }) |
| 1151 | .child(controls) |
| 1152 | .children(captions_overlay(model, now)) |
| 1153 | .children(captions_hint_chip(model)) |
| 1154 | .children(state.transfer_picker.clone()) |
| 1155 | .children(consent_overlay(app, model)); |
| 1156 | Some( |
| 1157 | h_flex() |
| 1158 | .debug_selector(|| "shell/islands/main".into()) |
| 1159 | .flex_1() |
| 1160 | .min_w_0() |
| 1161 | .h_full() |
| 1162 | .gap(px(ISLAND_GAP)) |
| 1163 | .child(column) |
| 1164 | .children(chat.map(|chat| chat_panel(app, chat))) |
| 1165 | .into_any_element(), |
| 1166 | ) |
| 1167 | } |
| 1168 | |
| 1169 | fn chat_panel(app: &Entity<AppState>, chat: Entity<ConversationView>) -> AnyElement { |
| 1170 | let app = app.clone(); |
| 1171 | v_flex() |
| 1172 | .id("call-chat-panel") |
| 1173 | .w(px(CHAT_PANEL_WIDTH)) |
| 1174 | .h_full() |
| 1175 | .flex_none() |
| 1176 | .rounded(px(10.)) |
| 1177 | .overflow_hidden() |
| 1178 | .bg(theme::surface()) |
| 1179 | .child( |
| 1180 | h_flex() |
| 1181 | .w_full() |
| 1182 | .h(px(CHAT_HEADER_HEIGHT)) |
| 1183 | .flex_none() |
| 1184 | .pl(px(20.)) |
| 1185 | .pr(px(12.)) |
| 1186 | .items_center() |
| 1187 | .justify_between() |
| 1188 | .child( |
| 1189 | div() |
| 1190 | .text_size(px(15.)) |
| 1191 | .font_weight(FontWeight::SEMIBOLD) |
| 1192 | .child("Chat"), |
| 1193 | ) |
| 1194 | .child( |
| 1195 | div() |
| 1196 | .id("call-chat-close") |
| 1197 | .size(px(28.)) |
| 1198 | .flex() |
| 1199 | .items_center() |
| 1200 | .justify_center() |
| 1201 | .rounded(px(7.)) |
| 1202 | .cursor_pointer() |
| 1203 | .hover(|button| button.bg(theme::row_hover())) |
| 1204 | .tooltip(|window, cx| Tooltip::new("Close the chat").build(window, cx)) |
| 1205 | .child(icon(IconName::Close, 14., theme::text_muted())) |
| 1206 | .on_click(move |_, _, cx| { |
| 1207 | app.update(cx, |state, cx| state.toggle_call_chat(cx)) |
| 1208 | }), |
| 1209 | ), |
| 1210 | ) |
| 1211 | .child(chat) |
| 1212 | .into_any_element() |
| 1213 | } |