Merge branch 'main' into guest-promotion
This commit is contained in:
commit
276bfa0fab
121 changed files with 1649 additions and 904 deletions
|
@ -20,7 +20,7 @@ use serde::{Deserialize, Serialize};
|
|||
use settings::{Settings, SettingsStore};
|
||||
use std::sync::Arc;
|
||||
use time::{OffsetDateTime, UtcOffset};
|
||||
use ui::{prelude::*, Avatar, Button, Icon, IconButton, Label, TabBar, Tooltip};
|
||||
use ui::{prelude::*, Avatar, Button, IconButton, IconName, Label, TabBar, Tooltip};
|
||||
use util::{ResultExt, TryFutureExt};
|
||||
use workspace::{
|
||||
dock::{DockPosition, Panel, PanelEvent},
|
||||
|
@ -281,12 +281,12 @@ impl ChatPanel {
|
|||
)),
|
||||
)
|
||||
.end_child(
|
||||
IconButton::new("notes", Icon::File)
|
||||
IconButton::new("notes", IconName::File)
|
||||
.on_click(cx.listener(Self::open_notes))
|
||||
.tooltip(|cx| Tooltip::text("Open notes", cx)),
|
||||
)
|
||||
.end_child(
|
||||
IconButton::new("call", Icon::AudioOn)
|
||||
IconButton::new("call", IconName::AudioOn)
|
||||
.on_click(cx.listener(Self::join_call))
|
||||
.tooltip(|cx| Tooltip::text("Join call", cx)),
|
||||
),
|
||||
|
@ -395,7 +395,7 @@ impl ChatPanel {
|
|||
.w_8()
|
||||
.visible_on_hover("")
|
||||
.children(message_id_to_remove.map(|message_id| {
|
||||
IconButton::new(("remove", message_id), Icon::XCircle).on_click(
|
||||
IconButton::new(("remove", message_id), IconName::XCircle).on_click(
|
||||
cx.listener(move |this, _, cx| {
|
||||
this.remove_message(message_id, cx);
|
||||
}),
|
||||
|
@ -429,7 +429,7 @@ impl ChatPanel {
|
|||
Button::new("sign-in", "Sign in")
|
||||
.style(ButtonStyle::Filled)
|
||||
.icon_color(Color::Muted)
|
||||
.icon(Icon::Github)
|
||||
.icon(IconName::Github)
|
||||
.icon_position(IconPosition::Start)
|
||||
.full_width()
|
||||
.on_click(cx.listener(move |this, _, cx| {
|
||||
|
@ -622,12 +622,12 @@ impl Panel for ChatPanel {
|
|||
"ChatPanel"
|
||||
}
|
||||
|
||||
fn icon(&self, cx: &WindowContext) -> Option<ui::Icon> {
|
||||
fn icon(&self, cx: &WindowContext) -> Option<ui::IconName> {
|
||||
if !is_channels_feature_enabled(cx) {
|
||||
return None;
|
||||
}
|
||||
|
||||
Some(ui::Icon::MessageBubbles).filter(|_| ChatPanelSettings::get_global(cx).button)
|
||||
Some(ui::IconName::MessageBubbles).filter(|_| ChatPanelSettings::get_global(cx).button)
|
||||
}
|
||||
|
||||
fn icon_tooltip(&self, _cx: &WindowContext) -> Option<&'static str> {
|
||||
|
|
|
@ -31,7 +31,7 @@ use smallvec::SmallVec;
|
|||
use std::{mem, sync::Arc};
|
||||
use theme::{ActiveTheme, ThemeSettings};
|
||||
use ui::{
|
||||
prelude::*, Avatar, Button, Color, ContextMenu, Icon, IconButton, IconElement, IconSize, Label,
|
||||
prelude::*, Avatar, Button, Color, ContextMenu, Icon, IconButton, IconName, IconSize, Label,
|
||||
ListHeader, ListItem, Tooltip,
|
||||
};
|
||||
use util::{maybe, ResultExt, TryFutureExt};
|
||||
|
@ -844,7 +844,7 @@ impl CollabPanel {
|
|||
.end_slot(if is_pending {
|
||||
Label::new("Calling").color(Color::Muted).into_any_element()
|
||||
} else if is_current_user {
|
||||
IconButton::new("leave-call", Icon::Exit)
|
||||
IconButton::new("leave-call", IconName::Exit)
|
||||
.style(ButtonStyle::Subtle)
|
||||
.on_click(move |_, cx| Self::leave_call(cx))
|
||||
.tooltip(|cx| Tooltip::text("Leave Call", cx))
|
||||
|
@ -903,7 +903,7 @@ impl CollabPanel {
|
|||
h_stack()
|
||||
.gap_1()
|
||||
.child(render_tree_branch(is_last, false, cx))
|
||||
.child(IconButton::new(0, Icon::Folder)),
|
||||
.child(IconButton::new(0, IconName::Folder)),
|
||||
)
|
||||
.child(Label::new(project_name.clone()))
|
||||
.tooltip(move |cx| Tooltip::text(format!("Open {}", project_name), cx))
|
||||
|
@ -924,7 +924,7 @@ impl CollabPanel {
|
|||
h_stack()
|
||||
.gap_1()
|
||||
.child(render_tree_branch(is_last, false, cx))
|
||||
.child(IconButton::new(0, Icon::Screen)),
|
||||
.child(IconButton::new(0, IconName::Screen)),
|
||||
)
|
||||
.child(Label::new("Screen"))
|
||||
.when_some(peer_id, |this, _| {
|
||||
|
@ -965,7 +965,7 @@ impl CollabPanel {
|
|||
h_stack()
|
||||
.gap_1()
|
||||
.child(render_tree_branch(false, true, cx))
|
||||
.child(IconButton::new(0, Icon::File)),
|
||||
.child(IconButton::new(0, IconName::File)),
|
||||
)
|
||||
.child(div().h_7().w_full().child(Label::new("notes")))
|
||||
.tooltip(move |cx| Tooltip::text("Open Channel Notes", cx))
|
||||
|
@ -986,7 +986,7 @@ impl CollabPanel {
|
|||
h_stack()
|
||||
.gap_1()
|
||||
.child(render_tree_branch(false, false, cx))
|
||||
.child(IconButton::new(0, Icon::MessageBubbles)),
|
||||
.child(IconButton::new(0, IconName::MessageBubbles)),
|
||||
)
|
||||
.child(Label::new("chat"))
|
||||
.tooltip(move |cx| Tooltip::text("Open Chat", cx))
|
||||
|
@ -1757,7 +1757,7 @@ impl CollabPanel {
|
|||
.child(
|
||||
Button::new("sign_in", "Sign in")
|
||||
.icon_color(Color::Muted)
|
||||
.icon(Icon::Github)
|
||||
.icon(IconName::Github)
|
||||
.icon_position(IconPosition::Start)
|
||||
.style(ButtonStyle::Filled)
|
||||
.full_width()
|
||||
|
@ -1949,7 +1949,7 @@ impl CollabPanel {
|
|||
let button = match section {
|
||||
Section::ActiveCall => channel_link.map(|channel_link| {
|
||||
let channel_link_copy = channel_link.clone();
|
||||
IconButton::new("channel-link", Icon::Copy)
|
||||
IconButton::new("channel-link", IconName::Copy)
|
||||
.icon_size(IconSize::Small)
|
||||
.size(ButtonSize::None)
|
||||
.visible_on_hover("section-header")
|
||||
|
@ -1961,13 +1961,13 @@ impl CollabPanel {
|
|||
.into_any_element()
|
||||
}),
|
||||
Section::Contacts => Some(
|
||||
IconButton::new("add-contact", Icon::Plus)
|
||||
IconButton::new("add-contact", IconName::Plus)
|
||||
.on_click(cx.listener(|this, _, cx| this.toggle_contact_finder(cx)))
|
||||
.tooltip(|cx| Tooltip::text("Search for new contact", cx))
|
||||
.into_any_element(),
|
||||
),
|
||||
Section::Channels => Some(
|
||||
IconButton::new("add-channel", Icon::Plus)
|
||||
IconButton::new("add-channel", IconName::Plus)
|
||||
.on_click(cx.listener(|this, _, cx| this.new_root_channel(cx)))
|
||||
.tooltip(|cx| Tooltip::text("Create a channel", cx))
|
||||
.into_any_element(),
|
||||
|
@ -2038,7 +2038,7 @@ impl CollabPanel {
|
|||
})
|
||||
.when(!calling, |el| {
|
||||
el.child(
|
||||
IconButton::new("remove_contact", Icon::Close)
|
||||
IconButton::new("remove_contact", IconName::Close)
|
||||
.icon_color(Color::Muted)
|
||||
.visible_on_hover("")
|
||||
.tooltip(|cx| Tooltip::text("Remove Contact", cx))
|
||||
|
@ -2099,13 +2099,13 @@ impl CollabPanel {
|
|||
|
||||
let controls = if is_incoming {
|
||||
vec![
|
||||
IconButton::new("decline-contact", Icon::Close)
|
||||
IconButton::new("decline-contact", IconName::Close)
|
||||
.on_click(cx.listener(move |this, _, cx| {
|
||||
this.respond_to_contact_request(user_id, false, cx);
|
||||
}))
|
||||
.icon_color(color)
|
||||
.tooltip(|cx| Tooltip::text("Decline invite", cx)),
|
||||
IconButton::new("accept-contact", Icon::Check)
|
||||
IconButton::new("accept-contact", IconName::Check)
|
||||
.on_click(cx.listener(move |this, _, cx| {
|
||||
this.respond_to_contact_request(user_id, true, cx);
|
||||
}))
|
||||
|
@ -2114,7 +2114,7 @@ impl CollabPanel {
|
|||
]
|
||||
} else {
|
||||
let github_login = github_login.clone();
|
||||
vec![IconButton::new("remove_contact", Icon::Close)
|
||||
vec![IconButton::new("remove_contact", IconName::Close)
|
||||
.on_click(cx.listener(move |this, _, cx| {
|
||||
this.remove_contact(user_id, &github_login, cx);
|
||||
}))
|
||||
|
@ -2154,13 +2154,13 @@ impl CollabPanel {
|
|||
};
|
||||
|
||||
let controls = [
|
||||
IconButton::new("reject-invite", Icon::Close)
|
||||
IconButton::new("reject-invite", IconName::Close)
|
||||
.on_click(cx.listener(move |this, _, cx| {
|
||||
this.respond_to_channel_invite(channel_id, false, cx);
|
||||
}))
|
||||
.icon_color(color)
|
||||
.tooltip(|cx| Tooltip::text("Decline invite", cx)),
|
||||
IconButton::new("accept-invite", Icon::Check)
|
||||
IconButton::new("accept-invite", IconName::Check)
|
||||
.on_click(cx.listener(move |this, _, cx| {
|
||||
this.respond_to_channel_invite(channel_id, true, cx);
|
||||
}))
|
||||
|
@ -2178,7 +2178,7 @@ impl CollabPanel {
|
|||
.child(h_stack().children(controls)),
|
||||
)
|
||||
.start_slot(
|
||||
IconElement::new(Icon::Hash)
|
||||
Icon::new(IconName::Hash)
|
||||
.size(IconSize::Small)
|
||||
.color(Color::Muted),
|
||||
)
|
||||
|
@ -2190,7 +2190,7 @@ impl CollabPanel {
|
|||
cx: &mut ViewContext<Self>,
|
||||
) -> ListItem {
|
||||
ListItem::new("contact-placeholder")
|
||||
.child(IconElement::new(Icon::Plus))
|
||||
.child(Icon::new(IconName::Plus))
|
||||
.child(Label::new("Add a Contact"))
|
||||
.selected(is_selected)
|
||||
.on_click(cx.listener(|this, _, cx| this.toggle_contact_finder(cx)))
|
||||
|
@ -2274,7 +2274,7 @@ impl CollabPanel {
|
|||
};
|
||||
|
||||
let messages_button = |cx: &mut ViewContext<Self>| {
|
||||
IconButton::new("channel_chat", Icon::MessageBubbles)
|
||||
IconButton::new("channel_chat", IconName::MessageBubbles)
|
||||
.icon_size(IconSize::Small)
|
||||
.icon_color(if has_messages_notification {
|
||||
Color::Default
|
||||
|
@ -2286,7 +2286,7 @@ impl CollabPanel {
|
|||
};
|
||||
|
||||
let notes_button = |cx: &mut ViewContext<Self>| {
|
||||
IconButton::new("channel_notes", Icon::File)
|
||||
IconButton::new("channel_notes", IconName::File)
|
||||
.icon_size(IconSize::Small)
|
||||
.icon_color(if has_notes_notification {
|
||||
Color::Default
|
||||
|
@ -2343,9 +2343,13 @@ impl CollabPanel {
|
|||
},
|
||||
))
|
||||
.start_slot(
|
||||
IconElement::new(if is_public { Icon::Public } else { Icon::Hash })
|
||||
.size(IconSize::Small)
|
||||
.color(Color::Muted),
|
||||
Icon::new(if is_public {
|
||||
IconName::Public
|
||||
} else {
|
||||
IconName::Hash
|
||||
})
|
||||
.size(IconSize::Small)
|
||||
.color(Color::Muted),
|
||||
)
|
||||
.child(
|
||||
h_stack()
|
||||
|
@ -2414,7 +2418,7 @@ impl CollabPanel {
|
|||
.indent_level(depth + 1)
|
||||
.indent_step_size(px(20.))
|
||||
.start_slot(
|
||||
IconElement::new(Icon::Hash)
|
||||
Icon::new(IconName::Hash)
|
||||
.size(IconSize::Small)
|
||||
.color(Color::Muted),
|
||||
);
|
||||
|
@ -2528,10 +2532,10 @@ impl Panel for CollabPanel {
|
|||
cx.notify();
|
||||
}
|
||||
|
||||
fn icon(&self, cx: &gpui::WindowContext) -> Option<ui::Icon> {
|
||||
fn icon(&self, cx: &gpui::WindowContext) -> Option<ui::IconName> {
|
||||
CollaborationPanelSettings::get_global(cx)
|
||||
.button
|
||||
.then(|| ui::Icon::Collab)
|
||||
.then(|| ui::IconName::Collab)
|
||||
}
|
||||
|
||||
fn icon_tooltip(&self, _cx: &WindowContext) -> Option<&'static str> {
|
||||
|
@ -2669,11 +2673,11 @@ impl Render for DraggedChannelView {
|
|||
.p_1()
|
||||
.gap_1()
|
||||
.child(
|
||||
IconElement::new(
|
||||
Icon::new(
|
||||
if self.channel.visibility == proto::ChannelVisibility::Public {
|
||||
Icon::Public
|
||||
IconName::Public
|
||||
} else {
|
||||
Icon::Hash
|
||||
IconName::Hash
|
||||
},
|
||||
)
|
||||
.size(IconSize::Small)
|
||||
|
|
|
@ -168,7 +168,7 @@ impl Render for ChannelModal {
|
|||
.w_px()
|
||||
.flex_1()
|
||||
.gap_1()
|
||||
.child(IconElement::new(Icon::Hash).size(IconSize::Medium))
|
||||
.child(Icon::new(IconName::Hash).size(IconSize::Medium))
|
||||
.child(Label::new(channel_name)),
|
||||
)
|
||||
.child(
|
||||
|
@ -406,7 +406,7 @@ impl PickerDelegate for ChannelModalDelegate {
|
|||
Some(ChannelRole::Guest) => Some(Label::new("Guest")),
|
||||
_ => None,
|
||||
})
|
||||
.child(IconButton::new("ellipsis", Icon::Ellipsis))
|
||||
.child(IconButton::new("ellipsis", IconName::Ellipsis))
|
||||
.children(
|
||||
if let (Some((menu, _)), true) = (&self.context_menu, selected) {
|
||||
Some(
|
||||
|
|
|
@ -155,9 +155,7 @@ impl PickerDelegate for ContactFinderDelegate {
|
|||
.selected(selected)
|
||||
.start_slot(Avatar::new(user.avatar_uri.clone()))
|
||||
.child(Label::new(user.github_login.clone()))
|
||||
.end_slot::<IconElement>(
|
||||
icon_path.map(|icon_path| IconElement::from_path(icon_path)),
|
||||
),
|
||||
.end_slot::<Icon>(icon_path.map(|icon_path| Icon::from_path(icon_path))),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ use std::sync::Arc;
|
|||
use theme::{ActiveTheme, PlayerColors};
|
||||
use ui::{
|
||||
h_stack, popover_menu, prelude::*, Avatar, Button, ButtonLike, ButtonStyle, ContextMenu, Icon,
|
||||
IconButton, IconElement, TintColor, Tooltip,
|
||||
IconButton, IconName, TintColor, Tooltip,
|
||||
};
|
||||
use util::ResultExt;
|
||||
use vcs_menu::{build_branch_list, BranchList, OpenRecent as ToggleVcsMenu};
|
||||
|
@ -213,7 +213,7 @@ impl Render for CollabTitlebarItem {
|
|||
.child(
|
||||
div()
|
||||
.child(
|
||||
IconButton::new("leave-call", ui::Icon::Exit)
|
||||
IconButton::new("leave-call", ui::IconName::Exit)
|
||||
.style(ButtonStyle::Subtle)
|
||||
.tooltip(|cx| Tooltip::text("Leave call", cx))
|
||||
.icon_size(IconSize::Small)
|
||||
|
@ -230,9 +230,9 @@ impl Render for CollabTitlebarItem {
|
|||
IconButton::new(
|
||||
"mute-microphone",
|
||||
if is_muted {
|
||||
ui::Icon::MicMute
|
||||
ui::IconName::MicMute
|
||||
} else {
|
||||
ui::Icon::Mic
|
||||
ui::IconName::Mic
|
||||
},
|
||||
)
|
||||
.tooltip(move |cx| {
|
||||
|
@ -256,9 +256,9 @@ impl Render for CollabTitlebarItem {
|
|||
IconButton::new(
|
||||
"mute-sound",
|
||||
if is_deafened {
|
||||
ui::Icon::AudioOff
|
||||
ui::IconName::AudioOff
|
||||
} else {
|
||||
ui::Icon::AudioOn
|
||||
ui::IconName::AudioOn
|
||||
},
|
||||
)
|
||||
.style(ButtonStyle::Subtle)
|
||||
|
@ -281,7 +281,7 @@ impl Render for CollabTitlebarItem {
|
|||
)
|
||||
.when(!read_only, |this| {
|
||||
this.child(
|
||||
IconButton::new("screen-share", ui::Icon::Screen)
|
||||
IconButton::new("screen-share", ui::IconName::Screen)
|
||||
.style(ButtonStyle::Subtle)
|
||||
.icon_size(IconSize::Small)
|
||||
.selected(is_screen_sharing)
|
||||
|
@ -573,7 +573,7 @@ impl CollabTitlebarItem {
|
|||
| client::Status::ReconnectionError { .. } => Some(
|
||||
div()
|
||||
.id("disconnected")
|
||||
.child(IconElement::new(Icon::Disconnected).size(IconSize::Small))
|
||||
.child(Icon::new(IconName::Disconnected).size(IconSize::Small))
|
||||
.tooltip(|cx| Tooltip::text("Disconnected", cx))
|
||||
.into_any_element(),
|
||||
),
|
||||
|
@ -643,7 +643,7 @@ impl CollabTitlebarItem {
|
|||
h_stack()
|
||||
.gap_0p5()
|
||||
.child(Avatar::new(user.avatar_uri.clone()))
|
||||
.child(IconElement::new(Icon::ChevronDown).color(Color::Muted)),
|
||||
.child(Icon::new(IconName::ChevronDown).color(Color::Muted)),
|
||||
)
|
||||
.style(ButtonStyle::Subtle)
|
||||
.tooltip(move |cx| Tooltip::text("Toggle User Menu", cx)),
|
||||
|
@ -665,7 +665,7 @@ impl CollabTitlebarItem {
|
|||
.child(
|
||||
h_stack()
|
||||
.gap_0p5()
|
||||
.child(IconElement::new(Icon::ChevronDown).color(Color::Muted)),
|
||||
.child(Icon::new(IconName::ChevronDown).color(Color::Muted)),
|
||||
)
|
||||
.style(ButtonStyle::Subtle)
|
||||
.tooltip(move |cx| Tooltip::text("Toggle User Menu", cx)),
|
||||
|
|
|
@ -19,7 +19,7 @@ use serde::{Deserialize, Serialize};
|
|||
use settings::{Settings, SettingsStore};
|
||||
use std::{sync::Arc, time::Duration};
|
||||
use time::{OffsetDateTime, UtcOffset};
|
||||
use ui::{h_stack, prelude::*, v_stack, Avatar, Button, Icon, IconButton, IconElement, Label};
|
||||
use ui::{h_stack, prelude::*, v_stack, Avatar, Button, Icon, IconButton, IconName, Label};
|
||||
use util::{ResultExt, TryFutureExt};
|
||||
use workspace::{
|
||||
dock::{DockPosition, Panel, PanelEvent},
|
||||
|
@ -553,7 +553,7 @@ impl Render for NotificationPanel {
|
|||
.border_b_1()
|
||||
.border_color(cx.theme().colors().border)
|
||||
.child(Label::new("Notifications"))
|
||||
.child(IconElement::new(Icon::Envelope)),
|
||||
.child(Icon::new(IconName::Envelope)),
|
||||
)
|
||||
.map(|this| {
|
||||
if self.client.user_id().is_none() {
|
||||
|
@ -564,7 +564,7 @@ impl Render for NotificationPanel {
|
|||
.child(
|
||||
Button::new("sign_in_prompt_button", "Sign in")
|
||||
.icon_color(Color::Muted)
|
||||
.icon(Icon::Github)
|
||||
.icon(IconName::Github)
|
||||
.icon_position(IconPosition::Start)
|
||||
.style(ButtonStyle::Filled)
|
||||
.full_width()
|
||||
|
@ -655,10 +655,10 @@ impl Panel for NotificationPanel {
|
|||
}
|
||||
}
|
||||
|
||||
fn icon(&self, cx: &gpui::WindowContext) -> Option<Icon> {
|
||||
fn icon(&self, cx: &gpui::WindowContext) -> Option<IconName> {
|
||||
(NotificationPanelSettings::get_global(cx).button
|
||||
&& self.notification_store.read(cx).notification_count() > 0)
|
||||
.then(|| Icon::Bell)
|
||||
.then(|| IconName::Bell)
|
||||
}
|
||||
|
||||
fn icon_tooltip(&self, _cx: &WindowContext) -> Option<&'static str> {
|
||||
|
@ -716,7 +716,7 @@ impl Render for NotificationToast {
|
|||
.children(user.map(|user| Avatar::new(user.avatar_uri.clone())))
|
||||
.child(Label::new(self.text.clone()))
|
||||
.child(
|
||||
IconButton::new("close", Icon::Close)
|
||||
IconButton::new("close", IconName::Close)
|
||||
.on_click(cx.listener(|_, _, cx| cx.emit(DismissEvent))),
|
||||
)
|
||||
.on_click(cx.listener(|this, _, cx| {
|
||||
|
|
|
@ -1,9 +1,16 @@
|
|||
mod collab_notification;
|
||||
pub mod incoming_call_notification;
|
||||
pub mod project_shared_notification;
|
||||
|
||||
#[cfg(feature = "stories")]
|
||||
mod stories;
|
||||
|
||||
use gpui::AppContext;
|
||||
use std::sync::Arc;
|
||||
use workspace::AppState;
|
||||
|
||||
pub mod incoming_call_notification;
|
||||
pub mod project_shared_notification;
|
||||
#[cfg(feature = "stories")]
|
||||
pub use stories::*;
|
||||
|
||||
pub fn init(app_state: &Arc<AppState>, cx: &mut AppContext) {
|
||||
incoming_call_notification::init(app_state, cx);
|
||||
|
|
52
crates/collab_ui/src/notifications/collab_notification.rs
Normal file
52
crates/collab_ui/src/notifications/collab_notification.rs
Normal file
|
@ -0,0 +1,52 @@
|
|||
use gpui::{img, prelude::*, AnyElement, SharedUrl};
|
||||
use smallvec::SmallVec;
|
||||
use ui::prelude::*;
|
||||
|
||||
#[derive(IntoElement)]
|
||||
pub struct CollabNotification {
|
||||
avatar_uri: SharedUrl,
|
||||
accept_button: Button,
|
||||
dismiss_button: Button,
|
||||
children: SmallVec<[AnyElement; 2]>,
|
||||
}
|
||||
|
||||
impl CollabNotification {
|
||||
pub fn new(
|
||||
avatar_uri: impl Into<SharedUrl>,
|
||||
accept_button: Button,
|
||||
dismiss_button: Button,
|
||||
) -> Self {
|
||||
Self {
|
||||
avatar_uri: avatar_uri.into(),
|
||||
accept_button,
|
||||
dismiss_button,
|
||||
children: SmallVec::new(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl ParentElement for CollabNotification {
|
||||
fn children_mut(&mut self) -> &mut SmallVec<[AnyElement; 2]> {
|
||||
&mut self.children
|
||||
}
|
||||
}
|
||||
|
||||
impl RenderOnce for CollabNotification {
|
||||
fn render(self, cx: &mut WindowContext) -> impl IntoElement {
|
||||
h_stack()
|
||||
.text_ui()
|
||||
.justify_between()
|
||||
.size_full()
|
||||
.overflow_hidden()
|
||||
.elevation_3(cx)
|
||||
.p_2()
|
||||
.gap_2()
|
||||
.child(img(self.avatar_uri).w_12().h_12().rounded_full())
|
||||
.child(v_stack().overflow_hidden().children(self.children))
|
||||
.child(
|
||||
v_stack()
|
||||
.child(self.accept_button)
|
||||
.child(self.dismiss_button),
|
||||
)
|
||||
}
|
||||
}
|
|
@ -1,15 +1,12 @@
|
|||
use crate::notification_window_options;
|
||||
use crate::notifications::collab_notification::CollabNotification;
|
||||
use call::{ActiveCall, IncomingCall};
|
||||
use futures::StreamExt;
|
||||
use gpui::{
|
||||
img, px, AppContext, ParentElement, Render, RenderOnce, Styled, ViewContext,
|
||||
VisualContext as _, WindowHandle,
|
||||
};
|
||||
use gpui::{prelude::*, AppContext, WindowHandle};
|
||||
use settings::Settings;
|
||||
use std::sync::{Arc, Weak};
|
||||
use theme::ThemeSettings;
|
||||
use ui::prelude::*;
|
||||
use ui::{h_stack, v_stack, Button, Label};
|
||||
use ui::{prelude::*, Button, Label};
|
||||
use util::ResultExt;
|
||||
use workspace::AppState;
|
||||
|
||||
|
@ -31,8 +28,8 @@ pub fn init(app_state: &Arc<AppState>, cx: &mut AppContext) {
|
|||
if let Some(incoming_call) = incoming_call {
|
||||
let unique_screens = cx.update(|cx| cx.displays()).unwrap();
|
||||
let window_size = gpui::Size {
|
||||
width: px(380.),
|
||||
height: px(64.),
|
||||
width: px(400.),
|
||||
height: px(72.),
|
||||
};
|
||||
|
||||
for screen in unique_screens {
|
||||
|
@ -129,35 +126,22 @@ impl Render for IncomingCallNotification {
|
|||
|
||||
cx.set_rem_size(ui_font_size);
|
||||
|
||||
h_stack()
|
||||
.font(ui_font)
|
||||
.text_ui()
|
||||
.justify_between()
|
||||
.size_full()
|
||||
.overflow_hidden()
|
||||
.elevation_3(cx)
|
||||
.p_2()
|
||||
.gap_2()
|
||||
.child(
|
||||
img(self.state.call.calling_user.avatar_uri.clone())
|
||||
.w_12()
|
||||
.h_12()
|
||||
.rounded_full(),
|
||||
div().size_full().font(ui_font).child(
|
||||
CollabNotification::new(
|
||||
self.state.call.calling_user.avatar_uri.clone(),
|
||||
Button::new("accept", "Accept").on_click({
|
||||
let state = self.state.clone();
|
||||
move |_, cx| state.respond(true, cx)
|
||||
}),
|
||||
Button::new("decline", "Decline").on_click({
|
||||
let state = self.state.clone();
|
||||
move |_, cx| state.respond(false, cx)
|
||||
}),
|
||||
)
|
||||
.child(v_stack().overflow_hidden().child(Label::new(format!(
|
||||
"{} is sharing a project in Zed",
|
||||
self.state.call.calling_user.github_login
|
||||
))))
|
||||
.child(
|
||||
v_stack()
|
||||
.child(Button::new("accept", "Accept").render(cx).on_click({
|
||||
let state = self.state.clone();
|
||||
move |_, cx| state.respond(true, cx)
|
||||
}))
|
||||
.child(Button::new("decline", "Decline").render(cx).on_click({
|
||||
let state = self.state.clone();
|
||||
move |_, cx| state.respond(false, cx)
|
||||
})),
|
||||
)
|
||||
)))),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
use crate::notification_window_options;
|
||||
use crate::notifications::collab_notification::CollabNotification;
|
||||
use call::{room, ActiveCall};
|
||||
use client::User;
|
||||
use collections::HashMap;
|
||||
use gpui::{img, px, AppContext, ParentElement, Render, Size, Styled, ViewContext, VisualContext};
|
||||
use gpui::{AppContext, Size};
|
||||
use settings::Settings;
|
||||
use std::sync::{Arc, Weak};
|
||||
use theme::ThemeSettings;
|
||||
use ui::{h_stack, prelude::*, v_stack, Button, Label};
|
||||
use ui::{prelude::*, Button, Label};
|
||||
use workspace::AppState;
|
||||
|
||||
pub fn init(app_state: &Arc<AppState>, cx: &mut AppContext) {
|
||||
|
@ -130,51 +131,30 @@ impl Render for ProjectSharedNotification {
|
|||
|
||||
cx.set_rem_size(ui_font_size);
|
||||
|
||||
h_stack()
|
||||
.font(ui_font)
|
||||
.text_ui()
|
||||
.justify_between()
|
||||
.size_full()
|
||||
.overflow_hidden()
|
||||
.elevation_3(cx)
|
||||
.p_2()
|
||||
.gap_2()
|
||||
.child(
|
||||
img(self.owner.avatar_uri.clone())
|
||||
.w_12()
|
||||
.h_12()
|
||||
.rounded_full(),
|
||||
)
|
||||
.child(
|
||||
v_stack()
|
||||
.overflow_hidden()
|
||||
.child(Label::new(self.owner.github_login.clone()))
|
||||
.child(Label::new(format!(
|
||||
"is sharing a project in Zed{}",
|
||||
if self.worktree_root_names.is_empty() {
|
||||
""
|
||||
} else {
|
||||
":"
|
||||
}
|
||||
)))
|
||||
.children(if self.worktree_root_names.is_empty() {
|
||||
None
|
||||
} else {
|
||||
Some(Label::new(self.worktree_root_names.join(", ")))
|
||||
}),
|
||||
)
|
||||
.child(
|
||||
v_stack()
|
||||
.child(Button::new("open", "Open").on_click(cx.listener(
|
||||
move |this, _event, cx| {
|
||||
this.join(cx);
|
||||
},
|
||||
)))
|
||||
.child(Button::new("dismiss", "Dismiss").on_click(cx.listener(
|
||||
move |this, _event, cx| {
|
||||
this.dismiss(cx);
|
||||
},
|
||||
))),
|
||||
div().size_full().font(ui_font).child(
|
||||
CollabNotification::new(
|
||||
self.owner.avatar_uri.clone(),
|
||||
Button::new("open", "Open").on_click(cx.listener(move |this, _event, cx| {
|
||||
this.join(cx);
|
||||
})),
|
||||
Button::new("dismiss", "Dismiss").on_click(cx.listener(move |this, _event, cx| {
|
||||
this.dismiss(cx);
|
||||
})),
|
||||
)
|
||||
.child(Label::new(self.owner.github_login.clone()))
|
||||
.child(Label::new(format!(
|
||||
"is sharing a project in Zed{}",
|
||||
if self.worktree_root_names.is_empty() {
|
||||
""
|
||||
} else {
|
||||
":"
|
||||
}
|
||||
)))
|
||||
.children(if self.worktree_root_names.is_empty() {
|
||||
None
|
||||
} else {
|
||||
Some(Label::new(self.worktree_root_names.join(", ")))
|
||||
}),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
3
crates/collab_ui/src/notifications/stories.rs
Normal file
3
crates/collab_ui/src/notifications/stories.rs
Normal file
|
@ -0,0 +1,3 @@
|
|||
mod collab_notification;
|
||||
|
||||
pub use collab_notification::*;
|
|
@ -0,0 +1,50 @@
|
|||
use gpui::prelude::*;
|
||||
use story::{StoryContainer, StoryItem, StorySection};
|
||||
use ui::prelude::*;
|
||||
|
||||
use crate::notifications::collab_notification::CollabNotification;
|
||||
|
||||
pub struct CollabNotificationStory;
|
||||
|
||||
impl Render for CollabNotificationStory {
|
||||
fn render(&mut self, _cx: &mut ViewContext<Self>) -> impl IntoElement {
|
||||
let window_container = |width, height| div().w(px(width)).h(px(height));
|
||||
|
||||
StoryContainer::new(
|
||||
"CollabNotification Story",
|
||||
"crates/collab_ui/src/notifications/stories/collab_notification.rs",
|
||||
)
|
||||
.child(
|
||||
StorySection::new().child(StoryItem::new(
|
||||
"Incoming Call Notification",
|
||||
window_container(400., 72.).child(
|
||||
CollabNotification::new(
|
||||
"https://avatars.githubusercontent.com/u/1486634?v=4",
|
||||
Button::new("accept", "Accept"),
|
||||
Button::new("decline", "Decline"),
|
||||
)
|
||||
.child(
|
||||
v_stack()
|
||||
.overflow_hidden()
|
||||
.child(Label::new("maxdeviant is sharing a project in Zed")),
|
||||
),
|
||||
),
|
||||
)),
|
||||
)
|
||||
.child(
|
||||
StorySection::new().child(StoryItem::new(
|
||||
"Project Shared Notification",
|
||||
window_container(400., 72.).child(
|
||||
CollabNotification::new(
|
||||
"https://avatars.githubusercontent.com/u/1714999?v=4",
|
||||
Button::new("open", "Open"),
|
||||
Button::new("dismiss", "Dismiss"),
|
||||
)
|
||||
.child(Label::new("iamnbutler"))
|
||||
.child(Label::new("is sharing a project in Zed:"))
|
||||
.child(Label::new("zed")),
|
||||
),
|
||||
)),
|
||||
)
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue