refactor dialogs

This commit is contained in:
2026-09-29 10:46:16 +07:00
parent 828986cd5c
commit 0a9301f131
16 changed files with 202 additions and 200 deletions
+2 -2
View File
@@ -15,7 +15,7 @@ use ui::{Disableable, StyledExt, WindowExtension, divider, v_flex};
pub fn open(window: &mut Window, cx: &mut App) {
let import = cx.new(|cx| ImportIdentity::new(window, cx));
window.open_modal(cx, move |this, _window, _cx| {
window.open_dialog(cx, move |this, _window, _cx| {
this.width(px(450.))
.show_close(false)
.overlay_closable(false)
@@ -138,7 +138,7 @@ impl ImportIdentity {
Ok(keys) => {
nostr.update_in(cx, |this, window, cx| {
this.set_signer(keys, cx);
window.close_modal(cx);
window.close_dialog(cx);
})?;
}
Err(e) => {
+3 -3
View File
@@ -13,9 +13,9 @@ use person::PersonRegistry;
use state::NostrRegistry;
use theme::ActiveTheme;
use ui::button::{Button, ButtonVariants};
use ui::dialog::DialogButtonProps;
use ui::dock::{DockArea, DockPlacement, PanelHandle};
use ui::input::{Input, InputEvent, InputState};
use ui::modal::ModalButtonProps;
use ui::nav::Nav;
use ui::{Disableable, IconName, Selectable, Sizable, WindowExtension, h_flex, v_flex};
@@ -27,14 +27,14 @@ const MAX_MEMBERS: usize = 3;
pub fn open(dock: WeakEntity<DockArea>, window: &mut Window, cx: &mut App) {
let view = cx.new(|cx| NewChat::new(dock, window, cx));
window.open_modal(cx, {
window.open_dialog(cx, {
let view = view.clone();
move |this, _window, _cx| {
this.width(px(420.))
.title("New chat")
.confirm()
.button_props(
ModalButtonProps::default()
DialogButtonProps::default()
.cancel_text("Cancel")
.ok_text("Start"),
)
@@ -6,7 +6,7 @@ use ui::input::{Input, InputState};
pub fn open(window: &mut Window, cx: &mut App) {
let name_input = cx.new(|cx| InputState::new(window, cx).placeholder("Community name"));
window.open_modal(cx, move |this, _window, _cx| {
window.open_dialog(cx, move |this, _window, _cx| {
let name_input = name_input.clone();
this.width(px(380.))
@@ -14,6 +14,7 @@ pub fn open(window: &mut Window, cx: &mut App) {
.title("New community")
.child(Input::new(&name_input))
.on_ok(move |_event, _window, cx| {
let community = CommunityRegistry::global(cx);
let name = name_input.read(cx).value().trim().to_owned();
if name.is_empty() {
@@ -25,8 +26,9 @@ pub fn open(window: &mut Window, cx: &mut App) {
..CommunityMetadata::default()
};
CommunityRegistry::global(cx)
.update(cx, |registry, cx| registry.create(metadata, cx));
community.update(cx, |registry, cx| {
registry.create(metadata, cx);
});
true
})
+2 -2
View File
@@ -65,8 +65,8 @@ impl RestoreEncryption {
this.set_announcement(Keys::new(secret), cx);
});
// Close the current modal
window.close_modal(cx);
// Close the current dialog
window.close_dialog(cx);
}
fn set_error<S>(&mut self, message: S, cx: &mut Context<Self>)
+3 -3
View File
@@ -52,7 +52,7 @@ impl Screening {
subscriptions.push(cx.on_release_in(window, move |this, window, cx| {
this.tasks.clear();
window.close_all_modals(cx);
window.close_all_dialogs(cx);
}));
cx.defer_in(window, |this, _window, cx| {
@@ -259,7 +259,7 @@ impl Screening {
self.tasks.push(cx.spawn_in(window, async move |_, cx| {
if task.await.is_ok() {
cx.update(|window, cx| {
window.close_modal(cx);
window.close_dialog(cx);
window.push_notification("Report submitted successfully", cx);
})
.ok();
@@ -270,7 +270,7 @@ impl Screening {
fn mutual_contacts(&mut self, window: &mut Window, cx: &mut Context<Self>) {
let contacts = self.mutual_contacts.clone();
window.open_modal(cx, move |this, _window, _cx| {
window.open_dialog(cx, move |this, _window, _cx| {
let contacts = contacts.clone();
let total = contacts.len();