Add text wrapping to notifications

This commit is contained in:
Marshall Bowers 2023-12-20 12:48:30 -05:00
parent 9c4e8699ba
commit 87f879bfa9

View file

@ -6,11 +6,11 @@ use collections::HashMap;
use db::kvp::KEY_VALUE_STORE; use db::kvp::KEY_VALUE_STORE;
use futures::StreamExt; use futures::StreamExt;
use gpui::{ use gpui::{
actions, div, list, px, serde_json, AnyElement, AppContext, AsyncWindowContext, CursorStyle, actions, div, img, list, px, serde_json, AnyElement, AppContext, AsyncWindowContext,
DismissEvent, Div, Element, EventEmitter, FocusHandle, FocusableView, InteractiveElement, CursorStyle, DismissEvent, Div, Element, EventEmitter, FocusHandle, FocusableView,
IntoElement, ListAlignment, ListScrollEvent, ListState, Model, ParentElement, Render, Stateful, InteractiveElement, IntoElement, ListAlignment, ListScrollEvent, ListState, Model,
StatefulInteractiveElement, Styled, Task, View, ViewContext, VisualContext, WeakView, ParentElement, Render, Stateful, StatefulInteractiveElement, Styled, Task, View, ViewContext,
WindowContext, VisualContext, WeakView, WindowContext,
}; };
use notifications::{NotificationEntry, NotificationEvent, NotificationStore}; use notifications::{NotificationEntry, NotificationEvent, NotificationStore};
use project::Fs; use project::Fs;
@ -227,19 +227,37 @@ impl NotificationPanel {
} }
Some( Some(
div() h_stack()
.id(ix) .id(ix)
.size_full()
.gap_2()
.when(can_navigate, |el| {
el.cursor(CursorStyle::PointingHand).on_click({
let notification = notification.clone();
cx.listener(move |this, _, cx| {
this.did_click_notification(&notification, cx)
})
})
})
.children(
actor.map(|actor| img(actor.avatar_uri.clone()).w_8().h_8().rounded_full()),
)
.child(
v_stack()
.gap_1()
.size_full()
.child(Label::new(text.clone()))
.child( .child(
h_stack() h_stack()
.children(actor.map(|actor| Avatar::new(actor.avatar_uri.clone()))) .justify_between()
.child( .child(
v_stack().child(Label::new(text)).child( Label::new(format_timestamp(
h_stack()
.child(Label::new(format_timestamp(
timestamp, timestamp,
now, now,
self.local_timezone, self.local_timezone,
))) ))
.color(Color::Muted),
)
.children(if let Some(is_accepted) = response { .children(if let Some(is_accepted) = response {
Some(div().child(Label::new(if is_accepted { Some(div().child(Label::new(if is_accepted {
"You accepted" "You accepted"
@ -249,8 +267,7 @@ impl NotificationPanel {
} else if needs_response { } else if needs_response {
Some( Some(
h_stack() h_stack()
.child(Button::new("decline", "Decline").on_click( .child(Button::new("decline", "Decline").on_click({
{
let notification = notification.clone(); let notification = notification.clone();
let view = cx.view().clone(); let view = cx.view().clone();
move |_, cx| { move |_, cx| {
@ -262,8 +279,7 @@ impl NotificationPanel {
) )
}); });
} }
}, }))
))
.child(Button::new("accept", "Accept").on_click({ .child(Button::new("accept", "Accept").on_click({
let notification = notification.clone(); let notification = notification.clone();
let view = cx.view().clone(); let view = cx.view().clone();
@ -282,16 +298,7 @@ impl NotificationPanel {
None None
}), }),
), ),
),
) )
.when(can_navigate, |el| {
el.cursor(CursorStyle::PointingHand).on_click({
let notification = notification.clone();
cx.listener(move |this, _, cx| {
this.did_click_notification(&notification, cx)
})
})
})
.into_any(), .into_any(),
) )
} }