1use crate::prelude::*;
2use crate::{Avatar, Facepile, PlayerWithCallStatus};
3
4#[derive(Element)]
5pub struct PlayerStack {
6 player_with_call_status: PlayerWithCallStatus,
7}
8
9impl PlayerStack {
10 pub fn new(player_with_call_status: PlayerWithCallStatus) -> Self {
11 Self {
12 player_with_call_status,
13 }
14 }
15
16 fn render<V: 'static>(&mut self, _: &mut V, cx: &mut ViewContext<V>) -> impl IntoElement<V> {
17 let system_color = SystemColor::new();
18 let player = self.player_with_call_status.get_player();
19 self.player_with_call_status.get_call_status();
20
21 let followers = self
22 .player_with_call_status
23 .get_call_status()
24 .followers
25 .as_ref()
26 .map(|followers| followers.clone());
27
28 // if we have no followers return a slightly different element
29 // if mic_status == muted add a red ring to avatar
30
31 div()
32 .h_full()
33 .flex()
34 .flex_col()
35 .gap_px()
36 .justify_center()
37 .child(
38 div().flex().justify_center().w_full().child(
39 div()
40 .w_4()
41 .h_1()
42 .rounded_bl_sm()
43 .rounded_br_sm()
44 .fill(player.cursor_color(cx)),
45 ),
46 )
47 .child(
48 div()
49 .flex()
50 .items_center()
51 .justify_center()
52 .h_6()
53 .px_1()
54 .rounded_lg()
55 .fill(if followers.is_none() {
56 system_color.transparent
57 } else {
58 player.selection_color(cx)
59 })
60 .child(Avatar::new(player.avatar_src().to_string()))
61 .children(followers.map(|followers| {
62 div().neg_mr_1().child(Facepile::new(followers.into_iter()))
63 })),
64 )
65 }
66}