Add additional notifications and style tweaks

Co-Authored-By: Marshall Bowers <1486634+maxdeviant@users.noreply.github.com>
This commit is contained in:
Nate Butler 2023-11-01 16:50:59 -04:00
parent be3cc6458c
commit 229ba0744e
3 changed files with 111 additions and 22 deletions

View file

@ -1,6 +1,6 @@
use crate::{ use crate::{
h_stack, prelude::*, static_new_notification_items, v_stack, Avatar, Button, Icon, IconButton, h_stack, prelude::*, static_new_notification_items_2, v_stack, Avatar, Button, Icon,
IconElement, Label, LabelColor, LineHeightStyle, ListHeaderMeta, ListSeparator, IconButton, IconElement, Label, LabelColor, LineHeightStyle, ListHeaderMeta, ListSeparator,
UnreadIndicator, UnreadIndicator,
}; };
use crate::{ClickHandler, ListHeader}; use crate::{ClickHandler, ListHeader};
@ -51,17 +51,11 @@ impl NotificationsPanel {
.line_height_style(LineHeightStyle::UILabel), .line_height_style(LineHeightStyle::UILabel),
), ),
) )
.children(static_new_notification_items()), .child(v_stack().px_1().children(static_new_notification_items_2())),
) )
} }
} }
pub enum NotificationItem<V: 'static> {
Message(Notification<V>),
// WithEdgeHeader(Notification<V>),
WithRequiredActions(NotificationWithActions<V>),
}
pub enum ButtonOrIconButton<V: 'static> { pub enum ButtonOrIconButton<V: 'static> {
Button(Button<V>), Button(Button<V>),
IconButton(IconButton<V>), IconButton(IconButton<V>),
@ -106,11 +100,6 @@ impl<V: 'static> NotificationAction<V> {
} }
} }
pub struct NotificationWithActions<V: 'static> {
notification: Notification<V>,
actions: [NotificationAction<V>; 2],
}
pub enum ActorOrIcon { pub enum ActorOrIcon {
Actor(PublicActor), Actor(PublicActor),
Icon(Icon), Icon(Icon),
@ -280,21 +269,29 @@ impl<V> Notification<V> {
div() div()
.relative() .relative()
.id(self.id.clone()) .id(self.id.clone())
.p_1()
.flex()
.flex_col()
.w_full()
.children( .children(
Some( Some(
div() div()
.absolute() .absolute()
.left(px(3.0)) .left(px(3.0))
.top_3() .top_3()
.z_index(2)
.child(UnreadIndicator::new()), .child(UnreadIndicator::new()),
) )
.filter(|_| self.unread), .filter(|_| self.unread),
) )
.child( .child(
v_stack() v_stack()
.z_index(1)
.gap_1() .gap_1()
.w_full()
.child( .child(
h_stack() h_stack()
.w_full()
.gap_2() .gap_2()
.child(self.render_slot(cx)) .child(self.render_slot(cx))
.child(div().flex_1().child(Label::new(self.message.clone()))), .child(div().flex_1().child(Label::new(self.message.clone()))),

View file

@ -12,6 +12,7 @@ impl UnreadIndicator {
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> { fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
div() div()
.rounded_full()
.border_2() .border_2()
.border_color(cx.theme().colors().surface) .border_color(cx.theme().colors().surface)
.w(px(9.0)) .w(px(9.0))

View file

@ -9,9 +9,8 @@ use theme2::ActiveTheme;
use crate::{ use crate::{
Buffer, BufferRow, BufferRows, Button, EditorPane, FileSystemStatus, GitStatus, Buffer, BufferRow, BufferRows, Button, EditorPane, FileSystemStatus, GitStatus,
HighlightedLine, Icon, Keybinding, Label, LabelColor, ListEntry, ListEntrySize, ListSubHeader, HighlightedLine, Icon, Keybinding, Label, LabelColor, ListEntry, ListEntrySize, ListSubHeader,
Livestream, MicStatus, ModifierKeys, Notification, NotificationItem, PaletteItem, Player, Livestream, MicStatus, ModifierKeys, Notification, PaletteItem, Player, PlayerCallStatus,
PlayerCallStatus, PlayerWithCallStatus, PublicActor, ScreenShareStatus, Symbol, Tab, PlayerWithCallStatus, PublicActor, ScreenShareStatus, Symbol, Tab, ToggleState, VideoStatus,
ToggleState, VideoStatus,
}; };
use crate::{HighlightedText, ListDetailsEntry}; use crate::{HighlightedText, ListDetailsEntry};
use crate::{ListItem, NotificationAction}; use crate::{ListItem, NotificationAction};
@ -328,15 +327,15 @@ pub fn static_players_with_call_status() -> Vec<PlayerWithCallStatus> {
] ]
} }
pub fn static_new_notification_items_2<V: 'static>() -> Vec<NotificationItem<V>> { pub fn static_new_notification_items_2<V: 'static>() -> Vec<Notification<V>> {
vec![ vec![
NotificationItem::Message(Notification::new_icon_message( Notification::new_icon_message(
"notif-1", "notif-1",
"You were mentioned in a note.", "You were mentioned in a note.",
Icon::AtSign, Icon::AtSign,
Arc::new(|_, _| {}), Arc::new(|_, _| {}),
)), ),
NotificationItem::Message(Notification::new_actor_with_actions( Notification::new_actor_with_actions(
"notif-2", "notif-2",
"as-cii sent you a contact request.", "as-cii sent you a contact request.",
PublicActor::new("as-cii", "http://github.com/as-cii.png?s=50"), PublicActor::new("as-cii", "http://github.com/as-cii.png?s=50"),
@ -352,7 +351,99 @@ pub fn static_new_notification_items_2<V: 'static>() -> Vec<NotificationItem<V>>
(Some(Icon::Check), "Accepted"), (Some(Icon::Check), "Accepted"),
), ),
], ],
)), ),
Notification::new_icon_message(
"notif-3",
"You were mentioned #design.",
Icon::MessageBubbles,
Arc::new(|_, _| {}),
),
Notification::new_actor_with_actions(
"notif-4",
"as-cii sent you a contact request.",
PublicActor::new("as-cii", "http://github.com/as-cii.png?s=50"),
[
NotificationAction::new(
Button::new("Decline"),
"Decline Request",
(Some(Icon::XCircle), "Declined"),
),
NotificationAction::new(
Button::new("Accept").variant(crate::ButtonVariant::Filled),
"Accept Request",
(Some(Icon::Check), "Accepted"),
),
],
),
Notification::new_icon_message(
"notif-5",
"You were mentioned in a note.",
Icon::AtSign,
Arc::new(|_, _| {}),
),
Notification::new_actor_with_actions(
"notif-6",
"as-cii sent you a contact request.",
PublicActor::new("as-cii", "http://github.com/as-cii.png?s=50"),
[
NotificationAction::new(
Button::new("Decline"),
"Decline Request",
(Some(Icon::XCircle), "Declined"),
),
NotificationAction::new(
Button::new("Accept").variant(crate::ButtonVariant::Filled),
"Accept Request",
(Some(Icon::Check), "Accepted"),
),
],
),
Notification::new_icon_message(
"notif-7",
"You were mentioned in a note.",
Icon::AtSign,
Arc::new(|_, _| {}),
),
Notification::new_actor_with_actions(
"notif-8",
"as-cii sent you a contact request.",
PublicActor::new("as-cii", "http://github.com/as-cii.png?s=50"),
[
NotificationAction::new(
Button::new("Decline"),
"Decline Request",
(Some(Icon::XCircle), "Declined"),
),
NotificationAction::new(
Button::new("Accept").variant(crate::ButtonVariant::Filled),
"Accept Request",
(Some(Icon::Check), "Accepted"),
),
],
),
Notification::new_icon_message(
"notif-9",
"You were mentioned in a note.",
Icon::AtSign,
Arc::new(|_, _| {}),
),
Notification::new_actor_with_actions(
"notif-10",
"as-cii sent you a contact request.",
PublicActor::new("as-cii", "http://github.com/as-cii.png?s=50"),
[
NotificationAction::new(
Button::new("Decline"),
"Decline Request",
(Some(Icon::XCircle), "Declined"),
),
NotificationAction::new(
Button::new("Accept").variant(crate::ButtonVariant::Filled),
"Accept Request",
(Some(Icon::Check), "Accepted"),
),
],
),
] ]
} }