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::{
|
use gpui::{
|
||||||
elements::*,
|
elements::*,
|
||||||
geometry::{rect::RectF, vector::vec2f},
|
geometry::{rect::RectF, vector::vec2f},
|
||||||
impl_actions, impl_internal_actions, keymap, AppContext, ClipboardItem, CursorStyle, Entity,
|
impl_actions, impl_internal_actions, keymap, AppContext, CursorStyle, Entity, ModelHandle,
|
||||||
ModelHandle, MouseButton, MutableAppContext, RenderContext, Subscription, View, ViewContext,
|
MouseButton, MutableAppContext, RenderContext, Subscription, View, ViewContext, ViewHandle,
|
||||||
ViewHandle,
|
|
||||||
};
|
};
|
||||||
use menu::{Confirm, SelectNext, SelectPrev};
|
use menu::{Confirm, SelectNext, SelectPrev};
|
||||||
use project::Project;
|
use project::Project;
|
||||||
|
@ -1104,55 +1103,6 @@ impl View for ContactList {
|
||||||
.boxed(),
|
.boxed(),
|
||||||
)
|
)
|
||||||
.with_child(List::new(self.list_state.clone()).flex(1., false).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()
|
.boxed()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
use crate::{contact_finder::ContactFinder, contact_list::ContactList};
|
use crate::{contact_finder::ContactFinder, contact_list::ContactList};
|
||||||
use client::UserStore;
|
use client::UserStore;
|
||||||
use gpui::{
|
use gpui::{
|
||||||
actions, elements::*, Entity, ModelHandle, MutableAppContext, RenderContext, View, ViewContext,
|
actions, elements::*, ClipboardItem, CursorStyle, Entity, ModelHandle, MouseButton,
|
||||||
ViewHandle,
|
MutableAppContext, RenderContext, View, ViewContext, ViewHandle,
|
||||||
};
|
};
|
||||||
use project::Project;
|
use project::Project;
|
||||||
use settings::Settings;
|
use settings::Settings;
|
||||||
|
@ -92,7 +92,57 @@ impl View for ContactsPopover {
|
||||||
Child::ContactFinder(child) => ChildView::new(child),
|
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()
|
.contained()
|
||||||
.with_style(theme.contacts_popover.container)
|
.with_style(theme.contacts_popover.container)
|
||||||
.constrained()
|
.constrained()
|
||||||
|
|
|
@ -89,6 +89,8 @@ pub struct ContactsPopover {
|
||||||
pub container: ContainerStyle,
|
pub container: ContainerStyle,
|
||||||
pub height: f32,
|
pub height: f32,
|
||||||
pub width: f32,
|
pub width: f32,
|
||||||
|
pub invite_row_height: f32,
|
||||||
|
pub invite_row: Interactive<ContainedLabel>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Deserialize, Default)]
|
#[derive(Deserialize, Default)]
|
||||||
|
@ -110,7 +112,6 @@ pub struct ContactList {
|
||||||
pub contact_button_spacing: f32,
|
pub contact_button_spacing: f32,
|
||||||
pub disabled_button: IconButton,
|
pub disabled_button: IconButton,
|
||||||
pub section_icon_size: f32,
|
pub section_icon_size: f32,
|
||||||
pub invite_row: Interactive<ContainedLabel>,
|
|
||||||
pub calling_indicator: ContainedText,
|
pub calling_indicator: ContainedText,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -139,17 +139,6 @@ export default function contactList(theme: Theme) {
|
||||||
background: backgroundColor(theme, 100),
|
background: backgroundColor(theme, 100),
|
||||||
color: iconColor(theme, "muted"),
|
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: {
|
callingIndicator: {
|
||||||
...text(theme, "mono", "muted", { size: "xs" })
|
...text(theme, "mono", "muted", { size: "xs" })
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
import Theme from "../themes/common/theme";
|
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) {
|
export default function contactsPopover(theme: Theme) {
|
||||||
|
const sidePadding = 12;
|
||||||
return {
|
return {
|
||||||
background: backgroundColor(theme, 300, "base"),
|
background: backgroundColor(theme, 300, "base"),
|
||||||
cornerRadius: 6,
|
cornerRadius: 6,
|
||||||
|
@ -11,5 +12,17 @@ export default function contactsPopover(theme: Theme) {
|
||||||
border: border(theme, "primary"),
|
border: border(theme, "primary"),
|
||||||
width: 300,
|
width: 300,
|
||||||
height: 400,
|
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…
Add table
Add a link
Reference in a new issue