mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-27 12:54:42 +00:00
Always show invite link in contacts popover
This commit is contained in:
parent
f83de0a91c
commit
ba6c5441c0
5 changed files with 71 additions and 68 deletions
|
@ -8,9 +8,8 @@ use fuzzy::{match_strings, StringMatchCandidate};
|
|||
use gpui::{
|
||||
elements::*,
|
||||
geometry::{rect::RectF, vector::vec2f},
|
||||
impl_actions, impl_internal_actions, keymap, AppContext, ClipboardItem, CursorStyle, Entity,
|
||||
ModelHandle, MouseButton, MutableAppContext, RenderContext, Subscription, View, ViewContext,
|
||||
ViewHandle,
|
||||
impl_actions, impl_internal_actions, keymap, AppContext, CursorStyle, Entity, ModelHandle,
|
||||
MouseButton, MutableAppContext, RenderContext, Subscription, View, ViewContext, ViewHandle,
|
||||
};
|
||||
use menu::{Confirm, SelectNext, SelectPrev};
|
||||
use project::Project;
|
||||
|
@ -1104,55 +1103,6 @@ impl View for ContactList {
|
|||
.boxed(),
|
||||
)
|
||||
.with_child(List::new(self.list_state.clone()).flex(1., false).boxed())
|
||||
.with_children(
|
||||
self.user_store
|
||||
.read(cx)
|
||||
.invite_info()
|
||||
.cloned()
|
||||
.and_then(|info| {
|
||||
enum InviteLink {}
|
||||
|
||||
if info.count > 0 {
|
||||
Some(
|
||||
MouseEventHandler::<InviteLink>::new(0, cx, |state, cx| {
|
||||
let style = theme
|
||||
.contact_list
|
||||
.invite_row
|
||||
.style_for(state, false)
|
||||
.clone();
|
||||
|
||||
let copied = cx.read_from_clipboard().map_or(false, |item| {
|
||||
item.text().as_str() == info.url.as_ref()
|
||||
});
|
||||
|
||||
Label::new(
|
||||
format!(
|
||||
"{} invite link ({} left)",
|
||||
if copied { "Copied" } else { "Copy" },
|
||||
info.count
|
||||
),
|
||||
style.label.clone(),
|
||||
)
|
||||
.aligned()
|
||||
.left()
|
||||
.constrained()
|
||||
.with_height(theme.contact_list.row_height)
|
||||
.contained()
|
||||
.with_style(style.container)
|
||||
.boxed()
|
||||
})
|
||||
.with_cursor_style(CursorStyle::PointingHand)
|
||||
.on_click(MouseButton::Left, move |_, cx| {
|
||||
cx.write_to_clipboard(ClipboardItem::new(info.url.to_string()));
|
||||
cx.notify();
|
||||
})
|
||||
.boxed(),
|
||||
)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}),
|
||||
)
|
||||
.boxed()
|
||||
}
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
use crate::{contact_finder::ContactFinder, contact_list::ContactList};
|
||||
use client::UserStore;
|
||||
use gpui::{
|
||||
actions, elements::*, Entity, ModelHandle, MutableAppContext, RenderContext, View, ViewContext,
|
||||
ViewHandle,
|
||||
actions, elements::*, ClipboardItem, CursorStyle, Entity, ModelHandle, MouseButton,
|
||||
MutableAppContext, RenderContext, View, ViewContext, ViewHandle,
|
||||
};
|
||||
use project::Project;
|
||||
use settings::Settings;
|
||||
|
@ -92,7 +92,57 @@ impl View for ContactsPopover {
|
|||
Child::ContactFinder(child) => ChildView::new(child),
|
||||
};
|
||||
|
||||
child
|
||||
Flex::column()
|
||||
.with_child(child.flex(1., true).boxed())
|
||||
.with_children(
|
||||
self.user_store
|
||||
.read(cx)
|
||||
.invite_info()
|
||||
.cloned()
|
||||
.and_then(|info| {
|
||||
enum InviteLink {}
|
||||
|
||||
if info.count > 0 {
|
||||
Some(
|
||||
MouseEventHandler::<InviteLink>::new(0, cx, |state, cx| {
|
||||
let style = theme
|
||||
.contacts_popover
|
||||
.invite_row
|
||||
.style_for(state, false)
|
||||
.clone();
|
||||
|
||||
let copied = cx.read_from_clipboard().map_or(false, |item| {
|
||||
item.text().as_str() == info.url.as_ref()
|
||||
});
|
||||
|
||||
Label::new(
|
||||
format!(
|
||||
"{} invite link ({} left)",
|
||||
if copied { "Copied" } else { "Copy" },
|
||||
info.count
|
||||
),
|
||||
style.label.clone(),
|
||||
)
|
||||
.aligned()
|
||||
.left()
|
||||
.constrained()
|
||||
.with_height(theme.contacts_popover.invite_row_height)
|
||||
.contained()
|
||||
.with_style(style.container)
|
||||
.boxed()
|
||||
})
|
||||
.with_cursor_style(CursorStyle::PointingHand)
|
||||
.on_click(MouseButton::Left, move |_, cx| {
|
||||
cx.write_to_clipboard(ClipboardItem::new(info.url.to_string()));
|
||||
cx.notify();
|
||||
})
|
||||
.boxed(),
|
||||
)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}),
|
||||
)
|
||||
.contained()
|
||||
.with_style(theme.contacts_popover.container)
|
||||
.constrained()
|
||||
|
|
|
@ -89,6 +89,8 @@ pub struct ContactsPopover {
|
|||
pub container: ContainerStyle,
|
||||
pub height: f32,
|
||||
pub width: f32,
|
||||
pub invite_row_height: f32,
|
||||
pub invite_row: Interactive<ContainedLabel>,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Default)]
|
||||
|
@ -110,7 +112,6 @@ pub struct ContactList {
|
|||
pub contact_button_spacing: f32,
|
||||
pub disabled_button: IconButton,
|
||||
pub section_icon_size: f32,
|
||||
pub invite_row: Interactive<ContainedLabel>,
|
||||
pub calling_indicator: ContainedText,
|
||||
}
|
||||
|
||||
|
|
|
@ -139,17 +139,6 @@ export default function contactList(theme: Theme) {
|
|||
background: backgroundColor(theme, 100),
|
||||
color: iconColor(theme, "muted"),
|
||||
},
|
||||
inviteRow: {
|
||||
padding: {
|
||||
left: sidePadding,
|
||||
right: sidePadding,
|
||||
},
|
||||
border: { top: true, width: 1, color: borderColor(theme, "primary") },
|
||||
text: text(theme, "sans", "secondary", { size: "sm" }),
|
||||
hover: {
|
||||
text: text(theme, "sans", "active", { size: "sm" }),
|
||||
},
|
||||
},
|
||||
callingIndicator: {
|
||||
...text(theme, "mono", "muted", { size: "xs" })
|
||||
},
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
import Theme from "../themes/common/theme";
|
||||
import { backgroundColor, border, popoverShadow } from "./components";
|
||||
import { backgroundColor, border, borderColor, popoverShadow, text } from "./components";
|
||||
|
||||
export default function contactsPopover(theme: Theme) {
|
||||
const sidePadding = 12;
|
||||
return {
|
||||
background: backgroundColor(theme, 300, "base"),
|
||||
cornerRadius: 6,
|
||||
|
@ -11,5 +12,17 @@ export default function contactsPopover(theme: Theme) {
|
|||
border: border(theme, "primary"),
|
||||
width: 300,
|
||||
height: 400,
|
||||
inviteRowHeight: 28,
|
||||
inviteRow: {
|
||||
padding: {
|
||||
left: sidePadding,
|
||||
right: sidePadding,
|
||||
},
|
||||
border: { top: true, width: 1, color: borderColor(theme, "primary") },
|
||||
text: text(theme, "sans", "secondary", { size: "sm" }),
|
||||
hover: {
|
||||
text: text(theme, "sans", "active", { size: "sm" }),
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue