use std::marker::PhantomData; use crate::{prelude::*, static_new_notification_items, static_read_notification_items}; use crate::{List, ListHeader}; #[derive(IntoAnyElement)] pub struct NotificationsPanel { id: ElementId, state_type: PhantomData, } impl NotificationsPanel { pub fn new(id: impl Into) -> Self { Self { id: id.into(), state_type: PhantomData, } } fn render(self, _view: &mut S, cx: &mut ViewContext) -> impl IntoAnyElement { let theme = theme(cx); div() .id(self.id.clone()) .flex() .flex_col() .w_full() .h_full() .bg(theme.surface) .child( div() .id("header") .w_full() .flex() .flex_col() .overflow_y_scroll() .child( List::new(static_new_notification_items()) .header(ListHeader::new("NEW").toggle(ToggleState::Toggled)) .toggle(ToggleState::Toggled), ) .child( List::new(static_read_notification_items()) .header(ListHeader::new("EARLIER").toggle(ToggleState::Toggled)) .empty_message("No new notifications") .toggle(ToggleState::Toggled), ), ) } } #[cfg(feature = "stories")] pub use stories::*; #[cfg(feature = "stories")] mod stories { use crate::{Panel, Story}; use super::*; #[derive(IntoAnyElement)] pub struct NotificationsPanelStory { state_type: PhantomData, } impl NotificationsPanelStory { pub fn new() -> Self { Self { state_type: PhantomData, } } fn render(self, _view: &mut S, cx: &mut ViewContext) -> impl IntoAnyElement { Story::container(cx) .child(Story::title_for::<_, NotificationsPanel>(cx)) .child(Story::label(cx, "Default")) .child( Panel::new("panel", cx).child(NotificationsPanel::new("notifications_panel")), ) } } }