| @@ -155,19 +155,19 @@ actions!( · 154 unmodified lines |
| 155 | 155 | |
| 156 | 156 | const COLLABORATION_PANEL_KEY: &'static str = "CollaborationPanel"; |
| 157 | 157 | |
| 158 | | −use std::sync::Arc; |
| 158 | +use std::{iter::once, sync::Arc}; |
| 159 | 159 | |
| 160 | 160 | use client::{Client, Contact, UserStore}; |
| 161 | 161 | use db::kvp::KEY_VALUE_STORE; |
| 162 | 162 | use gpui::{ |
| 163 | 163 | 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, |
| 166 | 166 | }; |
| 167 | 167 | use project::Fs; |
| 168 | 168 | use serde_derive::{Deserialize, Serialize}; |
| 169 | 169 | 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}; |
| 171 | 171 | use util::ResultExt; |
| 172 | 172 | use workspace::{ |
| 173 | 173 | dock::{DockPosition, Panel, PanelEvent}, |
| @@ -309,7 +309,7 @@ pub struct CollabPanel { · 135 unmodified lines |
| 309 | 309 | // match_candidates: Vec<StringMatchCandidate>, |
| 310 | 310 | // list_state: ListState<Self>, |
| 311 | 311 | // subscriptions: Vec<Subscription>, |
| 312 | | − // collapsed_sections: Vec<Section>, |
| 312 | + collapsed_sections: Vec<Section>, |
| 313 | 313 | // collapsed_channels: Vec<ChannelId>, |
| 314 | 314 | // drag_target_channel: ChannelDragTarget, |
| 315 | 315 | workspace: WeakView<Workspace>, |
| @@ -336,16 +336,16 @@ struct SerializedCollabPanel { · 20 unmodified lines |
| 336 | 336 | // Dismissed, |
| 337 | 337 | // } |
| 338 | 338 | |
| 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 | +} |
| 349 | 349 | |
| 350 | 350 | // #[derive(Clone, Debug)] |
| 351 | 351 | // enum ListEntry { |
| @@ -603,7 +603,7 @@ impl CollabPanel { · 251 unmodified lines |
| 603 | 603 | // project: workspace.project().clone(), |
| 604 | 604 | // subscriptions: Vec::default(), |
| 605 | 605 | // match_candidates: Vec::default(), |
| 606 | | − // collapsed_sections: vec![Section::Offline], |
| 606 | + collapsed_sections: vec![Section::Offline], |
| 607 | 607 | // collapsed_channels: Vec::default(), |
| 608 | 608 | workspace: workspace.weak_handle(), |
| 609 | 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 | 3273 | let contacts = self.contacts(cx).unwrap_or_default(); |
| 3274 | 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 | 3289 | let id = contact.user.id; |
| 3278 | 3290 | h_stack() |
| 3279 | 3291 | .p_2() |
| @@ -3298,7 +3310,9 @@ impl CollabPanel { · 18 unmodified lines |
| 3298 | 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 | 3368 | div() |
| 3355 | 3369 | .key_context("CollabPanel") |
| 3356 | 3370 | .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 | + } |
| 3361 | 3377 | }) |
| 3362 | 3378 | } |
| 3363 | 3379 | } |