assistant2: Adjust thread history list item visuals (#21998)
Most notably, adding the `outlined` property in the `ListItem` component. <img width="800" alt="Screenshot 2024-12-13 at 20 35 39" src="https://github.com/user-attachments/assets/adac4463-66f9-4b5e-b1c0-93c34f068dc4" /> Release Notes: - N/A
This commit is contained in:
parent
426f94b310
commit
ec741d61ed
3 changed files with 30 additions and 8 deletions
|
@ -323,10 +323,11 @@ impl AssistantPanel {
|
||||||
.when(!recent_threads.is_empty(), |parent| {
|
.when(!recent_threads.is_empty(), |parent| {
|
||||||
parent
|
parent
|
||||||
.child(
|
.child(
|
||||||
h_flex()
|
h_flex().w_full().justify_center().child(
|
||||||
.w_full()
|
Label::new("Recent Threads:")
|
||||||
.justify_center()
|
.size(LabelSize::Small)
|
||||||
.child(Label::new("Recent Threads:").size(LabelSize::Small)),
|
.color(Color::Muted),
|
||||||
|
),
|
||||||
)
|
)
|
||||||
.child(
|
.child(
|
||||||
v_flex().gap_2().children(
|
v_flex().gap_2().children(
|
||||||
|
|
|
@ -2,7 +2,7 @@ use gpui::{
|
||||||
uniform_list, AppContext, FocusHandle, FocusableView, Model, UniformListScrollHandle, WeakView,
|
uniform_list, AppContext, FocusHandle, FocusableView, Model, UniformListScrollHandle, WeakView,
|
||||||
};
|
};
|
||||||
use time::{OffsetDateTime, UtcOffset};
|
use time::{OffsetDateTime, UtcOffset};
|
||||||
use ui::{prelude::*, IconButtonShape, ListItem};
|
use ui::{prelude::*, IconButtonShape, ListItem, ListItemSpacing, Tooltip};
|
||||||
|
|
||||||
use crate::thread::Thread;
|
use crate::thread::Thread;
|
||||||
use crate::thread_store::ThreadStore;
|
use crate::thread_store::ThreadStore;
|
||||||
|
@ -117,17 +117,25 @@ impl RenderOnce for PastThread {
|
||||||
.unwrap_or(UtcOffset::UTC),
|
.unwrap_or(UtcOffset::UTC),
|
||||||
time_format::TimestampFormat::EnhancedAbsolute,
|
time_format::TimestampFormat::EnhancedAbsolute,
|
||||||
);
|
);
|
||||||
|
|
||||||
ListItem::new(("past-thread", self.thread.entity_id()))
|
ListItem::new(("past-thread", self.thread.entity_id()))
|
||||||
|
.outlined()
|
||||||
.start_slot(Icon::new(IconName::MessageBubbles))
|
.start_slot(Icon::new(IconName::MessageBubbles))
|
||||||
.child(Label::new(summary))
|
.spacing(ListItemSpacing::Sparse)
|
||||||
|
.child(Label::new(summary).size(LabelSize::Small))
|
||||||
.end_slot(
|
.end_slot(
|
||||||
h_flex()
|
h_flex()
|
||||||
.gap_2()
|
.gap_2()
|
||||||
.child(Label::new(thread_timestamp).color(Color::Disabled))
|
.child(
|
||||||
|
Label::new(thread_timestamp)
|
||||||
|
.color(Color::Disabled)
|
||||||
|
.size(LabelSize::Small),
|
||||||
|
)
|
||||||
.child(
|
.child(
|
||||||
IconButton::new("delete", IconName::TrashAlt)
|
IconButton::new("delete", IconName::TrashAlt)
|
||||||
.shape(IconButtonShape::Square)
|
.shape(IconButtonShape::Square)
|
||||||
.icon_size(IconSize::Small)
|
.icon_size(IconSize::Small)
|
||||||
|
.tooltip(|cx| Tooltip::text("Delete Thread", cx))
|
||||||
.on_click({
|
.on_click({
|
||||||
let assistant_panel = self.assistant_panel.clone();
|
let assistant_panel = self.assistant_panel.clone();
|
||||||
let id = id.clone();
|
let id = id.clone();
|
||||||
|
|
|
@ -38,6 +38,7 @@ pub struct ListItem {
|
||||||
on_secondary_mouse_down: Option<Box<dyn Fn(&MouseDownEvent, &mut WindowContext) + 'static>>,
|
on_secondary_mouse_down: Option<Box<dyn Fn(&MouseDownEvent, &mut WindowContext) + 'static>>,
|
||||||
children: SmallVec<[AnyElement; 2]>,
|
children: SmallVec<[AnyElement; 2]>,
|
||||||
selectable: bool,
|
selectable: bool,
|
||||||
|
outlined: bool,
|
||||||
overflow_x: bool,
|
overflow_x: bool,
|
||||||
focused: Option<bool>,
|
focused: Option<bool>,
|
||||||
}
|
}
|
||||||
|
@ -62,6 +63,7 @@ impl ListItem {
|
||||||
tooltip: None,
|
tooltip: None,
|
||||||
children: SmallVec::new(),
|
children: SmallVec::new(),
|
||||||
selectable: true,
|
selectable: true,
|
||||||
|
outlined: false,
|
||||||
overflow_x: false,
|
overflow_x: false,
|
||||||
focused: None,
|
focused: None,
|
||||||
}
|
}
|
||||||
|
@ -138,6 +140,11 @@ impl ListItem {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn outlined(mut self) -> Self {
|
||||||
|
self.outlined = true;
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
pub fn overflow_x(mut self) -> Self {
|
pub fn overflow_x(mut self) -> Self {
|
||||||
self.overflow_x = true;
|
self.overflow_x = true;
|
||||||
self
|
self
|
||||||
|
@ -203,6 +210,7 @@ impl RenderOnce for ListItem {
|
||||||
.child(
|
.child(
|
||||||
h_flex()
|
h_flex()
|
||||||
.id("inner_list_item")
|
.id("inner_list_item")
|
||||||
|
.group("list_item")
|
||||||
.w_full()
|
.w_full()
|
||||||
.relative()
|
.relative()
|
||||||
.items_center()
|
.items_center()
|
||||||
|
@ -212,7 +220,6 @@ impl RenderOnce for ListItem {
|
||||||
ListItemSpacing::Dense => this,
|
ListItemSpacing::Dense => this,
|
||||||
ListItemSpacing::Sparse => this.py_1(),
|
ListItemSpacing::Sparse => this.py_1(),
|
||||||
})
|
})
|
||||||
.group("list_item")
|
|
||||||
.when(self.inset && !self.disabled, |this| {
|
.when(self.inset && !self.disabled, |this| {
|
||||||
this
|
this
|
||||||
// TODO: Add focus state
|
// TODO: Add focus state
|
||||||
|
@ -238,6 +245,12 @@ impl RenderOnce for ListItem {
|
||||||
.when_some(self.on_click, |this, on_click| {
|
.when_some(self.on_click, |this, on_click| {
|
||||||
this.cursor_pointer().on_click(on_click)
|
this.cursor_pointer().on_click(on_click)
|
||||||
})
|
})
|
||||||
|
.when(self.outlined, |this| {
|
||||||
|
this.border_1()
|
||||||
|
.border_color(cx.theme().colors().border)
|
||||||
|
.rounded_md()
|
||||||
|
.overflow_hidden()
|
||||||
|
})
|
||||||
.when_some(self.on_secondary_mouse_down, |this, on_mouse_down| {
|
.when_some(self.on_secondary_mouse_down, |this, on_mouse_down| {
|
||||||
this.on_mouse_down(MouseButton::Right, move |event, cx| {
|
this.on_mouse_down(MouseButton::Right, move |event, cx| {
|
||||||
(on_mouse_down)(event, cx)
|
(on_mouse_down)(event, cx)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue