From 4d491ca3a155868430ab46be16561e3e31400ff8 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Mon, 23 Oct 2023 14:58:03 +0200 Subject: [PATCH] Tweak styling of notifications Co-authored-by: Piotr --- crates/collab_ui/src/notification_panel.rs | 174 +++++++++++---------- 1 file changed, 91 insertions(+), 83 deletions(-) diff --git a/crates/collab_ui/src/notification_panel.rs b/crates/collab_ui/src/notification_panel.rs index 48d09a5c6c..e245a919f3 100644 --- a/crates/collab_ui/src/notification_panel.rs +++ b/crates/collab_ui/src/notification_panel.rs @@ -232,92 +232,100 @@ impl NotificationPanel { MouseEventHandler::new::(ix, cx, |_, cx| { let container = message_style.container; - Flex::column() + Flex::row() + .with_children(actor.map(|actor| { + render_avatar(actor.avatar.clone(), &style.avatar, style.avatar_container) + })) .with_child( - Flex::row() - .with_children(actor.map(|actor| { - render_avatar( - actor.avatar.clone(), - &style.avatar, - style.avatar_container, - ) - })) + Flex::column() + .with_child(Text::new(text, message_style.text.clone())) .with_child( - Label::new( - format_timestamp(timestamp, now, self.local_timezone), - style.timestamp.text.clone(), - ) - .contained() - .with_style(style.timestamp.container) - .flex_float(), + Flex::row() + .with_child( + Label::new( + format_timestamp(timestamp, now, self.local_timezone), + style.timestamp.text.clone(), + ) + .contained() + .with_style(style.timestamp.container), + ) + .with_children(if let Some(is_accepted) = response { + Some( + Label::new( + if is_accepted { + "You accepted" + } else { + "You declined" + }, + style.read_text.text.clone(), + ) + .flex_float() + .into_any(), + ) + } else if needs_response { + Some( + Flex::row() + .with_children([ + MouseEventHandler::new::( + ix, + cx, + |state, _| { + let button = + style.button.style_for(state); + Label::new( + "Decline", + button.text.clone(), + ) + .contained() + .with_style(button.container) + }, + ) + .with_cursor_style(CursorStyle::PointingHand) + .on_click(MouseButton::Left, { + let notification = notification.clone(); + move |_, view, cx| { + view.respond_to_notification( + notification.clone(), + false, + cx, + ); + } + }), + MouseEventHandler::new::( + ix, + cx, + |state, _| { + let button = + style.button.style_for(state); + Label::new( + "Accept", + button.text.clone(), + ) + .contained() + .with_style(button.container) + }, + ) + .with_cursor_style(CursorStyle::PointingHand) + .on_click(MouseButton::Left, { + let notification = notification.clone(); + move |_, view, cx| { + view.respond_to_notification( + notification.clone(), + true, + cx, + ); + } + }), + ]) + .flex_float() + .into_any(), + ) + } else { + None + }), ) - .align_children_center(), + .flex(1.0, true), ) - .with_child(Text::new(text, message_style.text.clone())) - .with_children(if let Some(is_accepted) = response { - Some( - Label::new( - if is_accepted { - "You Accepted" - } else { - "You Declined" - }, - style.read_text.text.clone(), - ) - .into_any(), - ) - } else if needs_response { - Some( - Flex::row() - .with_children([ - MouseEventHandler::new::(ix, cx, |state, _| { - let button = style.button.style_for(state); - Label::new("Decline", button.text.clone()) - .contained() - .with_style(button.container) - }) - .with_cursor_style(CursorStyle::PointingHand) - .on_click( - MouseButton::Left, - { - let notification = notification.clone(); - move |_, view, cx| { - view.respond_to_notification( - notification.clone(), - false, - cx, - ); - } - }, - ), - MouseEventHandler::new::(ix, cx, |state, _| { - let button = style.button.style_for(state); - Label::new("Accept", button.text.clone()) - .contained() - .with_style(button.container) - }) - .with_cursor_style(CursorStyle::PointingHand) - .on_click( - MouseButton::Left, - { - let notification = notification.clone(); - move |_, view, cx| { - view.respond_to_notification( - notification.clone(), - true, - cx, - ); - } - }, - ), - ]) - .aligned() - .right() - .into_any(), - ) - } else { - None - }) .contained() .with_style(container) .into_any() @@ -394,7 +402,7 @@ impl NotificationPanel { Some(NotificationPresenter { icon: "icons/conversations.svg", text: format!( - "{} mentioned you in the #{} channel:\n{}", + "{} mentioned you in #{}:\n{}", sender.github_login, channel.name, message.body, ), needs_response: false,