mirror of
https://github.com/zed-industries/zed.git
synced 2024-12-24 17:28:40 +00:00
Add an empty state to the notification panel
This commit is contained in:
parent
522b76e452
commit
c66385f0f9
2 changed files with 22 additions and 3 deletions
|
@ -299,6 +299,19 @@ impl NotificationPanel {
|
|||
.into_any()
|
||||
}
|
||||
|
||||
fn render_empty_state(
|
||||
&self,
|
||||
theme: &Arc<Theme>,
|
||||
_cx: &mut ViewContext<Self>,
|
||||
) -> AnyElement<Self> {
|
||||
Label::new(
|
||||
"You have no notifications".to_string(),
|
||||
theme.chat_panel.sign_in_prompt.default.clone(),
|
||||
)
|
||||
.aligned()
|
||||
.into_any()
|
||||
}
|
||||
|
||||
fn on_notification_event(
|
||||
&mut self,
|
||||
_: ModelHandle<NotificationStore>,
|
||||
|
@ -373,13 +386,15 @@ impl View for NotificationPanel {
|
|||
|
||||
fn render(&mut self, cx: &mut ViewContext<Self>) -> AnyElement<Self> {
|
||||
let theme = theme::current(cx);
|
||||
let element = if self.client.user_id().is_some() {
|
||||
let element = if self.client.user_id().is_none() {
|
||||
self.render_sign_in_prompt(&theme, cx)
|
||||
} else if self.notification_list.item_count() == 0 {
|
||||
self.render_empty_state(&theme, cx)
|
||||
} else {
|
||||
List::new(self.notification_list.clone())
|
||||
.contained()
|
||||
.with_style(theme.chat_panel.list)
|
||||
.into_any()
|
||||
} else {
|
||||
self.render_sign_in_prompt(&theme, cx)
|
||||
};
|
||||
element
|
||||
.contained()
|
||||
|
|
|
@ -378,6 +378,10 @@ impl<V: 'static> ListState<V> {
|
|||
.extend((0..element_count).map(|_| ListItem::Unrendered), &());
|
||||
}
|
||||
|
||||
pub fn item_count(&self) -> usize {
|
||||
self.0.borrow().items.summary().count
|
||||
}
|
||||
|
||||
pub fn splice(&self, old_range: Range<usize>, count: usize) {
|
||||
let state = &mut *self.0.borrow_mut();
|
||||
|
||||
|
|
Loading…
Reference in a new issue