Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

Merge branch 'main' into collab-panel2

Conrad Irwin4c27f4453c45
diff --cc crates/collab_ui2/src/collab_panel.rs
index 8c72491295d,6b51d300268..3c3e125108b
--- a/crates/collab_ui2/src/collab_panel.rs
+++ b/crates/collab_ui2/src/collab_panel.rs
@@@ -175,9 -175,10 +175,10 @@@ use gpui::
Point, PromptLevel, Render, RenderOnce, SharedString, Stateful, Styled, Subscription, Task,
View, ViewContext, VisualContext, WeakView,
};
-use project::Fs;
+use project::{Fs, Project};
use serde_derive::{Deserialize, Serialize};
use settings::{Settings, SettingsStore};
+ use ui::prelude::*;
use ui::{
h_stack, v_stack, Avatar, Button, Color, ContextMenu, Icon, IconButton, IconElement, IconSize,
Label, List, ListHeader, ListItem, Tooltip,
@@@ -2548,57 -2560,113 +2551,57 @@@ impl CollabPanel
.w_full()
.justify_between()
.child(Label::new(github_login.clone()))
- .child(
- div()
- .id("remove_contact")
- .invisible()
- .group_hover("", |style| style.visible())
- .child(
- IconButton::new("remove_contact", Icon::Close)
- .icon_color(Color::Muted)
- .tooltip(|cx| Tooltip::text("Remove Contact", cx))
- .on_click(cx.listener(move |this, _, cx| {
- this.remove_contact(user_id, &github_login, cx);
- })),
- ),
- ),
- );
-
- if let Some(avatar) = contact.user.avatar.clone() {
- item = item.left_avatar(avatar);
- }
-
- div().group("").child(item)
- // let event_handler =
- // MouseEventHandler::new::<Contact, _>(contact.user.id as usize, cx, |state, cx| {
- // Flex::row()
- // .with_children(contact.user.avatar.clone().map(|avatar| {
- // let status_badge = if contact.online {
- // Some(
- // Empty::new()
- // .collapsed()
- // .contained()
- // .with_style(if busy {
- // collab_theme.contact_status_busy
- // } else {
- // collab_theme.contact_status_free
- // })
- // .aligned(),
- // )
- // } else {
- // None
- // };
- // Stack::new()
- // .with_child(
- // Image::from_data(avatar)
- // .with_style(collab_theme.contact_avatar)
- // .aligned()
- // .left(),
- // )
- // .with_children(status_badge)
- // }))
-
- // .with_children(if calling {
- // Some(
- // Label::new("Calling", collab_theme.calling_indicator.text.clone())
- // .contained()
- // .with_style(collab_theme.calling_indicator.container)
- // .aligned(),
- // )
- // } else {
- // None
- // })
- // .constrained()
- // .with_height(collab_theme.row_height)
- // .contained()
- // .with_style(
- // *collab_theme
- // .contact_row
- // .in_state(is_selected)
- // .style_for(state),
- // )
- // });
-
- // if online && !busy {
- // let room = ActiveCall::global(cx).read(cx).room();
- // let label = if room.is_some() {
- // format!("Invite {} to join call", contact.user.github_login)
- // } else {
- // format!("Call {}", contact.user.github_login)
- // };
+ .when(calling, |el| {
+ el.child(Label::new("Calling").color(Color::Muted))
+ })
+ .when(!calling, |el| {
+ el.child(
+ div()
+ .id("remove_contact")
+ .invisible()
+ .group_hover("", |style| style.visible())
+ .child(
+ IconButton::new("remove_contact", Icon::Close)
- .color(Color::Muted)
++ .icon_color(Color::Muted)
+ .tooltip(|cx| Tooltip::text("Remove Contact", cx))
+ .on_click(cx.listener({
+ let github_login = github_login.clone();
+ move |this, _, cx| {
+ this.remove_contact(user_id, &github_login, cx);
+ }
+ })),
+ ),
+ )
+ }),
+ )
+ .left_child(
+ // todo!() handle contacts with no avatar
+ Avatar::data(contact.user.avatar.clone().unwrap())
+ .availability_indicator(if online { Some(!busy) } else { None }),
+ )
+ .when(online && !busy, |el| {
+ el.on_click(cx.listener(move |this, _, cx| this.call(user_id, cx)))
+ });
- // event_handler
- // .on_click(MouseButton::Left, move |_, this, cx| {
- // this.call(user_id, Some(initial_project.clone()), cx);
- // })
- // .with_cursor_style(CursorStyle::PointingHand)
- // .with_tooltip::<ContactTooltip>(
- // contact.user.id as usize,
- // label,
- // None,
- // theme.tooltip.clone(),
- // cx,
- // )
- // .into_any()
- // } else {
- // event_handler
- // .with_tooltip::<ContactTooltip>(
- // contact.user.id as usize,
- // format!(
- // "{} is {}",
- // contact.user.github_login,
- // if busy { "on a call" } else { "offline" }
- // ),
- // None,
- // theme.tooltip.clone(),
- // cx,
- // )
- // .into_any()
- // };
+ div()
+ .id(github_login.clone())
+ .group("")
+ .child(item)
+ .tooltip(move |cx| {
+ let text = if !online {
+ format!(" {} is offline", &github_login)
+ } else if busy {
+ format!(" {} is on a call", &github_login)
+ } else {
+ let room = ActiveCall::global(cx).read(cx).room();
+ if room.is_some() {
+ format!("Invite {} to join call", &github_login)
+ } else {
+ format!("Call {}", &github_login)
+ }
+ };
+ Tooltip::text(text, cx)
+ })
}
fn render_contact_request(