From ea00a000281387df8962ab45114a0fb01dac707b Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Thu, 15 Sep 2022 15:56:51 +0200 Subject: [PATCH] Start showing a filter query in contacts popover --- .../src/contacts_popover.rs | 62 +++++++++++++++++-- 1 file changed, 58 insertions(+), 4 deletions(-) diff --git a/crates/contacts_status_item/src/contacts_popover.rs b/crates/contacts_status_item/src/contacts_popover.rs index cd0e361f5b..2998d74ed8 100644 --- a/crates/contacts_status_item/src/contacts_popover.rs +++ b/crates/contacts_status_item/src/contacts_popover.rs @@ -1,11 +1,14 @@ -use gpui::{elements::*, Entity, RenderContext, View, ViewContext}; +use editor::Editor; +use gpui::{elements::*, Entity, RenderContext, View, ViewContext, ViewHandle}; use settings::Settings; pub enum Event { Deactivated, } -pub struct ContactsPopover; +pub struct ContactsPopover { + filter_editor: ViewHandle, +} impl Entity for ContactsPopover { type Event = Event; @@ -18,9 +21,50 @@ impl View for ContactsPopover { fn render(&mut self, cx: &mut RenderContext) -> ElementBox { let theme = &cx.global::().theme.contacts_popover; - Empty::new() + + Flex::row() + .with_child( + ChildView::new(self.filter_editor.clone()) + .contained() + .with_style( + cx.global::() + .theme + .contacts_panel + .user_query_editor + .container, + ) + .flex(1., true) + .boxed(), + ) + // .with_child( + // MouseEventHandler::::new(0, cx, |_, _| { + // Svg::new("icons/user_plus_16.svg") + // .with_color(theme.add_contact_button.color) + // .constrained() + // .with_height(16.) + // .contained() + // .with_style(theme.add_contact_button.container) + // .aligned() + // .boxed() + // }) + // .with_cursor_style(CursorStyle::PointingHand) + // .on_click(MouseButton::Left, |_, cx| { + // cx.dispatch_action(contact_finder::Toggle) + // }) + // .boxed(), + // ) + .constrained() + .with_height( + cx.global::() + .theme + .contacts_panel + .user_query_editor_height, + ) + .aligned() + .top() .contained() .with_background_color(theme.background) + .with_uniform_padding(4.) .boxed() } } @@ -29,7 +73,17 @@ impl ContactsPopover { pub fn new(cx: &mut ViewContext) -> Self { cx.observe_window_activation(Self::window_activation_changed) .detach(); - Self + + let filter_editor = cx.add_view(|cx| { + let mut editor = Editor::single_line( + Some(|theme| theme.contacts_panel.user_query_editor.clone()), + cx, + ); + editor.set_placeholder_text("Filter contacts", cx); + editor + }); + + Self { filter_editor } } fn window_activation_changed(&mut self, is_active: bool, cx: &mut ViewContext) {