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
155155
156156 const COLLABORATION_PANEL_KEY: &'static str = "CollaborationPanel";
157157
158−use std::sync::Arc;
158+use std::{iter::once, sync::Arc};
159159
160160 use client::{Client, Contact, UserStore};
161161 use db::kvp::KEY_VALUE_STORE;
162162 use gpui::{
163163 actions, div, serde_json, AppContext, AsyncWindowContext, Div, EventEmitter, FocusHandle,
164− Focusable, FocusableView, InteractiveElement, Model, ParentElement, Render, Styled, View,
165− ViewContext, VisualContext, WeakView,
164+ Focusable, FocusableView, InteractiveElement, IntoElement, Model, ParentElement, Render,
165+ RenderOnce, Styled, View, ViewContext, VisualContext, WeakView,
166166 };
167167 use project::Fs;
168168 use serde_derive::{Deserialize, Serialize};
169169 use settings::Settings;
170−use ui::{h_stack, v_stack, Avatar, Button, Label};
170+use ui::{h_stack, v_stack, Avatar, Button, Icon, IconButton, Label, List, ListHeader};
171171 use util::ResultExt;
172172 use workspace::{
173173 dock::{DockPosition, Panel, PanelEvent},
@@ -309,7 +309,7 @@ pub struct CollabPanel { · 135 unmodified lines
309309 // match_candidates: Vec<StringMatchCandidate>,
310310 // list_state: ListState<Self>,
311311 // subscriptions: Vec<Subscription>,
312− // collapsed_sections: Vec<Section>,
312+ collapsed_sections: Vec<Section>,
313313 // collapsed_channels: Vec<ChannelId>,
314314 // drag_target_channel: ChannelDragTarget,
315315 workspace: WeakView<Workspace>,
@@ -336,16 +336,16 @@ struct SerializedCollabPanel { · 20 unmodified lines
336336 // Dismissed,
337337 // }
338338
339−// #[derive(Clone, Copy, PartialEq, Eq, Debug, PartialOrd, Ord)]
340−// enum Section {
341−// ActiveCall,
342−// Channels,
343−// ChannelInvites,
344−// ContactRequests,
345−// Contacts,
346−// Online,
347−// Offline,
348−// }
339+#[derive(Clone, Copy, PartialEq, Eq, Debug, PartialOrd, Ord)]
340+enum Section {
341+ // ActiveCall,
342+ // Channels,
343+ // ChannelInvites,
344+ // ContactRequests,
345+ Contacts,
346+ // Online,
347+ Offline,
348+}
349349
350350 // #[derive(Clone, Debug)]
351351 // enum ListEntry {
@@ -603,7 +603,7 @@ impl CollabPanel { · 251 unmodified lines
603603 // project: workspace.project().clone(),
604604 // subscriptions: Vec::default(),
605605 // match_candidates: Vec::default(),
606− // collapsed_sections: vec![Section::Offline],
606+ collapsed_sections: vec![Section::Offline],
607607 // collapsed_channels: Vec::default(),
608608 workspace: workspace.weak_handle(),
609609 client: workspace.app_state().client.clone(),
@@ -3269,11 +3269,23 @@ impl CollabPanel { · 2659 unmodified lines
32693269 )))
32703270 }
32713271
3272− fn render_signed_in(&mut self, cx: &mut ViewContext<Self>) -> Div {
3272+ fn render_signed_in(&mut self, cx: &mut ViewContext<Self>) -> List {
32733273 let contacts = self.contacts(cx).unwrap_or_default();
32743274 let workspace = self.workspace.clone();
32753275
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| {
32773289 let id = contact.user.id;
32783290 h_stack()
32793291 .p_2()
@@ -3298,7 +3310,9 @@ impl CollabPanel { · 18 unmodified lines
32983310 .log_err();
32993311 }
33003312 })
3301− }))
3313+ }));
3314+
3315+ List::new().children(children)
33023316 }
33033317 }
33043318
@@ -3354,10 +3368,12 @@ impl Render for CollabPanel { · 49 unmodified lines
33543368 div()
33553369 .key_context("CollabPanel")
33563370 .track_focus(&self.focus_handle)
3357− .child(if self.user_store.read(cx).current_user().is_none() {
3358− self.render_signed_out(cx)
3359− } else {
3360− self.render_signed_in(cx)
3371+ .map(|el| {
3372+ if self.user_store.read(cx).current_user().is_none() {
3373+ el.child(self.render_signed_out(cx))
3374+ } else {
3375+ el.child(self.render_signed_in(cx))
3376+ }
33613377 })
33623378 }
33633379 }
crates/ui2/src/components/list.rs+8−8
@@ -5,7 +5,8 @@ use smallvec::SmallVec; · 4 unmodified lines
55 use std::rc::Rc;
66
77 use 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,
910 };
1011 use crate::{prelude::*, GraphicSlot};
1112
@@ -18,8 +19,7 @@ pub enum ListItemVariant { · 6 unmodified lines
1819 }
1920
2021 pub enum ListHeaderMeta {
21− // TODO: These should be IconButtons
22− Tools(Vec<Icon>),
22+ Tools(Vec<IconButton>),
2323 // TODO: This should be a button
2424 Button(Label),
2525 Text(Label),
@@ -45,11 +45,7 @@ impl RenderOnce for ListHeader { · 19 unmodified lines
4545 h_stack()
4646 .gap_2()
4747 .items_center()
48− .children(icons.into_iter().map(|i| {
49− IconElement::new(i)
50− .color(Color::Muted)
51− .size(IconSize::Small)
52− })),
48+ .children(icons.into_iter().map(|i| i.color(Color::Muted))),
5349 ),
5450 Some(ListHeaderMeta::Button(label)) => div().child(label),
5551 Some(ListHeaderMeta::Text(label)) => div().child(label),
@@ -113,6 +109,10 @@ impl ListHeader { · 57 unmodified lines
113109 self
114110 }
115111
112+ pub fn right_button(self, button: IconButton) -> Self {
113+ self.meta(Some(ListHeaderMeta::Tools(vec![button])))
114+ }
115+
116116 pub fn meta(mut self, meta: Option<ListHeaderMeta>) -> Self {
117117 self.meta = meta;
118118 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