1use ui::{prelude::*, Avatar, IconButtonShape};
2
3#[derive(IntoElement)]
4pub struct ChatNotice {
5 message: SharedString,
6 meta: Option<SharedString>,
7}
8
9impl ChatNotice {
10 pub fn new(message: impl Into<SharedString>) -> Self {
11 Self {
12 message: message.into(),
13 meta: None,
14 }
15 }
16
17 pub fn meta(mut self, meta: impl Into<SharedString>) -> Self {
18 self.meta = Some(meta.into());
19 self
20 }
21}
22
23impl RenderOnce for ChatNotice {
24 fn render(self, _cx: &mut WindowContext) -> impl IntoElement {
25 h_flex()
26 .w_full()
27 .items_start()
28 .mt_4()
29 .gap_3()
30 .child(
31 // TODO: Replace with question mark.
32 Avatar::new("https://zed.dev/assistant_avatar.png").size(rems_from_px(20.)),
33 )
34 .child(
35 v_flex()
36 .size_full()
37 .gap_1()
38 .pr_4()
39 .overflow_hidden()
40 .child(
41 h_flex()
42 .justify_between()
43 .overflow_hidden()
44 .child(
45 h_flex()
46 .flex_none()
47 .overflow_hidden()
48 .child(Label::new(self.message)),
49 )
50 .child(
51 h_flex()
52 .flex_shrink_0()
53 .gap_1()
54 .child(Button::new("allow", "Allow"))
55 .child(
56 IconButton::new("deny", IconName::Close)
57 .shape(IconButtonShape::Square)
58 .icon_color(Color::Muted)
59 .size(ButtonSize::None)
60 .icon_size(IconSize::XSmall),
61 ),
62 ),
63 )
64 .children(
65 self.meta.map(|meta| {
66 Label::new(meta).size(LabelSize::Small).color(Color::Muted)
67 }),
68 ),
69 )
70 }
71}