diff --git a/crates/ui2/src/components/notification.rs b/crates/ui2/src/components/notification.rs index 606096aeff..b4f6b10d28 100644 --- a/crates/ui2/src/components/notification.rs +++ b/crates/ui2/src/components/notification.rs @@ -1,4 +1,4 @@ -use gpui3::{Element, ParentElement, StyleHelpers, ViewContext}; +use gpui3::{div, Element, ParentElement, StyleHelpers, ViewContext}; use crate::{ h_stack, v_stack, Button, Icon, IconButton, IconElement, Label, ThemeColor, Toast, ToastOrigin, @@ -12,7 +12,8 @@ pub struct NotificationToast { left_icon: Option, title: String, message: String, - actions: Vec>, + primary_action: Button, + secondary_action: Option>, } impl NotificationToast { @@ -20,12 +21,14 @@ impl NotificationToast { title: impl Into, message: impl Into, actions: Vec>, + primary_action: Button, ) -> Self { Self { left_icon: None, title: title.into(), message: message.into(), - actions, + primary_action, + secondary_action: None, } } @@ -34,9 +37,22 @@ impl NotificationToast { self } + pub fn set_secondary_action(mut self, action: Button) -> Self { + self.secondary_action = Some(action); + self + } + fn render(&mut self, _view: &mut S, cx: &mut ViewContext) -> impl Element { let color = ThemeColor::new(cx); + // TODO: Fix me + + // let secondary_action = if self.secondary_action.is_some() { + // div().child(Some(self.secondary_action)) + // } else { + // div() + // }; + let notification = h_stack() .gap_1() .items_start() @@ -47,14 +63,20 @@ impl NotificationToast { h_stack() .justify_between() .p_1() - .child(Label::new(self.title)) + .child(Label::new(self.title.clone())) .child(IconButton::new(Icon::Close)), ) .child( - h_stack() + v_stack() .p_1() - .child(Label::new(self.message)) - .children(self.actions.iter().map(|action| action)), + .child(Label::new(self.message.clone())) + .child( + h_stack() + .gap_1() + .justify_end() + .child(Label::new("Secondary").color(crate::LabelColor::Muted)) + .child(Label::new("Primary")), + ), ), );