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_0p5()
42 .rounded_sm()
43 .fill(player.cursor_color(cx)),
44 ),
45 )
46 .child(
47 div()
48 .flex()
49 .items_center()
50 .justify_center()
51 .h_6()
52 .pl_1()
53 .rounded_lg()
54 .fill(if followers.is_none() {
55 system_color.transparent
56 } else {
57 player.selection_color(cx)
58 })
59 .child(Avatar::new(player.avatar_src().to_string()))
60 .children(followers.map(|followers| {
61 div().neg_ml_2().child(Facepile::new(followers.into_iter()))
62 })),
63 )
64 }
65}