Add an x mark icon to the list of contacts

Petros Amoiridis and Antonio Scandurra created

We want to be able to remove contacts from our list. This was not possible. This change add an icon and dispatches the RemoveContact action.

Co-Authored-By: Antonio Scandurra <me@as-cii.com>

Change summary

crates/collab_ui/src/contact_list.rs | 23 ++++++++++++++++++++++-
1 file changed, 22 insertions(+), 1 deletion(-)

Detailed changes

crates/collab_ui/src/contact_list.rs 🔗

@@ -1051,7 +1051,7 @@ impl ContactList {
         let user_id = contact.user.id;
         let initial_project = project.clone();
         let mut element =
-            MouseEventHandler::<Contact>::new(contact.user.id as usize, cx, |_, _| {
+            MouseEventHandler::<Contact>::new(contact.user.id as usize, cx, |_, cx| {
                 Flex::row()
                     .with_children(contact.user.avatar.clone().map(|avatar| {
                         let status_badge = if contact.online {
@@ -1093,6 +1093,27 @@ impl ContactList {
                         .flex(1., true)
                         .boxed(),
                     )
+                    .with_child(
+                        MouseEventHandler::<Cancel>::new(
+                            contact.user.id as usize,
+                            cx,
+                            |mouse_state, _| {
+                                let button_style =
+                                    theme.contact_button.style_for(mouse_state, false);
+                                render_icon_button(button_style, "icons/x_mark_8.svg")
+                                    .aligned()
+                                    .flex_float()
+                                    .boxed()
+                            },
+                        )
+                        .with_padding(Padding::uniform(2.))
+                        .with_cursor_style(CursorStyle::PointingHand)
+                        .on_click(MouseButton::Left, move |_, cx| {
+                            cx.dispatch_action(RemoveContact(user_id))
+                        })
+                        .flex_float()
+                        .boxed(),
+                    )
                     .with_children(if calling {
                         Some(
                             Label::new("Calling".to_string(), theme.calling_indicator.text.clone())