Style signed-out and empty states for the notification panel
This commit is contained in:
parent
3886b1993d
commit
636c12ec3f
1 changed files with 65 additions and 46 deletions
|
@ -439,28 +439,6 @@ impl NotificationPanel {
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render_sign_in_prompt(&self) -> AnyElement {
|
|
||||||
Button::new(
|
|
||||||
"sign_in_prompt_button",
|
|
||||||
"Sign in to view your notifications",
|
|
||||||
)
|
|
||||||
.on_click({
|
|
||||||
let client = self.client.clone();
|
|
||||||
move |_, cx| {
|
|
||||||
let client = client.clone();
|
|
||||||
cx.spawn(move |cx| async move {
|
|
||||||
client.authenticate_and_connect(true, &cx).log_err().await;
|
|
||||||
})
|
|
||||||
.detach()
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.into_any_element()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn render_empty_state(&self) -> AnyElement {
|
|
||||||
Label::new("You have no notifications").into_any_element()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn on_notification_event(
|
fn on_notification_event(
|
||||||
&mut self,
|
&mut self,
|
||||||
_: Model<NotificationStore>,
|
_: Model<NotificationStore>,
|
||||||
|
@ -543,31 +521,72 @@ impl NotificationPanel {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Render for NotificationPanel {
|
impl Render for NotificationPanel {
|
||||||
type Element = AnyElement;
|
type Element = Div;
|
||||||
|
|
||||||
fn render(&mut self, cx: &mut ViewContext<Self>) -> AnyElement {
|
fn render(&mut self, cx: &mut ViewContext<Self>) -> Div {
|
||||||
if self.client.user_id().is_none() {
|
v_stack()
|
||||||
self.render_sign_in_prompt()
|
.size_full()
|
||||||
} else if self.notification_list.item_count() == 0 {
|
.child(
|
||||||
self.render_empty_state()
|
h_stack()
|
||||||
} else {
|
.justify_between()
|
||||||
v_stack()
|
.px_2()
|
||||||
.child(
|
.py_1()
|
||||||
h_stack()
|
// Match the height of the tab bar so they line up.
|
||||||
.justify_between()
|
.h(rems(ui::Tab::HEIGHT_IN_REMS))
|
||||||
.px_2()
|
.border_b_1()
|
||||||
.py_1()
|
.border_color(cx.theme().colors().border)
|
||||||
// Match the height of the tab bar so they line up.
|
.child(Label::new("Notifications"))
|
||||||
.h(rems(ui::Tab::HEIGHT_IN_REMS))
|
.child(IconElement::new(Icon::Envelope)),
|
||||||
.border_b_1()
|
)
|
||||||
.border_color(cx.theme().colors().border)
|
.map(|this| {
|
||||||
.child(Label::new("Notifications"))
|
if self.client.user_id().is_none() {
|
||||||
.child(IconElement::new(Icon::Envelope)),
|
this.child(
|
||||||
)
|
v_stack()
|
||||||
.child(list(self.notification_list.clone()).size_full())
|
.gap_2()
|
||||||
.size_full()
|
.p_4()
|
||||||
.into_any_element()
|
.child(
|
||||||
}
|
Button::new("sign_in_prompt_button", "Sign in")
|
||||||
|
.icon_color(Color::Muted)
|
||||||
|
.icon(Icon::Github)
|
||||||
|
.icon_position(IconPosition::Start)
|
||||||
|
.style(ButtonStyle::Filled)
|
||||||
|
.full_width()
|
||||||
|
.on_click({
|
||||||
|
let client = self.client.clone();
|
||||||
|
move |_, cx| {
|
||||||
|
let client = client.clone();
|
||||||
|
cx.spawn(move |cx| async move {
|
||||||
|
client
|
||||||
|
.authenticate_and_connect(true, &cx)
|
||||||
|
.log_err()
|
||||||
|
.await;
|
||||||
|
})
|
||||||
|
.detach()
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
.child(
|
||||||
|
div().flex().w_full().items_center().child(
|
||||||
|
Label::new("Sign in to view notifications.")
|
||||||
|
.color(Color::Muted)
|
||||||
|
.size(LabelSize::Small),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
} else if self.notification_list.item_count() == 0 {
|
||||||
|
this.child(
|
||||||
|
v_stack().p_4().child(
|
||||||
|
div().flex().w_full().items_center().child(
|
||||||
|
Label::new("You have no notifications.")
|
||||||
|
.color(Color::Muted)
|
||||||
|
.size(LabelSize::Small),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
this.child(list(self.notification_list.clone()).size_full())
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue