TEMP
This commit is contained in:
parent
e6aab57656
commit
4a25fae51e
2 changed files with 47 additions and 31 deletions
|
@ -155,19 +155,19 @@ actions!(
|
||||||
|
|
||||||
const COLLABORATION_PANEL_KEY: &'static str = "CollaborationPanel";
|
const COLLABORATION_PANEL_KEY: &'static str = "CollaborationPanel";
|
||||||
|
|
||||||
use std::sync::Arc;
|
use std::{iter::once, sync::Arc};
|
||||||
|
|
||||||
use client::{Client, Contact, UserStore};
|
use client::{Client, Contact, UserStore};
|
||||||
use db::kvp::KEY_VALUE_STORE;
|
use db::kvp::KEY_VALUE_STORE;
|
||||||
use gpui::{
|
use gpui::{
|
||||||
actions, div, serde_json, AppContext, AsyncWindowContext, Div, EventEmitter, FocusHandle,
|
actions, div, serde_json, AppContext, AsyncWindowContext, Div, EventEmitter, FocusHandle,
|
||||||
Focusable, FocusableView, InteractiveElement, Model, ParentElement, Render, Styled, View,
|
Focusable, FocusableView, InteractiveElement, IntoElement, Model, ParentElement, Render,
|
||||||
ViewContext, VisualContext, WeakView,
|
RenderOnce, Styled, View, ViewContext, VisualContext, WeakView,
|
||||||
};
|
};
|
||||||
use project::Fs;
|
use project::Fs;
|
||||||
use serde_derive::{Deserialize, Serialize};
|
use serde_derive::{Deserialize, Serialize};
|
||||||
use settings::Settings;
|
use settings::Settings;
|
||||||
use ui::{h_stack, v_stack, Avatar, Button, Label};
|
use ui::{h_stack, v_stack, Avatar, Button, Icon, IconButton, Label, List, ListHeader};
|
||||||
use util::ResultExt;
|
use util::ResultExt;
|
||||||
use workspace::{
|
use workspace::{
|
||||||
dock::{DockPosition, Panel, PanelEvent},
|
dock::{DockPosition, Panel, PanelEvent},
|
||||||
|
@ -309,7 +309,7 @@ pub struct CollabPanel {
|
||||||
// match_candidates: Vec<StringMatchCandidate>,
|
// match_candidates: Vec<StringMatchCandidate>,
|
||||||
// list_state: ListState<Self>,
|
// list_state: ListState<Self>,
|
||||||
// subscriptions: Vec<Subscription>,
|
// subscriptions: Vec<Subscription>,
|
||||||
// collapsed_sections: Vec<Section>,
|
collapsed_sections: Vec<Section>,
|
||||||
// collapsed_channels: Vec<ChannelId>,
|
// collapsed_channels: Vec<ChannelId>,
|
||||||
// drag_target_channel: ChannelDragTarget,
|
// drag_target_channel: ChannelDragTarget,
|
||||||
workspace: WeakView<Workspace>,
|
workspace: WeakView<Workspace>,
|
||||||
|
@ -336,16 +336,16 @@ struct SerializedCollabPanel {
|
||||||
// Dismissed,
|
// Dismissed,
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// #[derive(Clone, Copy, PartialEq, Eq, Debug, PartialOrd, Ord)]
|
#[derive(Clone, Copy, PartialEq, Eq, Debug, PartialOrd, Ord)]
|
||||||
// enum Section {
|
enum Section {
|
||||||
// ActiveCall,
|
// ActiveCall,
|
||||||
// Channels,
|
// Channels,
|
||||||
// ChannelInvites,
|
// ChannelInvites,
|
||||||
// ContactRequests,
|
// ContactRequests,
|
||||||
// Contacts,
|
Contacts,
|
||||||
// Online,
|
// Online,
|
||||||
// Offline,
|
Offline,
|
||||||
// }
|
}
|
||||||
|
|
||||||
// #[derive(Clone, Debug)]
|
// #[derive(Clone, Debug)]
|
||||||
// enum ListEntry {
|
// enum ListEntry {
|
||||||
|
@ -603,7 +603,7 @@ impl CollabPanel {
|
||||||
// project: workspace.project().clone(),
|
// project: workspace.project().clone(),
|
||||||
// subscriptions: Vec::default(),
|
// subscriptions: Vec::default(),
|
||||||
// match_candidates: Vec::default(),
|
// match_candidates: Vec::default(),
|
||||||
// collapsed_sections: vec![Section::Offline],
|
collapsed_sections: vec![Section::Offline],
|
||||||
// collapsed_channels: Vec::default(),
|
// collapsed_channels: Vec::default(),
|
||||||
workspace: workspace.weak_handle(),
|
workspace: workspace.weak_handle(),
|
||||||
client: workspace.app_state().client.clone(),
|
client: workspace.app_state().client.clone(),
|
||||||
|
@ -3269,11 +3269,23 @@ impl CollabPanel {
|
||||||
)))
|
)))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render_signed_in(&mut self, cx: &mut ViewContext<Self>) -> Div {
|
fn render_signed_in(&mut self, cx: &mut ViewContext<Self>) -> List {
|
||||||
let contacts = self.contacts(cx).unwrap_or_default();
|
let contacts = self.contacts(cx).unwrap_or_default();
|
||||||
let workspace = self.workspace.clone();
|
let workspace = self.workspace.clone();
|
||||||
|
|
||||||
v_stack().children(contacts.into_iter().map(|contact| {
|
let children = once(
|
||||||
|
ListHeader::new("Contacts")
|
||||||
|
.right_button(
|
||||||
|
IconButton::new("add-contact", Icon::Plus).on_click(cx.listener(
|
||||||
|
|this, _, cx| {
|
||||||
|
todo!();
|
||||||
|
//this.toggle_contact_finder(cx);
|
||||||
|
},
|
||||||
|
)),
|
||||||
|
)
|
||||||
|
.render(cx),
|
||||||
|
)
|
||||||
|
.chain(contacts.into_iter().map(|contact| {
|
||||||
let id = contact.user.id;
|
let id = contact.user.id;
|
||||||
h_stack()
|
h_stack()
|
||||||
.p_2()
|
.p_2()
|
||||||
|
@ -3298,7 +3310,9 @@ impl CollabPanel {
|
||||||
.log_err();
|
.log_err();
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}))
|
}));
|
||||||
|
|
||||||
|
List::new().children(children)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3354,10 +3368,12 @@ impl Render for CollabPanel {
|
||||||
div()
|
div()
|
||||||
.key_context("CollabPanel")
|
.key_context("CollabPanel")
|
||||||
.track_focus(&self.focus_handle)
|
.track_focus(&self.focus_handle)
|
||||||
.child(if self.user_store.read(cx).current_user().is_none() {
|
.map(|el| {
|
||||||
self.render_signed_out(cx)
|
if self.user_store.read(cx).current_user().is_none() {
|
||||||
} else {
|
el.child(self.render_signed_out(cx))
|
||||||
self.render_signed_in(cx)
|
} else {
|
||||||
|
el.child(self.render_signed_in(cx))
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,8 @@ use smallvec::SmallVec;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
disclosure_control, h_stack, v_stack, Avatar, Icon, IconElement, IconSize, Label, Toggle,
|
disclosure_control, h_stack, v_stack, Avatar, Icon, IconButton, IconElement, IconSize, Label,
|
||||||
|
Toggle,
|
||||||
};
|
};
|
||||||
use crate::{prelude::*, GraphicSlot};
|
use crate::{prelude::*, GraphicSlot};
|
||||||
|
|
||||||
|
@ -18,8 +19,7 @@ pub enum ListItemVariant {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub enum ListHeaderMeta {
|
pub enum ListHeaderMeta {
|
||||||
// TODO: These should be IconButtons
|
Tools(Vec<IconButton>),
|
||||||
Tools(Vec<Icon>),
|
|
||||||
// TODO: This should be a button
|
// TODO: This should be a button
|
||||||
Button(Label),
|
Button(Label),
|
||||||
Text(Label),
|
Text(Label),
|
||||||
|
@ -45,11 +45,7 @@ impl RenderOnce for ListHeader {
|
||||||
h_stack()
|
h_stack()
|
||||||
.gap_2()
|
.gap_2()
|
||||||
.items_center()
|
.items_center()
|
||||||
.children(icons.into_iter().map(|i| {
|
.children(icons.into_iter().map(|i| i.color(Color::Muted))),
|
||||||
IconElement::new(i)
|
|
||||||
.color(Color::Muted)
|
|
||||||
.size(IconSize::Small)
|
|
||||||
})),
|
|
||||||
),
|
),
|
||||||
Some(ListHeaderMeta::Button(label)) => div().child(label),
|
Some(ListHeaderMeta::Button(label)) => div().child(label),
|
||||||
Some(ListHeaderMeta::Text(label)) => div().child(label),
|
Some(ListHeaderMeta::Text(label)) => div().child(label),
|
||||||
|
@ -113,6 +109,10 @@ impl ListHeader {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn right_button(self, button: IconButton) -> Self {
|
||||||
|
self.meta(Some(ListHeaderMeta::Tools(vec![button])))
|
||||||
|
}
|
||||||
|
|
||||||
pub fn meta(mut self, meta: Option<ListHeaderMeta>) -> Self {
|
pub fn meta(mut self, meta: Option<ListHeaderMeta>) -> Self {
|
||||||
self.meta = meta;
|
self.meta = meta;
|
||||||
self
|
self
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue