feat: improve compose modal

This commit is contained in:
reya
2025-02-09 14:29:34 +07:00
parent 0daebe5762
commit 600af900e9
14 changed files with 661 additions and 524 deletions
+7 -11
View File
@@ -1,9 +1,8 @@
use crate::views::sidebar::inbox::Inbox;
use chat_state::registry::ChatRegistry;
use compose::Compose;
use gpui::{
div, px, AnyElement, App, AppContext, BorrowAppContext, Context, Entity, EventEmitter,
FocusHandle, Focusable, InteractiveElement, IntoElement, ParentElement, Render, SharedString,
div, px, AnyElement, App, AppContext, Context, Entity, EventEmitter, FocusHandle, Focusable,
InteractiveElement, IntoElement, ParentElement, Render, SharedString,
StatefulInteractiveElement, Styled, Window,
};
use ui::{
@@ -11,7 +10,7 @@ use ui::{
dock_area::panel::{Panel, PanelEvent},
popup_menu::PopupMenu,
theme::{scale::ColorScaleStep, ActiveTheme},
v_flex, ContextModal, Icon, IconName, Sizable, StyledExt,
v_flex, ContextModal, Disableable, Icon, IconName, Sizable, StyledExt,
};
mod compose;
@@ -53,6 +52,7 @@ impl Sidebar {
window.open_modal(cx, move |modal, window, cx| {
let label = compose.read(cx).label(window, cx);
let is_submitting = compose.read(cx).is_submitting();
modal
.title("Direct Messages")
@@ -70,14 +70,10 @@ impl Sidebar {
.bold()
.rounded(ButtonRounded::Large)
.w_full()
.loading(is_submitting)
.disabled(is_submitting)
.on_click(window.listener_for(&compose, |this, _, window, cx| {
if let Some(room) = this.room(window, cx) {
cx.update_global::<ChatRegistry, _>(|this, cx| {
this.new_room(room, cx);
});
window.close_modal(cx);
}
this.compose(window, cx)
})),
),
)