Add text wrapping to notifications
This commit is contained in:
parent
9c4e8699ba
commit
87f879bfa9
1 changed files with 68 additions and 61 deletions
|
@ -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,63 +227,10 @@ impl NotificationPanel {
|
||||||
}
|
}
|
||||||
|
|
||||||
Some(
|
Some(
|
||||||
div()
|
h_stack()
|
||||||
.id(ix)
|
.id(ix)
|
||||||
.child(
|
.size_full()
|
||||||
h_stack()
|
.gap_2()
|
||||||
.children(actor.map(|actor| Avatar::new(actor.avatar_uri.clone())))
|
|
||||||
.child(
|
|
||||||
v_stack().child(Label::new(text)).child(
|
|
||||||
h_stack()
|
|
||||||
.child(Label::new(format_timestamp(
|
|
||||||
timestamp,
|
|
||||||
now,
|
|
||||||
self.local_timezone,
|
|
||||||
)))
|
|
||||||
.children(if let Some(is_accepted) = response {
|
|
||||||
Some(div().child(Label::new(if is_accepted {
|
|
||||||
"You accepted"
|
|
||||||
} else {
|
|
||||||
"You declined"
|
|
||||||
})))
|
|
||||||
} else if needs_response {
|
|
||||||
Some(
|
|
||||||
h_stack()
|
|
||||||
.child(Button::new("decline", "Decline").on_click(
|
|
||||||
{
|
|
||||||
let notification = notification.clone();
|
|
||||||
let view = cx.view().clone();
|
|
||||||
move |_, cx| {
|
|
||||||
view.update(cx, |this, cx| {
|
|
||||||
this.respond_to_notification(
|
|
||||||
notification.clone(),
|
|
||||||
false,
|
|
||||||
cx,
|
|
||||||
)
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
|
||||||
))
|
|
||||||
.child(Button::new("accept", "Accept").on_click({
|
|
||||||
let notification = notification.clone();
|
|
||||||
let view = cx.view().clone();
|
|
||||||
move |_, cx| {
|
|
||||||
view.update(cx, |this, cx| {
|
|
||||||
this.respond_to_notification(
|
|
||||||
notification.clone(),
|
|
||||||
true,
|
|
||||||
cx,
|
|
||||||
)
|
|
||||||
});
|
|
||||||
}
|
|
||||||
})),
|
|
||||||
)
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
.when(can_navigate, |el| {
|
.when(can_navigate, |el| {
|
||||||
el.cursor(CursorStyle::PointingHand).on_click({
|
el.cursor(CursorStyle::PointingHand).on_click({
|
||||||
let notification = notification.clone();
|
let notification = notification.clone();
|
||||||
|
@ -292,6 +239,66 @@ impl NotificationPanel {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
.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(
|
||||||
|
h_stack()
|
||||||
|
.justify_between()
|
||||||
|
.child(
|
||||||
|
Label::new(format_timestamp(
|
||||||
|
timestamp,
|
||||||
|
now,
|
||||||
|
self.local_timezone,
|
||||||
|
))
|
||||||
|
.color(Color::Muted),
|
||||||
|
)
|
||||||
|
.children(if let Some(is_accepted) = response {
|
||||||
|
Some(div().child(Label::new(if is_accepted {
|
||||||
|
"You accepted"
|
||||||
|
} else {
|
||||||
|
"You declined"
|
||||||
|
})))
|
||||||
|
} else if needs_response {
|
||||||
|
Some(
|
||||||
|
h_stack()
|
||||||
|
.child(Button::new("decline", "Decline").on_click({
|
||||||
|
let notification = notification.clone();
|
||||||
|
let view = cx.view().clone();
|
||||||
|
move |_, cx| {
|
||||||
|
view.update(cx, |this, cx| {
|
||||||
|
this.respond_to_notification(
|
||||||
|
notification.clone(),
|
||||||
|
false,
|
||||||
|
cx,
|
||||||
|
)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}))
|
||||||
|
.child(Button::new("accept", "Accept").on_click({
|
||||||
|
let notification = notification.clone();
|
||||||
|
let view = cx.view().clone();
|
||||||
|
move |_, cx| {
|
||||||
|
view.update(cx, |this, cx| {
|
||||||
|
this.respond_to_notification(
|
||||||
|
notification.clone(),
|
||||||
|
true,
|
||||||
|
cx,
|
||||||
|
)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
})),
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
)
|
||||||
.into_any(),
|
.into_any(),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue