update ui

This commit is contained in:
2026-10-30 12:51:05 +07:00
parent 6ce20927ee
commit 905a339e3e
7 changed files with 56 additions and 73 deletions
+26 -2
View File
@@ -597,13 +597,14 @@ pub fn react_menu(
})
}
/// A hovered message's action bar: quick reactions, reply, copy, and an overflow menu.
/// A hovered message's action bar: quick reactions, reply, copy, read aloud, and an overflow menu.
#[derive(IntoElement)]
pub struct MessageActions {
style: StyleRefinement,
reactions: SmallVec<[(&'static str, SharedClickListener); 4]>,
reply: Option<SharedClickListener>,
copy: Option<(ElementId, SharedString)>,
speech: Option<SharedClickListener>,
dropdown: Option<DropdownBuilder>,
}
@@ -615,6 +616,7 @@ impl MessageActions {
reactions: SmallVec::new(),
reply: None,
copy: None,
speech: None,
dropdown: None,
}
}
@@ -642,6 +644,15 @@ impl MessageActions {
self
}
/// Add the read-aloud button.
pub fn speech(
mut self,
handler: impl Fn(&ClickEvent, &mut Window, &mut App) + 'static,
) -> Self {
self.speech = Some(Rc::new(handler));
self
}
/// Fill the bar's overflow menu.
pub fn dropdown(
mut self,
@@ -671,10 +682,13 @@ impl RenderOnce for MessageActions {
reactions,
reply,
copy,
speech,
dropdown,
} = self;
let has_center = reply.is_some() || copy.is_some();
// The leading separator only separates reactions from the center buttons
let has_center =
!reactions.is_empty() && (reply.is_some() || copy.is_some() || speech.is_some());
h_flex()
.p_0p5()
@@ -712,6 +726,16 @@ impl RenderOnce for MessageActions {
.when_some(copy, |this, (id, value)| {
this.child(Clipboard::new(id).value(value).tooltip("Copy").small())
})
.when_some(speech, |this, speech| {
this.child(
Button::new("speech")
.icon(crate::IconName::Speech)
.tooltip("Read aloud")
.small()
.ghost()
.on_click(move |event, window, cx| speech(event, window, cx)),
)
})
.when_some(dropdown, |this, dropdown| {
this.child(div().flex_shrink_0().h_4().w_px().bg(cx.theme().border))
.child(