1use gpui::{AnyElement, SharedUri, img, prelude::*};
2use smallvec::SmallVec;
3use ui::prelude::*;
4
5#[derive(IntoElement)]
6pub struct CollabNotification {
7 avatar_uri: SharedUri,
8 accept_button: Button,
9 dismiss_button: Button,
10 children: SmallVec<[AnyElement; 2]>,
11}
12
13impl CollabNotification {
14 pub fn new(
15 avatar_uri: impl Into<SharedUri>,
16 accept_button: Button,
17 dismiss_button: Button,
18 ) -> Self {
19 Self {
20 avatar_uri: avatar_uri.into(),
21 accept_button,
22 dismiss_button,
23 children: SmallVec::new(),
24 }
25 }
26}
27
28impl ParentElement for CollabNotification {
29 fn extend(&mut self, elements: impl IntoIterator<Item = AnyElement>) {
30 self.children.extend(elements)
31 }
32}
33
34impl RenderOnce for CollabNotification {
35 fn render(self, _: &mut Window, cx: &mut App) -> impl IntoElement {
36 h_flex()
37 .text_ui(cx)
38 .justify_between()
39 .size_full()
40 .overflow_hidden()
41 .elevation_3(cx)
42 .p_2()
43 .gap_2()
44 .child(img(self.avatar_uri).w_12().h_12().rounded_full())
45 .child(v_flex().overflow_hidden().children(self.children))
46 .child(
47 v_flex()
48 .child(self.accept_button)
49 .child(self.dismiss_button),
50 )
51 }
52}