BlueGit

ict rusty-teams

Files

rusty-teams / crates / app / src / views / message_row.rs

message_row.rs

message_row.rs 23.4 KiB Download Raw
1use gpui_kit::assets::IconName;
2use gpui_kit::component::{Icon, h_flex, v_flex};
3use gpui_kit::prelude::FluentBuilder as _;
4use gpui_kit::*;
5use std::time::Duration;
6
7use super::adaptive_card::cards_view;
8use super::attachments::{FileActions, ImageActions, attachments_view, message_body};
9use super::avatar::{bot_avatar, person_avatar};
10use super::call_card::{CallActions, call_card_row};
11use super::jumbo_emoji::jumbo_row;
12use super::link_preview::{link_preview_card, meeting_join_chip};
13use super::message_actions::{MessageMenu, ReactionAdder, message_toolbar};
14use super::profile_card::opens_profile;
15use super::reaction_picker::PickHandler;
16use super::reaction_pills::{PillLook, ReactionControls, reaction_pills};
17use super::reaction_proposal_pill::{ReactionPill, reaction_pill};
18use super::scheduled_toolbar::{ScheduledMenu, scheduled_toolbar};
19use super::toolbar_placement::{HoverChange, TimelineBounds, placed_toolbar};
20use super::translation_line::{TranslationActions, translation_line};
21use super::widgets::{icon, symbol};
22use crate::agents::{AgentRun, run_chip};
23use crate::card_state::BotIdentity;
24use crate::data::Directory;
25use crate::render::Block;
26use crate::restorable_deletes::{DELETED_TOMBSTONE, UNDO_DELETE_LABEL};
27use crate::rows::{Delivery, MessageRow, Receipt, ScheduledState, Skeleton, bubble_corners};
28use crate::sidebar_model::DELETED_PREVIEW;
29use crate::theme;
30use app_ui_kit::layout::ROW_PADDING;
31
32pub type RowAction = Option<Box<dyn Fn(&mut App)>>;
33pub type SharedRowAction = Option<std::rc::Rc<dyn Fn(&mut App)>>;
34
35pub const BUBBLE_TAGS: [&str; 12] = [
36 "message-bubble/0",
37 "message-bubble/1",
38 "message-bubble/2",
39 "message-bubble/3",
40 "message-bubble/4",
41 "message-bubble/5",
42 "message-bubble/6",
43 "message-bubble/7",
44 "message-bubble/8",
45 "message-bubble/9",
46 "message-bubble/10",
47 "message-bubble/11",
48];
49pub(super) const AVATAR_SIZE: f32 = 28.;
50pub(super) const AVATAR_GAP: f32 = 8.;
51const SERIES_START_GAP: f32 = 8.;
52pub(super) const BODY_SIZE: f32 = 13.5;
53const MAX_WIDTH_RATIO: f32 = 0.7;
54const NARROW_BUBBLE_WIDTH: f32 = 300.;
55const BUBBLE_PADDING_Y: f32 = 8.;
56const META_BOTTOM_INSET: f32 = 4.;
57const META_SIZE: f32 = 11.;
58const META_CHECK_SIZE: f32 = 15.;
59const SAVED_MARK_SIZE: f32 = 12.;
60const FORWARDED_SIZE: f32 = 11.;
61const FIGURE_SPACE_WIDTH: f32 = 7.4;
62const PULSE_PERIOD: Duration = Duration::from_millis(1600);
63const RECEIPT_FADE_PERIOD: Duration = Duration::from_millis(600);
64const SKELETON_LINE_HEIGHT: f32 = 20.;
65
66pub struct DeliveryActions {
67 pub retry: RowAction,
68 pub delete: RowAction,
69 pub send_now: RowAction,
70}
71
72pub struct RowActions {
73 pub bot: Option<BotIdentity>,
74 pub delivery: DeliveryActions,
75 pub reply: RowAction,
76 pub hovered: Option<HoverChange>,
77 pub menu: Option<MessageMenu>,
78 pub scheduled_menu: Option<ScheduledMenu>,
79 pub react: Option<PickHandler>,
80 pub reaction_controls: Option<ReactionControls>,
81 pub add_reaction: Option<ReactionAdder>,
82 pub files: Option<FileActions>,
83 pub open_image: Option<ImageActions>,
84 pub highlighted: bool,
85 pub saved: bool,
86 pub pinned: bool,
87 pub translation: Option<TranslationActions>,
88 pub timeline: TimelineBounds,
89 pub agent_run: Option<AgentRun>,
90 pub call: CallActions,
91 pub reaction_proposal: Option<ReactionPill>,
92 pub undo_delete: SharedRowAction,
93}
94
95const TOOLBAR_RIGHT_INSET: f32 = 0.;
96
97fn separator_pill(label: &str, fill: Hsla, text_color: Hsla) -> Div {
98 h_flex()
99 .w_full()
100 .justify_center()
101 .mt(px(12.))
102 .mb(px(6.))
103 .child(
104 div()
105 .h(px(24.))
106 .px(px(8.))
107 .flex()
108 .items_center()
109 .rounded(px(12.))
110 .bg(fill)
111 .text_size(px(11.))
112 .text_color(text_color)
113 .child(label.to_owned()),
114 )
115}
116
117pub(super) fn day_separator(label: &str) -> Div {
118 separator_pill(label, theme::row_hover(), theme::text_muted())
119}
120
121pub(super) fn new_marker() -> Div {
122 separator_pill(
123 "New",
124 theme::mention_background(false),
125 theme::accent_text(),
126 )
127}
128
129pub(super) fn deleted_tombstone(index: usize, undo_delete: SharedRowAction) -> Div {
130 let line =
131 h_flex()
132 .gap(px(8.))
133 .items_baseline()
134 .text_size(px(13.))
135 .child(div().italic().text_color(theme::text_muted()).child(
136 if undo_delete.is_some() {
137 DELETED_TOMBSTONE
138 } else {
139 DELETED_PREVIEW
140 },
141 ));
142 match undo_delete {
143 Some(undo) => line.child(
144 div()
145 .id(ElementId::Name(format!("undo-delete-{index}").into()))
146 .cursor_pointer()
147 .font_weight(FontWeight::SEMIBOLD)
148 .text_color(theme::accent_text())
149 .hover(|link| link.underline())
150 .child(UNDO_DELETE_LABEL)
151 .on_click(move |_, _, cx| undo(cx)),
152 ),
153 None => line,
154 }
155}
156
157fn bubble_max_width(timeline: &TimelineBounds, reserved: f32) -> Length {
158 let Some(bounds) = timeline.get() else {
159 return relative(MAX_WIDTH_RATIO).into();
160 };
161 let row_width = (f32::from(bounds.size.width) - 2. * ROW_PADDING - reserved).max(0.);
162 px((row_width * MAX_WIDTH_RATIO).max(row_width.min(NARROW_BUBBLE_WIDTH))).into()
163}
164
165fn bubble(
166 row: &MessageRow,
167 index: usize,
168 own: bool,
169 directory: &Directory,
170 extras: BubbleExtras,
171 cx: &App,
172) -> Stateful<Div> {
173 let corners = bubble_corners(own, row.series);
174 let jumbo = row.jumbo.as_deref().filter(|_| {
175 !row.deleted && matches!(row.delivery, Delivery::Delivered | Delivery::Sending)
176 });
177 let mut element = div()
178 .id(ElementId::Name(format!("bubble-{index}").into()))
179 .when_some(extras.hover.clone(), |element, hover| {
180 element.on_hover(move |is_hovered, _, cx| hover(*is_hovered, cx))
181 })
182 .relative()
183 .max_w_full()
184 .when_some(BUBBLE_TAGS.get(index).copied(), |element, tag| {
185 element.debug_selector(|| tag.into())
186 })
187 .when(jumbo.is_none(), |element| {
188 element
189 .rounded_tl(px(corners.top_left))
190 .rounded_tr(px(corners.top_right))
191 .rounded_br(px(corners.bottom_right))
192 .rounded_bl(px(corners.bottom_left))
193 .px(px(12.))
194 .py(px(BUBBLE_PADDING_Y))
195 })
196 .text_size(px(BODY_SIZE))
197 .line_height(relative(1.45));
198 if row.deleted {
199 return element
200 .border_1()
201 .border_color(theme::border_strong())
202 .py(px(6.))
203 .child(deleted_tombstone(index, extras.undo_delete));
204 }
205 let failed = matches!(row.delivery, Delivery::Failed(_));
206 let scheduled = matches!(row.delivery, Delivery::Scheduled(_));
207 element = element
208 .when(!scheduled && jumbo.is_none(), |bubble| {
209 bubble.bg(if own && !failed {
210 theme::bubble_own()
211 } else {
212 theme::bubble_other()
213 })
214 })
215 .when(failed, |bubble| {
216 bubble.border_1().border_color(theme::red())
217 })
218 .when(scheduled, |bubble| {
219 bubble.border_1().border_color(
220 if row.delivery == Delivery::Scheduled(ScheduledState::DeliveryFailed) {
221 theme::red()
222 } else {
223 theme::accent()
224 },
225 )
226 });
227 let has_reactions = !row.reactions.is_empty();
228 let saved = extras.saved;
229 let mut content = v_flex().gap(px(6.));
230 if row.forwarded {
231 content = content.child(forwarded_header());
232 }
233 let attachments = attachments_view(
234 &row.blocks,
235 &row.images,
236 &row.local_images,
237 &row.files,
238 &format!("message-{index}"),
239 directory,
240 extras.files.as_ref(),
241 extras.open_image.as_ref(),
242 );
243 let cards = cards_view(&row.adaptive_cards, &row.conversation_id, &row.key, cx);
244 let trailing_content = attachments.is_some()
245 || row.meeting_link.is_some()
246 || row.link_preview.is_some()
247 || !cards.is_empty();
248 let padded_blocks = if has_reactions || trailing_content || jumbo.is_some() {
249 None
250 } else {
251 with_meta_room(&row.blocks, meta_room(row, own, saved))
252 };
253 let meta_inline = has_text(row) && padded_blocks.is_some();
254 if let Some(jumbo) = jumbo {
255 content = content.child(jumbo_row(&row.key, jumbo, own));
256 } else if has_text(row) {
257 content = content.children(message_body(
258 padded_blocks.as_deref().unwrap_or(&row.blocks),
259 &row.images,
260 &row.local_images,
261 &format!("message-{index}"),
262 own,
263 directory,
264 extras.open_image.as_ref(),
265 cx,
266 ));
267 }
268 content = content.children(attachments);
269 content = content.children(
270 row.meeting_link
271 .clone()
272 .map(|url| meeting_join_chip(format!("message-{index}-join"), url)),
273 );
274 content = content.children(row.link_preview.as_ref().map(|preview| {
275 link_preview_card(
276 preview,
277 format!("message-{index}-link"),
278 directory,
279 false,
280 None,
281 )
282 }));
283 content = content.children(cards);
284 if has_reactions {
285 content = content.child(
286 h_flex()
287 .gap(px(8.))
288 .items_end()
289 .child(
290 reaction_pills(
291 &row.reactions,
292 index,
293 own,
294 PillLook::Faces,
295 directory,
296 extras.react.clone(),
297 extras.controls.as_ref(),
298 )
299 .flex_auto(),
300 )
301 .child(
302 h_flex()
303 .flex_none()
304 .mb(px(META_BOTTOM_INSET - BUBBLE_PADDING_Y))
305 .child(bubble_meta(row, own, saved)),
306 ),
307 );
308 } else if !meta_inline {
309 content = content.child(h_flex().justify_end().child(bubble_meta(row, own, saved)));
310 }
311 element = element.child(content);
312 if meta_inline {
313 element = element.child(
314 div()
315 .absolute()
316 .right(px(8.))
317 .bottom(px(META_BOTTOM_INSET))
318 .child(bubble_meta(row, own, saved)),
319 );
320 }
321 if let Some(menu) = extras.menu {
322 element = element.child(placed_toolbar(
323 message_toolbar(menu, cx),
324 extras.timeline.clone(),
325 TOOLBAR_RIGHT_INSET,
326 ));
327 }
328 if let Some(menu) = extras.scheduled_menu {
329 element = element.child(placed_toolbar(
330 scheduled_toolbar(menu),
331 extras.timeline.clone(),
332 TOOLBAR_RIGHT_INSET,
333 ));
334 }
335 element
336}
337
338#[derive(Default)]
339struct BubbleExtras {
340 hover: Option<HoverChange>,
341 menu: Option<MessageMenu>,
342 scheduled_menu: Option<ScheduledMenu>,
343 react: Option<PickHandler>,
344 controls: Option<ReactionControls>,
345 files: Option<FileActions>,
346 open_image: Option<ImageActions>,
347 saved: bool,
348 translation: Option<TranslationActions>,
349 timeline: TimelineBounds,
350 agent_run: Option<AgentRun>,
351 reaction_proposal: Option<ReactionPill>,
352 undo_delete: SharedRowAction,
353}
354
355fn agent_chip(run: Option<AgentRun>) -> Option<Div> {
356 run.map(|run| div().py(px(2.)).child(run_chip(&run, theme::row_hover())))
357}
358
359pub(super) fn forwarded_header() -> Div {
360 h_flex()
361 .gap(px(4.))
362 .items_center()
363 .text_size(px(FORWARDED_SIZE))
364 .text_color(theme::text_muted())
365 .child(icon(IconName::Forward, FORWARDED_SIZE, theme::text_muted()))
366 .child("Forwarded")
367}
368
369fn bubble_meta(row: &MessageRow, own: bool, saved: bool) -> Div {
370 let tint = if own {
371 theme::own_meta()
372 } else {
373 theme::text_muted()
374 };
375 h_flex()
376 .gap(px(4.))
377 .items_center()
378 .text_size(px(META_SIZE))
379 .line_height(px(14.))
380 .italic()
381 .text_color(tint)
382 .when(row.edited, |meta| meta.child("Edited"))
383 .when(saved, |meta| {
384 meta.child(icon(
385 IconName::Bookmark,
386 SAVED_MARK_SIZE,
387 theme::accent_text(),
388 ))
389 })
390 .child(row.time.clone())
391 .when(own && row.delivery == Delivery::Sending, |meta| {
392 meta.child(symbol("schedule", META_CHECK_SIZE, tint))
393 })
394 .when(matches!(row.delivery, Delivery::Scheduled(_)), |meta| {
395 meta.child(symbol("schedule", META_SIZE + 3., tint))
396 })
397 .when(
398 own && row.delivery == Delivery::Delivered,
399 |meta| match row.receipt {
400 Receipt::Hidden => meta,
401 Receipt::Sent => meta.child(on_baseline(symbol("done", META_CHECK_SIZE, tint))),
402 Receipt::Read => meta.child(on_baseline(symbol(
403 "done_all",
404 META_CHECK_SIZE,
405 theme::own_read(),
406 ))),
407 Receipt::ReadLive => meta.child(receipt_fade_in(
408 &row.key,
409 on_baseline(symbol("done_all", META_CHECK_SIZE, theme::own_read())),
410 )),
411 },
412 )
413}
414
415fn on_baseline(check: Icon) -> Div {
416 div().relative().top(px(1.)).child(check)
417}
418
419fn pulse<E: IntoElement + Styled + 'static>(id: &'static str, element: E) -> AnimationElement<E> {
420 element.with_animation(
421 id,
422 Animation::new(PULSE_PERIOD)
423 .repeat_synced()
424 .with_easing(pulsating_between(0.35, 1.)),
425 |element, opacity| element.opacity(opacity),
426 )
427}
428
429fn receipt_fade_in(message_key: &str, check: Div) -> AnimationElement<Div> {
430 check.with_animation(
431 SharedString::from(format!("receipt-fade/{message_key}")),
432 Animation::new(RECEIPT_FADE_PERIOD).with_easing(ease_in_out),
433 |check, delta| check.opacity(0.25 + 0.75 * delta),
434 )
435}
436
437pub fn render_skeleton_row(skeleton: &Skeleton, index: usize) -> AnyElement {
438 let corners = bubble_corners(skeleton.own, Default::default());
439 let height = 14. + SKELETON_LINE_HEIGHT * f32::from(skeleton.lines);
440 let shape = div()
441 .w(relative(skeleton.width_ratio))
442 .h(px(height))
443 .rounded_tl(px(corners.top_left))
444 .rounded_tr(px(corners.top_right))
445 .rounded_br(px(corners.bottom_right))
446 .rounded_bl(px(corners.bottom_left))
447 .bg(if skeleton.own {
448 theme::bubble_own().opacity(0.55)
449 } else {
450 theme::bubble_other()
451 });
452 let line = h_flex()
453 .w_full()
454 .when(skeleton.own, |line| line.justify_end())
455 .when(!skeleton.own, |line| {
456 line.gap(px(AVATAR_GAP)).child(
457 div()
458 .size(px(AVATAR_SIZE))
459 .flex_none()
460 .rounded_full()
461 .bg(theme::bubble_other()),
462 )
463 })
464 .child(shape);
465 div()
466 .id(ElementId::Name(format!("row-{index}").into()))
467 .w_full()
468 .px(px(ROW_PADDING))
469 .pt(px(SERIES_START_GAP))
470 .child(pulse("skeleton", line))
471 .into_any_element()
472}
473
474fn meta_room(row: &MessageRow, own: bool, saved: bool) -> usize {
475 let mut width = 12. + row.time.chars().count() as f32 * 6.;
476 if saved {
477 width += SAVED_MARK_SIZE + 4.;
478 }
479 if row.edited {
480 width += 56.;
481 }
482 if own {
483 width += META_CHECK_SIZE + 4.;
484 }
485 (width / FIGURE_SPACE_WIDTH).ceil() as usize
486}
487
488fn with_meta_room(blocks: &[Block], room: usize) -> Option<Vec<Block>> {
489 let mut padded = blocks.to_vec();
490 let inline = padded.last_mut()?.last_inline_mut()?;
491 *inline = inline.with_trailing_room(room);
492 Some(padded)
493}
494
495pub(super) fn has_text(row: &MessageRow) -> bool {
496 !row.blocks.is_empty()
497 || (row.images.is_empty()
498 && row.local_images.is_empty()
499 && row.files.is_empty()
500 && row.adaptive_cards.is_empty())
501}
502
503fn delivery_link(
504 index: usize,
505 name: &str,
506 label: &'static str,
507 action: RowAction,
508) -> Stateful<Div> {
509 div()
510 .id(ElementId::Name(format!("{name}-{index}").into()))
511 .cursor_pointer()
512 .text_color(theme::red_tint())
513 .underline()
514 .child(label)
515 .when_some(action, |link, action| {
516 link.on_click(move |_, _, cx| action(cx))
517 })
518}
519
520pub(super) fn delivery_note(
521 row: &MessageRow,
522 delivery: DeliveryActions,
523 index: usize,
524) -> Option<AnyElement> {
525 let DeliveryActions {
526 retry,
527 delete,
528 send_now,
529 } = delivery;
530 let note = |text: &'static str| {
531 h_flex()
532 .gap(px(4.))
533 .text_size(px(11.))
534 .text_color(theme::red_soft())
535 .child(text)
536 };
537 match &row.delivery {
538 Delivery::Delivered | Delivery::Sending | Delivery::Scheduled(ScheduledState::Waiting) => {
539 None
540 }
541 Delivery::Failed(_) => Some(
542 note("Failed to send.")
543 .child(delivery_link(index, "retry", "Retry", retry))
544 .child(delivery_link(index, "delete", "Delete", delete))
545 .into_any_element(),
546 ),
547 Delivery::Scheduled(ScheduledState::DeliveryFailed) => Some(
548 note("Couldn't send at the scheduled time.")
549 .child(delivery_link(index, "send-now", "Send now", send_now))
550 .child(delivery_link(index, "delete", "Delete", delete))
551 .into_any_element(),
552 ),
553 Delivery::Scheduled(ScheduledState::ChangeFailed) => Some(
554 note("Couldn't change the scheduled message.")
555 .child(delivery_link(index, "retry", "Retry", retry))
556 .into_any_element(),
557 ),
558 }
559}
560
561fn others_row(
562 row: &MessageRow,
563 index: usize,
564 directory: &Directory,
565 bot: Option<&BotIdentity>,
566 delivery: DeliveryActions,
567 mut extras: BubbleExtras,
568 cx: &App,
569) -> Div {
570 let translation = extras.translation.take();
571 let agent_run = extras.agent_run.take();
572 let reaction_proposal = extras.reaction_proposal.take();
573 let first = !row.series.has_prev;
574 let author = bot.map_or_else(|| row.author.clone(), |bot| bot.name.clone());
575 let profile_user = row.sender_id.as_deref().filter(|_| bot.is_none());
576 let mut column = v_flex()
577 .gap(px(2.))
578 .flex_1()
579 .min_w_0()
580 .max_w(bubble_max_width(&extras.timeline, AVATAR_SIZE + AVATAR_GAP))
581 .items_start();
582 if first {
583 column = column.child(
584 h_flex().gap(px(8.)).items_baseline().pl(px(2.)).child(
585 opens_profile(
586 div().id(ElementId::Name(format!("author-{index}").into())),
587 profile_user,
588 )
589 .text_size(px(12.))
590 .font_weight(FontWeight::SEMIBOLD)
591 .text_color(theme::text_soft())
592 .child(author.clone()),
593 ),
594 );
595 }
596 column = column.child(bubble(row, index, false, directory, extras, cx));
597 column = column.children(agent_chip(agent_run));
598 column = column.children(reaction_proposal.map(|pill| reaction_pill(pill, &row.key)));
599 column = column.children(translation_line(row, index, translation.as_ref()));
600 if let Some(note) = delivery_note(row, delivery, index) {
601 column = column.child(note);
602 }
603 let lead = if let Some(bot) = bot.filter(|_| first) {
604 bot_avatar(bot, AVATAR_SIZE)
605 } else if first {
606 person_avatar(
607 directory,
608 row.sender_id.as_deref(),
609 &row.author,
610 AVATAR_SIZE,
611 )
612 } else {
613 div().size(px(AVATAR_SIZE)).into_any_element()
614 };
615 h_flex()
616 .w_full()
617 .gap(px(AVATAR_GAP))
618 .items_start()
619 .child(
620 opens_profile(
621 div().id(ElementId::Name(format!("author-avatar-{index}").into())),
622 profile_user.filter(|_| first),
623 )
624 .w(px(AVATAR_SIZE))
625 .flex_none()
626 .child(lead),
627 )
628 .child(column)
629}
630
631fn own_row(
632 row: &MessageRow,
633 index: usize,
634 directory: &Directory,
635 delivery: DeliveryActions,
636 mut extras: BubbleExtras,
637 cx: &App,
638) -> Div {
639 let translation = extras.translation.take();
640 let agent_run = extras.agent_run.take();
641 let reaction_proposal = extras.reaction_proposal.take();
642 let mut column = v_flex().w_full().items_end().gap(px(2.));
643 column = column.child(
644 h_flex().w_full().justify_end().child(
645 div()
646 .min_w_0()
647 .max_w(bubble_max_width(&extras.timeline, 0.))
648 .child(bubble(row, index, true, directory, extras, cx)),
649 ),
650 );
651 column = column.children(agent_chip(agent_run));
652 column = column.children(reaction_proposal.map(|pill| reaction_pill(pill, &row.key)));
653 column = column.children(translation_line(row, index, translation.as_ref()));
654 if let Some(note) = delivery_note(row, delivery, index) {
655 column = column.child(note);
656 }
657 column
658}
659
660pub fn render_message_row(
661 row: &MessageRow,
662 index: usize,
663 actions: RowActions,
664 directory: &Directory,
665 cx: &App,
666) -> AnyElement {
667 if let Some(call) = &row.call {
668 return call_card_row(row, call, index, directory, actions.call);
669 }
670 let RowActions {
671 bot,
672 delivery,
673 reply,
674 hovered,
675 menu,
676 scheduled_menu,
677 react,
678 reaction_controls,
679 add_reaction: _,
680 files,
681 open_image,
682 highlighted,
683 saved,
684 translation,
685 timeline,
686 agent_run,
687 call: _,
688 pinned: _,
689 reaction_proposal,
690 undo_delete,
691 } = actions;
692 let extras = BubbleExtras {
693 hover: hovered,
694 menu,
695 scheduled_menu,
696 react,
697 controls: reaction_controls,
698 files,
699 open_image,
700 saved,
701 translation,
702 timeline,
703 agent_run,
704 reaction_proposal,
705 undo_delete,
706 };
707 let own = row.own;
708 let spacing = if row.series.has_prev {
709 px(2.)
710 } else {
711 px(SERIES_START_GAP)
712 };
713 let mut container = v_flex().w_full().px(px(ROW_PADDING));
714 if let Some(day) = &row.day_header {
715 container = container.child(day_separator(day));
716 }
717 if row.new_marker {
718 container = container.child(new_marker());
719 }
720 let body = if own {
721 own_row(row, index, directory, delivery, extras, cx)
722 } else {
723 others_row(row, index, directory, bot.as_ref(), delivery, extras, cx)
724 };
725 container
726 .child(
727 div()
728 .id(ElementId::Name(format!("row-{index}").into()))
729 .w_full()
730 .pt(spacing)
731 .when_some(reply, |element, reply| {
732 element.on_mouse_down(MouseButton::Right, move |_, _, cx| reply(cx))
733 })
734 .child(
735 div()
736 .w_full()
737 .rounded(px(10.))
738 .when(highlighted, |element| {
739 element.bg(theme::accent().opacity(0.2))
740 })
741 .child(body),
742 ),
743 )
744 .into_any_element()
745}