Tweak styling of notifications

Co-authored-by: Piotr <piotr@zed.dev>
This commit is contained in:
Max Brunsfeld 2023-10-23 14:58:03 +02:00
parent 2f0eaafc39
commit 4d491ca3a1

View file

@ -232,54 +232,56 @@ impl NotificationPanel {
MouseEventHandler::new::<NotificationEntry, _>(ix, cx, |_, cx| { MouseEventHandler::new::<NotificationEntry, _>(ix, cx, |_, cx| {
let container = message_style.container; let container = message_style.container;
Flex::column()
.with_child(
Flex::row() Flex::row()
.with_children(actor.map(|actor| { .with_children(actor.map(|actor| {
render_avatar( render_avatar(actor.avatar.clone(), &style.avatar, style.avatar_container)
actor.avatar.clone(),
&style.avatar,
style.avatar_container,
)
})) }))
.with_child(
Flex::column()
.with_child(Text::new(text, message_style.text.clone()))
.with_child(
Flex::row()
.with_child( .with_child(
Label::new( Label::new(
format_timestamp(timestamp, now, self.local_timezone), format_timestamp(timestamp, now, self.local_timezone),
style.timestamp.text.clone(), style.timestamp.text.clone(),
) )
.contained() .contained()
.with_style(style.timestamp.container) .with_style(style.timestamp.container),
.flex_float(),
) )
.align_children_center(),
)
.with_child(Text::new(text, message_style.text.clone()))
.with_children(if let Some(is_accepted) = response { .with_children(if let Some(is_accepted) = response {
Some( Some(
Label::new( Label::new(
if is_accepted { if is_accepted {
"You Accepted" "You accepted"
} else { } else {
"You Declined" "You declined"
}, },
style.read_text.text.clone(), style.read_text.text.clone(),
) )
.flex_float()
.into_any(), .into_any(),
) )
} else if needs_response { } else if needs_response {
Some( Some(
Flex::row() Flex::row()
.with_children([ .with_children([
MouseEventHandler::new::<Decline, _>(ix, cx, |state, _| { MouseEventHandler::new::<Decline, _>(
let button = style.button.style_for(state); ix,
Label::new("Decline", button.text.clone()) cx,
|state, _| {
let button =
style.button.style_for(state);
Label::new(
"Decline",
button.text.clone(),
)
.contained() .contained()
.with_style(button.container) .with_style(button.container)
}) },
)
.with_cursor_style(CursorStyle::PointingHand) .with_cursor_style(CursorStyle::PointingHand)
.on_click( .on_click(MouseButton::Left, {
MouseButton::Left,
{
let notification = notification.clone(); let notification = notification.clone();
move |_, view, cx| { move |_, view, cx| {
view.respond_to_notification( view.respond_to_notification(
@ -288,18 +290,23 @@ impl NotificationPanel {
cx, cx,
); );
} }
}, }),
), MouseEventHandler::new::<Accept, _>(
MouseEventHandler::new::<Accept, _>(ix, cx, |state, _| { ix,
let button = style.button.style_for(state); cx,
Label::new("Accept", button.text.clone()) |state, _| {
let button =
style.button.style_for(state);
Label::new(
"Accept",
button.text.clone(),
)
.contained() .contained()
.with_style(button.container) .with_style(button.container)
}) },
)
.with_cursor_style(CursorStyle::PointingHand) .with_cursor_style(CursorStyle::PointingHand)
.on_click( .on_click(MouseButton::Left, {
MouseButton::Left,
{
let notification = notification.clone(); let notification = notification.clone();
move |_, view, cx| { move |_, view, cx| {
view.respond_to_notification( view.respond_to_notification(
@ -308,16 +315,17 @@ impl NotificationPanel {
cx, cx,
); );
} }
}, }),
),
]) ])
.aligned() .flex_float()
.right()
.into_any(), .into_any(),
) )
} else { } else {
None None
}) }),
)
.flex(1.0, true),
)
.contained() .contained()
.with_style(container) .with_style(container)
.into_any() .into_any()
@ -394,7 +402,7 @@ impl NotificationPanel {
Some(NotificationPresenter { Some(NotificationPresenter {
icon: "icons/conversations.svg", icon: "icons/conversations.svg",
text: format!( text: format!(
"{} mentioned you in the #{} channel:\n{}", "{} mentioned you in #{}:\n{}",
sender.github_login, channel.name, message.body, sender.github_login, channel.name, message.body,
), ),
needs_response: false, needs_response: false,