1use std::marker::PhantomData;
2
3use crate::{prelude::*, static_new_notification_items, static_read_notification_items};
4use crate::{List, ListHeader};
5
6#[derive(Element)]
7pub struct NotificationsPanel<S: 'static + Send + Sync + Clone> {
8 state_type: PhantomData<S>,
9}
10
11impl<S: 'static + Send + Sync + Clone> NotificationsPanel<S> {
12 pub fn new() -> Self {
13 Self {
14 state_type: PhantomData,
15 }
16 }
17
18 fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Element<ViewState = S> {
19 let color = ThemeColor::new(cx);
20
21 div()
22 .flex()
23 .flex_col()
24 .w_full()
25 .h_full()
26 .bg(color.surface)
27 .child(
28 div()
29 .w_full()
30 .flex()
31 .flex_col()
32 .overflow_y_scroll(ScrollState::default())
33 .child(
34 List::new(static_new_notification_items())
35 .header(ListHeader::new("NEW").set_toggle(ToggleState::Toggled))
36 .set_toggle(ToggleState::Toggled),
37 )
38 .child(
39 List::new(static_read_notification_items())
40 .header(ListHeader::new("EARLIER").set_toggle(ToggleState::Toggled))
41 .empty_message("No new notifications")
42 .set_toggle(ToggleState::Toggled),
43 ),
44 )
45 }
46}
47
48#[cfg(feature = "stories")]
49pub use stories::*;
50
51#[cfg(feature = "stories")]
52mod stories {
53 use crate::{Panel, Story};
54
55 use super::*;
56
57 #[derive(Element)]
58 pub struct NotificationsPanelStory<S: 'static + Send + Sync + Clone> {
59 state_type: PhantomData<S>,
60 }
61
62 impl<S: 'static + Send + Sync + Clone> NotificationsPanelStory<S> {
63 pub fn new() -> Self {
64 Self {
65 state_type: PhantomData,
66 }
67 }
68
69 fn render(
70 &mut self,
71 _view: &mut S,
72 cx: &mut ViewContext<S>,
73 ) -> impl Element<ViewState = S> {
74 Story::container(cx)
75 .child(Story::title_for::<_, NotificationsPanel<S>>(cx))
76 .child(Story::label(cx, "Default"))
77 .child(Panel::new(cx).child(NotificationsPanel::new()))
78 }
79 }
80}