use gpui_kit::assets::IconName; use gpui_kit::base::GlobalState; use gpui_kit::component::h_flex; use gpui_kit::*; use super::message_actions::{Action, bar_button}; use super::toolbar_placement::{HoverChange, TOOLBAR_HEIGHT, toolbar_slot}; use super::widgets::icon; use crate::theme::{self, ElevatedSurface as _}; pub struct ScheduledMenu { pub key: String, pub edit: Action, pub send_now: Action, pub delete: Action, pub hover: HoverChange, } fn element_id(prefix: &str, key: &str) -> ElementId { ElementId::Name(format!("{prefix}-{key}").into()) } fn text_button(id: ElementId, label: &'static str) -> Stateful
{ bar_button(id) .w_auto() .px(px(8.)) .text_size(px(12.5)) .text_color(theme::text_soft()) .child(label) } pub fn scheduled_toolbar(menu: ScheduledMenu) -> AnyElement { let ScheduledMenu { key, edit, send_now, delete, hover, } = menu; let bar = h_flex() .h(px(TOOLBAR_HEIGHT)) .p(px(3.)) .gap(px(1.)) .items_center() .rounded(px(10.)) .flyout_surface() .on_mouse_down(MouseButton::Left, |_, _, cx| { GlobalState::suppress_text_selection(cx) }) .child( text_button(element_id("scheduled-edit", &key), "Edit").on_click( move |_, window, cx| { cx.stop_propagation(); edit(window, cx); }, ), ) .child( text_button(element_id("scheduled-send-now", &key), "Send now").on_click( move |_, window, cx| { cx.stop_propagation(); send_now(window, cx); }, ), ) .child( bar_button(element_id("scheduled-delete", &key)) .child(icon(IconName::Trash, 16., theme::red_soft())) .on_click(move |_, window, cx| { cx.stop_propagation(); delete(window, cx); }), ); toolbar_slot(element_id("scheduled-toolbar", &key), hover, bar).into_any_element() }