History

TEMP

Conrad Irwin committed 2 years ago

Commit 4a25fae1 parent e6aab572 files · +47 −31Browse files

Unified · Split

2 files
  1. crates/collab_ui2/src/collab_panel.rs +39 −23
  2. crates/ui2/src/components/list.rs +8 −8
crates/collab_ui2/src/collab_panel.rs+39−23
@@ -155,19 +155,19 @@ actions!( · 154 unmodified lines
155 155
156const COLLABORATION_PANEL_KEY: &'static str = "CollaborationPanel";156const COLLABORATION_PANEL_KEY: &'static str = "CollaborationPanel";
157 157
158use std::sync::Arc;158use std::{iter::once, sync::Arc};
159 159
160use client::{Client, Contact, UserStore};160use client::{Client, Contact, UserStore};
161use db::kvp::KEY_VALUE_STORE;161use db::kvp::KEY_VALUE_STORE;
162use gpui::{162use gpui::{
163 actions, div, serde_json, AppContext, AsyncWindowContext, Div, EventEmitter, FocusHandle,163 actions, div, serde_json, AppContext, AsyncWindowContext, Div, EventEmitter, FocusHandle,
164 Focusable, FocusableView, InteractiveElement, Model, ParentElement, Render, Styled, View,164 Focusable, FocusableView, InteractiveElement, IntoElement, Model, ParentElement, Render,
165 ViewContext, VisualContext, WeakView,165 RenderOnce, Styled, View, ViewContext, VisualContext, WeakView,
166};166};
167use project::Fs;167use project::Fs;
168use serde_derive::{Deserialize, Serialize};168use serde_derive::{Deserialize, Serialize};
169use settings::Settings;169use settings::Settings;
170use ui::{h_stack, v_stack, Avatar, Button, Label};170use ui::{h_stack, v_stack, Avatar, Button, Icon, IconButton, Label, List, ListHeader};
171use util::ResultExt;171use util::ResultExt;
172use workspace::{172use workspace::{
173 dock::{DockPosition, Panel, PanelEvent},173 dock::{DockPosition, Panel, PanelEvent},
@@ -309,7 +309,7 @@ pub struct CollabPanel { · 135 unmodified lines
309 // match_candidates: Vec<StringMatchCandidate>,309 // match_candidates: Vec<StringMatchCandidate>,
310 // list_state: ListState<Self>,310 // list_state: ListState<Self>,
311 // subscriptions: Vec<Subscription>,311 // subscriptions: Vec<Subscription>,
312 // collapsed_sections: Vec<Section>,312 collapsed_sections: Vec<Section>,
313 // collapsed_channels: Vec<ChannelId>,313 // collapsed_channels: Vec<ChannelId>,
314 // drag_target_channel: ChannelDragTarget,314 // drag_target_channel: ChannelDragTarget,
315 workspace: WeakView<Workspace>,315 workspace: WeakView<Workspace>,
@@ -336,16 +336,16 @@ struct SerializedCollabPanel { · 20 unmodified lines
336// Dismissed,336// Dismissed,
337// }337// }
338 338
339// #[derive(Clone, Copy, PartialEq, Eq, Debug, PartialOrd, Ord)]339#[derive(Clone, Copy, PartialEq, Eq, Debug, PartialOrd, Ord)]
340// enum Section {340enum Section {
341// ActiveCall,341 // ActiveCall,
342// Channels,342 // Channels,
343// ChannelInvites,343 // ChannelInvites,
344// ContactRequests,344 // ContactRequests,
345// Contacts,345 Contacts,
346// Online,346 // Online,
347// Offline,347 Offline,
348// }348}
349 349
350// #[derive(Clone, Debug)]350// #[derive(Clone, Debug)]
351// enum ListEntry {351// enum ListEntry {
@@ -603,7 +603,7 @@ impl CollabPanel { · 251 unmodified lines
603 // project: workspace.project().clone(),603 // project: workspace.project().clone(),
604 // subscriptions: Vec::default(),604 // subscriptions: Vec::default(),
605 // match_candidates: Vec::default(),605 // match_candidates: Vec::default(),
606 // collapsed_sections: vec![Section::Offline],606 collapsed_sections: vec![Section::Offline],
607 // collapsed_channels: Vec::default(),607 // collapsed_channels: Vec::default(),
608 workspace: workspace.weak_handle(),608 workspace: workspace.weak_handle(),
609 client: workspace.app_state().client.clone(),609 client: workspace.app_state().client.clone(),
@@ -3269,11 +3269,23 @@ impl CollabPanel { · 2659 unmodified lines
3269 )))3269 )))
3270 }3270 }
3271 3271
3272 fn render_signed_in(&mut self, cx: &mut ViewContext<Self>) -> Div {3272 fn render_signed_in(&mut self, cx: &mut ViewContext<Self>) -> List {
3273 let contacts = self.contacts(cx).unwrap_or_default();3273 let contacts = self.contacts(cx).unwrap_or_default();
3274 let workspace = self.workspace.clone();3274 let workspace = self.workspace.clone();
3275 3275
3276 v_stack().children(contacts.into_iter().map(|contact| {3276 let children = once(
3277 ListHeader::new("Contacts")
3278 .right_button(
3279 IconButton::new("add-contact", Icon::Plus).on_click(cx.listener(
3280 |this, _, cx| {
3281 todo!();
3282 //this.toggle_contact_finder(cx);
3283 },
3284 )),
3285 )
3286 .render(cx),
3287 )
3288 .chain(contacts.into_iter().map(|contact| {
3277 let id = contact.user.id;3289 let id = contact.user.id;
3278 h_stack()3290 h_stack()
3279 .p_2()3291 .p_2()
@@ -3298,7 +3310,9 @@ impl CollabPanel { · 18 unmodified lines
3298 .log_err();3310 .log_err();
3299 }3311 }
3300 })3312 })
3301 }))3313 }));
3314
3315 List::new().children(children)
3302 }3316 }
3303}3317}
3304 3318
@@ -3354,10 +3368,12 @@ impl Render for CollabPanel { · 49 unmodified lines
3354 div()3368 div()
3355 .key_context("CollabPanel")3369 .key_context("CollabPanel")
3356 .track_focus(&self.focus_handle)3370 .track_focus(&self.focus_handle)
3357 .child(if self.user_store.read(cx).current_user().is_none() {3371 .map(|el| {
3358 self.render_signed_out(cx)3372 if self.user_store.read(cx).current_user().is_none() {
3359 } else {3373 el.child(self.render_signed_out(cx))
3360 self.render_signed_in(cx)3374 } else {
3375 el.child(self.render_signed_in(cx))
3376 }
3361 })3377 })
3362 }3378 }
3363}3379}
crates/ui2/src/components/list.rs+8−8
@@ -5,7 +5,8 @@ use smallvec::SmallVec; · 4 unmodified lines
5use std::rc::Rc;5use std::rc::Rc;
6 6
7use crate::{7use crate::{
8 disclosure_control, h_stack, v_stack, Avatar, Icon, IconElement, IconSize, Label, Toggle,8 disclosure_control, h_stack, v_stack, Avatar, Icon, IconButton, IconElement, IconSize, Label,
9 Toggle,
9};10};
10use crate::{prelude::*, GraphicSlot};11use crate::{prelude::*, GraphicSlot};
11 12
@@ -18,8 +19,7 @@ pub enum ListItemVariant { · 6 unmodified lines
18}19}
19 20
20pub enum ListHeaderMeta {21pub enum ListHeaderMeta {
21 // TODO: These should be IconButtons22 Tools(Vec<IconButton>),
22 Tools(Vec<Icon>),
23 // TODO: This should be a button23 // TODO: This should be a button
24 Button(Label),24 Button(Label),
25 Text(Label),25 Text(Label),
@@ -45,11 +45,7 @@ impl RenderOnce for ListHeader { · 19 unmodified lines
45 h_stack()45 h_stack()
46 .gap_2()46 .gap_2()
47 .items_center()47 .items_center()
48 .children(icons.into_iter().map(|i| {48 .children(icons.into_iter().map(|i| i.color(Color::Muted))),
49 IconElement::new(i)
50 .color(Color::Muted)
51 .size(IconSize::Small)
52 })),
53 ),49 ),
54 Some(ListHeaderMeta::Button(label)) => div().child(label),50 Some(ListHeaderMeta::Button(label)) => div().child(label),
55 Some(ListHeaderMeta::Text(label)) => div().child(label),51 Some(ListHeaderMeta::Text(label)) => div().child(label),
@@ -113,6 +109,10 @@ impl ListHeader { · 57 unmodified lines
113 self109 self
114 }110 }
115 111
112 pub fn right_button(self, button: IconButton) -> Self {
113 self.meta(Some(ListHeaderMeta::Tools(vec![button])))
114 }
115
116 pub fn meta(mut self, meta: Option<ListHeaderMeta>) -> Self {116 pub fn meta(mut self, meta: Option<ListHeaderMeta>) -> Self {
117 self.meta = meta;117 self.meta = meta;
118 self118 self

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t