Implement Notifications

Co-Authored-By: Marshall Bowers <1486634+maxdeviant@users.noreply.github.com>
This commit is contained in:
Nate Butler 2023-11-01 16:34:42 -04:00
parent 3f74f75dee
commit be3cc6458c
4 changed files with 110 additions and 100 deletions

View file

@ -1,5 +1,6 @@
use std::path::PathBuf;
use std::str::FromStr;
use std::sync::Arc;
use gpui2::{AppContext, ViewContext};
use rand::Rng;
@ -7,12 +8,13 @@ use theme2::ActiveTheme;
use crate::{
Buffer, BufferRow, BufferRows, Button, EditorPane, FileSystemStatus, GitStatus,
HighlightedLine, Icon, Keybinding, Label, LabelColor, ListEntry, ListEntrySize, ListHeaderMeta,
ListItem, ListSubHeader, Livestream, MicStatus, ModifierKeys, NotificationItem, PaletteItem,
Player, PlayerCallStatus, PlayerWithCallStatus, ScreenShareStatus, Symbol, Tab, ToggleState,
VideoStatus,
HighlightedLine, Icon, Keybinding, Label, LabelColor, ListEntry, ListEntrySize, ListSubHeader,
Livestream, MicStatus, ModifierKeys, Notification, NotificationItem, PaletteItem, Player,
PlayerCallStatus, PlayerWithCallStatus, PublicActor, ScreenShareStatus, Symbol, Tab,
ToggleState, VideoStatus,
};
use crate::{HighlightedText, ListDetailsEntry};
use crate::{ListItem, NotificationAction};
pub fn static_tabs_example() -> Vec<Tab> {
vec![
@ -327,8 +329,33 @@ pub fn static_players_with_call_status() -> Vec<PlayerWithCallStatus> {
}
pub fn static_new_notification_items_2<V: 'static>() -> Vec<NotificationItem<V>> {
vec![]
vec![
NotificationItem::Message(Notification::new_icon_message(
"notif-1",
"You were mentioned in a note.",
Icon::AtSign,
Arc::new(|_, _| {}),
)),
NotificationItem::Message(Notification::new_actor_with_actions(
"notif-2",
"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"),
),
],
)),
]
}
pub fn static_new_notification_items<V: 'static>() -> Vec<ListItem<V>> {
vec![
ListItem::Header(ListSubHeader::new("New")),