feat: add contact-based chat creation and re-add chat screening #54
+31
-35
@@ -84,40 +84,36 @@ impl RenderOnce for Nav {
|
|||||||
fn render(self, _window: &mut Window, cx: &mut App) -> impl IntoElement {
|
fn render(self, _window: &mut Window, cx: &mut App) -> impl IntoElement {
|
||||||
let clickable = self.on_click.is_some();
|
let clickable = self.on_click.is_some();
|
||||||
|
|
||||||
v_flex()
|
v_flex().w_full().h_10().child(
|
||||||
.id(format!("nav-{}", self.id))
|
h_flex()
|
||||||
.w_full()
|
.id(self.id)
|
||||||
.h_10()
|
.h_9()
|
||||||
.child(
|
.w_full()
|
||||||
h_flex()
|
.px_1p5()
|
||||||
.id(self.id)
|
.gap_1p5()
|
||||||
.h_9()
|
.rounded(cx.theme().radius_lg)
|
||||||
.w_full()
|
.when_some(self.prefix, |this, prefix| this.child(prefix))
|
||||||
.px_1p5()
|
.child(
|
||||||
.gap_1p5()
|
h_flex()
|
||||||
.rounded(cx.theme().radius_lg)
|
.gap_1()
|
||||||
.when_some(self.prefix, |this, prefix| this.child(prefix))
|
.flex_1()
|
||||||
.child(
|
.min_w_0()
|
||||||
h_flex()
|
.child(div().flex_1().min_w_0().truncate().child(self.label))
|
||||||
.gap_1()
|
.when_some(self.suffix, |this, suffix| {
|
||||||
.flex_1()
|
this.child(div().flex_shrink_0().child(suffix))
|
||||||
.min_w_0()
|
}),
|
||||||
.child(div().flex_1().min_w_0().truncate().child(self.label))
|
)
|
||||||
.when_some(self.suffix, |this, suffix| {
|
.when(clickable, |this| {
|
||||||
this.child(div().flex_shrink_0().child(suffix))
|
this.cursor_pointer()
|
||||||
}),
|
.hover(|this| this.bg(cx.theme().ghost_element_hover))
|
||||||
)
|
.when(self.selected, |this| {
|
||||||
.when(clickable, |this| {
|
this.bg(cx.theme().ghost_element_active)
|
||||||
this.cursor_pointer()
|
})
|
||||||
.hover(|this| this.bg(cx.theme().ghost_element_hover))
|
})
|
||||||
.when(self.selected, |this| {
|
.when_some(self.on_click, |this, handler| {
|
||||||
this.bg(cx.theme().ghost_element_active)
|
this.on_click(move |event, window, cx| handler(event, window, cx))
|
||||||
})
|
})
|
||||||
})
|
.refine_style(&self.style),
|
||||||
.when_some(self.on_click, |this, handler| {
|
)
|
||||||
this.on_click(move |event, window, cx| handler(event, window, cx))
|
|
||||||
})
|
|
||||||
.refine_style(&self.style),
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -345,7 +345,7 @@ impl NewChat {
|
|||||||
let profile = persons.read(cx).get(public_key, cx);
|
let profile = persons.read(cx).get(public_key, cx);
|
||||||
let public_key = *public_key;
|
let public_key = *public_key;
|
||||||
|
|
||||||
Nav::new(SharedString::from(format!("contact-{}", start + offset)))
|
Nav::new(start + offset)
|
||||||
.label(profile.name())
|
.label(profile.name())
|
||||||
.text_sm()
|
.text_sm()
|
||||||
.when(!AppSettings::get_hide_avatar(cx), |this| {
|
.when(!AppSettings::get_hide_avatar(cx), |this| {
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ use chat::{ChatRegistry, Room, RoomKind};
|
|||||||
use common::DebouncedDelay;
|
use common::DebouncedDelay;
|
||||||
use gpui::prelude::FluentBuilder;
|
use gpui::prelude::FluentBuilder;
|
||||||
use gpui::{
|
use gpui::{
|
||||||
AnyElement, App, AppContext, Context, ElementId, Entity, EventEmitter, FocusHandle, Focusable,
|
AnyElement, App, AppContext, Context, Entity, EventEmitter, FocusHandle, Focusable,
|
||||||
IntoElement, ParentElement, Render, SharedString, Styled, Subscription, Task, WeakEntity,
|
IntoElement, ParentElement, Render, SharedString, Styled, Subscription, Task, WeakEntity,
|
||||||
Window, div, uniform_list,
|
Window, div, uniform_list,
|
||||||
};
|
};
|
||||||
@@ -359,24 +359,21 @@ impl SearchPanel {
|
|||||||
this.select(&pkey_clone, cx);
|
this.select(&pkey_clone, cx);
|
||||||
});
|
});
|
||||||
|
|
||||||
Nav::new(ElementId::NamedInteger(
|
Nav::new(range.start + ix)
|
||||||
"search-result".into(),
|
.label(profile.name())
|
||||||
(range.start + ix) as u64,
|
.text_sm()
|
||||||
))
|
.font_medium()
|
||||||
.label(profile.name())
|
.when(!hide_avatar, |this| {
|
||||||
.text_sm()
|
this.prefix(
|
||||||
.font_medium()
|
Avatar::from_source(profile.avatar())
|
||||||
.when(!hide_avatar, |this| {
|
.seed(profile.avatar_seed())
|
||||||
this.prefix(
|
.small()
|
||||||
Avatar::from_source(profile.avatar())
|
.flex_shrink_0(),
|
||||||
.seed(profile.avatar_seed())
|
)
|
||||||
.small()
|
})
|
||||||
.flex_shrink_0(),
|
.on_click(handler)
|
||||||
)
|
.selected(selected)
|
||||||
})
|
.into_any_element()
|
||||||
.on_click(handler)
|
|
||||||
.selected(selected)
|
|
||||||
.into_any_element()
|
|
||||||
})
|
})
|
||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
@@ -409,24 +406,21 @@ impl SearchPanel {
|
|||||||
this.select(&pkey_clone, cx);
|
this.select(&pkey_clone, cx);
|
||||||
});
|
});
|
||||||
|
|
||||||
Nav::new(ElementId::NamedInteger(
|
Nav::new(range.start + ix)
|
||||||
"contact".into(),
|
.label(profile.name().trim())
|
||||||
(range.start + ix) as u64,
|
.text_sm()
|
||||||
))
|
.font_medium()
|
||||||
.label(profile.name().trim())
|
.when(!hide_avatar, |this| {
|
||||||
.text_sm()
|
this.prefix(
|
||||||
.font_medium()
|
Avatar::from_source(profile.avatar())
|
||||||
.when(!hide_avatar, |this| {
|
.seed(profile.avatar_seed())
|
||||||
this.prefix(
|
.small()
|
||||||
Avatar::from_source(profile.avatar())
|
.flex_shrink_0(),
|
||||||
.seed(profile.avatar_seed())
|
)
|
||||||
.small()
|
})
|
||||||
.flex_shrink_0(),
|
.on_click(handler)
|
||||||
)
|
.selected(selected)
|
||||||
})
|
.into_any_element()
|
||||||
.on_click(handler)
|
|
||||||
.selected(selected)
|
|
||||||
.into_any_element()
|
|
||||||
})
|
})
|
||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -853,7 +853,7 @@ impl Sidebar {
|
|||||||
let dock = self.dock.clone();
|
let dock = self.dock.clone();
|
||||||
let room = room.clone();
|
let room = room.clone();
|
||||||
|
|
||||||
Nav::new(SharedString::from(format!("room-{index}")))
|
Nav::new(index)
|
||||||
.label(name)
|
.label(name)
|
||||||
.text_sm()
|
.text_sm()
|
||||||
.font_medium()
|
.font_medium()
|
||||||
@@ -907,7 +907,7 @@ impl Sidebar {
|
|||||||
let sidebar = cx.entity().downgrade();
|
let sidebar = cx.entity().downgrade();
|
||||||
let public_key = public_key.to_owned();
|
let public_key = public_key.to_owned();
|
||||||
|
|
||||||
Nav::new(SharedString::from(format!("contact-{index}")))
|
Nav::new(index)
|
||||||
.label(person.name())
|
.label(person.name())
|
||||||
.text_sm()
|
.text_sm()
|
||||||
.font_medium()
|
.font_medium()
|
||||||
@@ -937,7 +937,7 @@ impl Sidebar {
|
|||||||
let sidebar = cx.entity().downgrade();
|
let sidebar = cx.entity().downgrade();
|
||||||
let community = community.clone();
|
let community = community.clone();
|
||||||
|
|
||||||
Nav::new(SharedString::from(format!("com-{index}")))
|
Nav::new(index)
|
||||||
.label(name)
|
.label(name)
|
||||||
.text_sm()
|
.text_sm()
|
||||||
.when(!hide_avatar, |this| {
|
.when(!hide_avatar, |this| {
|
||||||
|
|||||||
Reference in New Issue
Block a user