Make major collab panel headers non-interactive
This commit is contained in:
parent
fc49194535
commit
4a088fc4ae
3 changed files with 146 additions and 155 deletions
|
@ -444,123 +444,122 @@ impl CollabPanel {
|
||||||
self.entries
|
self.entries
|
||||||
.push(ContactEntry::Header(Section::Contacts, 0));
|
.push(ContactEntry::Header(Section::Contacts, 0));
|
||||||
|
|
||||||
if !self.collapsed_sections.contains(&Section::Contacts) {
|
let mut request_entries = Vec::new();
|
||||||
let mut request_entries = Vec::new();
|
let incoming = user_store.incoming_contact_requests();
|
||||||
let incoming = user_store.incoming_contact_requests();
|
if !incoming.is_empty() {
|
||||||
if !incoming.is_empty() {
|
self.match_candidates.clear();
|
||||||
self.match_candidates.clear();
|
self.match_candidates
|
||||||
self.match_candidates
|
.extend(
|
||||||
.extend(
|
incoming
|
||||||
incoming
|
.iter()
|
||||||
.iter()
|
.enumerate()
|
||||||
.enumerate()
|
.map(|(ix, user)| StringMatchCandidate {
|
||||||
.map(|(ix, user)| StringMatchCandidate {
|
id: ix,
|
||||||
id: ix,
|
string: user.github_login.clone(),
|
||||||
string: user.github_login.clone(),
|
char_bag: user.github_login.chars().collect(),
|
||||||
char_bag: user.github_login.chars().collect(),
|
}),
|
||||||
}),
|
|
||||||
);
|
|
||||||
let matches = executor.block(match_strings(
|
|
||||||
&self.match_candidates,
|
|
||||||
&query,
|
|
||||||
true,
|
|
||||||
usize::MAX,
|
|
||||||
&Default::default(),
|
|
||||||
executor.clone(),
|
|
||||||
));
|
|
||||||
request_entries.extend(
|
|
||||||
matches.iter().map(|mat| {
|
|
||||||
ContactEntry::IncomingRequest(incoming[mat.candidate_id].clone())
|
|
||||||
}),
|
|
||||||
);
|
);
|
||||||
}
|
let matches = executor.block(match_strings(
|
||||||
|
&self.match_candidates,
|
||||||
|
&query,
|
||||||
|
true,
|
||||||
|
usize::MAX,
|
||||||
|
&Default::default(),
|
||||||
|
executor.clone(),
|
||||||
|
));
|
||||||
|
request_entries.extend(
|
||||||
|
matches
|
||||||
|
.iter()
|
||||||
|
.map(|mat| ContactEntry::IncomingRequest(incoming[mat.candidate_id].clone())),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
let outgoing = user_store.outgoing_contact_requests();
|
let outgoing = user_store.outgoing_contact_requests();
|
||||||
if !outgoing.is_empty() {
|
if !outgoing.is_empty() {
|
||||||
self.match_candidates.clear();
|
self.match_candidates.clear();
|
||||||
self.match_candidates
|
self.match_candidates
|
||||||
.extend(
|
.extend(
|
||||||
outgoing
|
outgoing
|
||||||
.iter()
|
.iter()
|
||||||
.enumerate()
|
.enumerate()
|
||||||
.map(|(ix, user)| StringMatchCandidate {
|
.map(|(ix, user)| StringMatchCandidate {
|
||||||
id: ix,
|
id: ix,
|
||||||
string: user.github_login.clone(),
|
string: user.github_login.clone(),
|
||||||
char_bag: user.github_login.chars().collect(),
|
char_bag: user.github_login.chars().collect(),
|
||||||
}),
|
}),
|
||||||
);
|
|
||||||
let matches = executor.block(match_strings(
|
|
||||||
&self.match_candidates,
|
|
||||||
&query,
|
|
||||||
true,
|
|
||||||
usize::MAX,
|
|
||||||
&Default::default(),
|
|
||||||
executor.clone(),
|
|
||||||
));
|
|
||||||
request_entries.extend(
|
|
||||||
matches.iter().map(|mat| {
|
|
||||||
ContactEntry::OutgoingRequest(outgoing[mat.candidate_id].clone())
|
|
||||||
}),
|
|
||||||
);
|
);
|
||||||
}
|
let matches = executor.block(match_strings(
|
||||||
|
&self.match_candidates,
|
||||||
|
&query,
|
||||||
|
true,
|
||||||
|
usize::MAX,
|
||||||
|
&Default::default(),
|
||||||
|
executor.clone(),
|
||||||
|
));
|
||||||
|
request_entries.extend(
|
||||||
|
matches
|
||||||
|
.iter()
|
||||||
|
.map(|mat| ContactEntry::OutgoingRequest(outgoing[mat.candidate_id].clone())),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
if !request_entries.is_empty() {
|
if !request_entries.is_empty() {
|
||||||
self.entries
|
self.entries
|
||||||
.push(ContactEntry::Header(Section::Requests, 1));
|
.push(ContactEntry::Header(Section::Requests, 1));
|
||||||
if !self.collapsed_sections.contains(&Section::Requests) {
|
if !self.collapsed_sections.contains(&Section::Requests) {
|
||||||
self.entries.append(&mut request_entries);
|
self.entries.append(&mut request_entries);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let contacts = user_store.contacts();
|
let contacts = user_store.contacts();
|
||||||
if !contacts.is_empty() {
|
if !contacts.is_empty() {
|
||||||
self.match_candidates.clear();
|
self.match_candidates.clear();
|
||||||
self.match_candidates
|
self.match_candidates
|
||||||
.extend(contacts.iter().enumerate().map(|(ix, contact)| {
|
.extend(
|
||||||
StringMatchCandidate {
|
contacts
|
||||||
|
.iter()
|
||||||
|
.enumerate()
|
||||||
|
.map(|(ix, contact)| StringMatchCandidate {
|
||||||
id: ix,
|
id: ix,
|
||||||
string: contact.user.github_login.clone(),
|
string: contact.user.github_login.clone(),
|
||||||
char_bag: contact.user.github_login.chars().collect(),
|
char_bag: contact.user.github_login.chars().collect(),
|
||||||
}
|
}),
|
||||||
}));
|
);
|
||||||
|
|
||||||
let matches = executor.block(match_strings(
|
let matches = executor.block(match_strings(
|
||||||
&self.match_candidates,
|
&self.match_candidates,
|
||||||
&query,
|
&query,
|
||||||
true,
|
true,
|
||||||
usize::MAX,
|
usize::MAX,
|
||||||
&Default::default(),
|
&Default::default(),
|
||||||
executor.clone(),
|
executor.clone(),
|
||||||
));
|
));
|
||||||
|
|
||||||
let (mut online_contacts, offline_contacts) = matches
|
let (mut online_contacts, offline_contacts) = matches
|
||||||
.iter()
|
.iter()
|
||||||
.partition::<Vec<_>, _>(|mat| contacts[mat.candidate_id].online);
|
.partition::<Vec<_>, _>(|mat| contacts[mat.candidate_id].online);
|
||||||
if let Some(room) = ActiveCall::global(cx).read(cx).room() {
|
if let Some(room) = ActiveCall::global(cx).read(cx).room() {
|
||||||
let room = room.read(cx);
|
let room = room.read(cx);
|
||||||
online_contacts.retain(|contact| {
|
online_contacts.retain(|contact| {
|
||||||
let contact = &contacts[contact.candidate_id];
|
let contact = &contacts[contact.candidate_id];
|
||||||
!room.contains_participant(contact.user.id)
|
!room.contains_participant(contact.user.id)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
for (matches, section) in [
|
for (matches, section) in [
|
||||||
(online_contacts, Section::Online),
|
(online_contacts, Section::Online),
|
||||||
(offline_contacts, Section::Offline),
|
(offline_contacts, Section::Offline),
|
||||||
] {
|
] {
|
||||||
if !matches.is_empty() {
|
if !matches.is_empty() {
|
||||||
self.entries.push(ContactEntry::Header(section, 1));
|
self.entries.push(ContactEntry::Header(section, 1));
|
||||||
if !self.collapsed_sections.contains(§ion) {
|
if !self.collapsed_sections.contains(§ion) {
|
||||||
let active_call = &ActiveCall::global(cx).read(cx);
|
let active_call = &ActiveCall::global(cx).read(cx);
|
||||||
for mat in matches {
|
for mat in matches {
|
||||||
let contact = &contacts[mat.candidate_id];
|
let contact = &contacts[mat.candidate_id];
|
||||||
self.entries.push(ContactEntry::Contact {
|
self.entries.push(ContactEntry::Contact {
|
||||||
contact: contact.clone(),
|
contact: contact.clone(),
|
||||||
calling: active_call
|
calling: active_call.pending_invites().contains(&contact.user.id),
|
||||||
.pending_invites()
|
});
|
||||||
.contains(&contact.user.id),
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -940,13 +939,15 @@ impl CollabPanel {
|
||||||
let can_collapse = depth > 0;
|
let can_collapse = depth > 0;
|
||||||
let icon_size = (&theme.collab_panel).section_icon_size;
|
let icon_size = (&theme.collab_panel).section_icon_size;
|
||||||
MouseEventHandler::<Header, Self>::new(section as usize, cx, |state, _| {
|
MouseEventHandler::<Header, Self>::new(section as usize, cx, |state, _| {
|
||||||
let header_style = if depth > 0 {
|
let header_style = if can_collapse {
|
||||||
&theme.collab_panel.subheader_row
|
theme
|
||||||
|
.collab_panel
|
||||||
|
.subheader_row
|
||||||
|
.in_state(is_selected)
|
||||||
|
.style_for(state)
|
||||||
} else {
|
} else {
|
||||||
&theme.collab_panel.header_row
|
&theme.collab_panel.header_row
|
||||||
}
|
};
|
||||||
.in_state(is_selected)
|
|
||||||
.style_for(state);
|
|
||||||
|
|
||||||
Flex::row()
|
Flex::row()
|
||||||
.with_children(if can_collapse {
|
.with_children(if can_collapse {
|
||||||
|
@ -1209,13 +1210,15 @@ impl CollabPanel {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn select_next(&mut self, _: &SelectNext, cx: &mut ViewContext<Self>) {
|
fn select_next(&mut self, _: &SelectNext, cx: &mut ViewContext<Self>) {
|
||||||
if let Some(ix) = self.selection {
|
let mut ix = self.selection.map_or(0, |ix| ix + 1);
|
||||||
if self.entries.len() > ix + 1 {
|
while let Some(entry) = self.entries.get(ix) {
|
||||||
self.selection = Some(ix + 1);
|
if entry.is_selectable() {
|
||||||
|
self.selection = Some(ix);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
} else if !self.entries.is_empty() {
|
ix += 1;
|
||||||
self.selection = Some(0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
self.list_state.reset(self.entries.len());
|
self.list_state.reset(self.entries.len());
|
||||||
if let Some(ix) = self.selection {
|
if let Some(ix) = self.selection {
|
||||||
self.list_state.scroll_to(ListOffset {
|
self.list_state.scroll_to(ListOffset {
|
||||||
|
@ -1227,13 +1230,18 @@ impl CollabPanel {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn select_prev(&mut self, _: &SelectPrev, cx: &mut ViewContext<Self>) {
|
fn select_prev(&mut self, _: &SelectPrev, cx: &mut ViewContext<Self>) {
|
||||||
if let Some(ix) = self.selection {
|
if let Some(mut ix) = self.selection.take() {
|
||||||
if ix > 0 {
|
while ix > 0 {
|
||||||
self.selection = Some(ix - 1);
|
ix -= 1;
|
||||||
} else {
|
if let Some(entry) = self.entries.get(ix) {
|
||||||
self.selection = None;
|
if entry.is_selectable() {
|
||||||
|
self.selection = Some(ix);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
self.list_state.reset(self.entries.len());
|
self.list_state.reset(self.entries.len());
|
||||||
if let Some(ix) = self.selection {
|
if let Some(ix) = self.selection {
|
||||||
self.list_state.scroll_to(ListOffset {
|
self.list_state.scroll_to(ListOffset {
|
||||||
|
@ -1471,6 +1479,16 @@ impl Panel for CollabPanel {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl ContactEntry {
|
||||||
|
fn is_selectable(&self) -> bool {
|
||||||
|
if let ContactEntry::Header(_, 0) = self {
|
||||||
|
false
|
||||||
|
} else {
|
||||||
|
true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl PartialEq for ContactEntry {
|
impl PartialEq for ContactEntry {
|
||||||
fn eq(&self, other: &Self) -> bool {
|
fn eq(&self, other: &Self) -> bool {
|
||||||
match self {
|
match self {
|
||||||
|
|
|
@ -225,7 +225,7 @@ pub struct CollabPanel {
|
||||||
pub user_query_editor_height: f32,
|
pub user_query_editor_height: f32,
|
||||||
pub leave_call_button: IconButton,
|
pub leave_call_button: IconButton,
|
||||||
pub add_contact_button: IconButton,
|
pub add_contact_button: IconButton,
|
||||||
pub header_row: Toggleable<Interactive<ContainedText>>,
|
pub header_row: ContainedText,
|
||||||
pub subheader_row: Toggleable<Interactive<ContainedText>>,
|
pub subheader_row: Toggleable<Interactive<ContainedText>>,
|
||||||
pub leave_call: Interactive<ContainedText>,
|
pub leave_call: Interactive<ContainedText>,
|
||||||
pub contact_row: Toggleable<Interactive<ContainerStyle>>,
|
pub contact_row: Toggleable<Interactive<ContainerStyle>>,
|
||||||
|
|
|
@ -87,45 +87,18 @@ export default function contacts_panel(): any {
|
||||||
},
|
},
|
||||||
row_height: 28,
|
row_height: 28,
|
||||||
section_icon_size: 8,
|
section_icon_size: 8,
|
||||||
header_row: toggleable({
|
header_row: {
|
||||||
base: interactive({
|
...text(layer, "mono", { size: "sm", weight: "bold" }),
|
||||||
base: {
|
margin: { top: 14 },
|
||||||
...text(layer, "mono", { size: "sm", weight: "bold" }),
|
padding: {
|
||||||
margin: { top: 14 },
|
left: side_padding,
|
||||||
padding: {
|
right: side_padding,
|
||||||
left: side_padding,
|
|
||||||
right: side_padding,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
state: {
|
|
||||||
hovered: {
|
|
||||||
background: background(layer, "hovered"),
|
|
||||||
},
|
|
||||||
clicked: {
|
|
||||||
background: background(layer, "pressed"),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
state: {
|
|
||||||
active: {
|
|
||||||
default: {
|
|
||||||
...text(layer, "mono", "active", { size: "sm" }),
|
|
||||||
background: background(layer, "active"),
|
|
||||||
},
|
|
||||||
hovered: {
|
|
||||||
background: background(layer, "hovered"),
|
|
||||||
},
|
|
||||||
clicked: {
|
|
||||||
background: background(layer, "pressed"),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
}),
|
},
|
||||||
subheader_row: toggleable({
|
subheader_row: toggleable({
|
||||||
base: interactive({
|
base: interactive({
|
||||||
base: {
|
base: {
|
||||||
...text(layer, "mono", { size: "sm" }),
|
...text(layer, "mono", { size: "sm" }),
|
||||||
// margin: { top: 14 },
|
|
||||||
padding: {
|
padding: {
|
||||||
left: side_padding,
|
left: side_padding,
|
||||||
right: side_padding,
|
right: side_padding,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue