Skip to content

Commit 547e854

Browse files
committed
refactor: move draw_modal_overlay from modal_overlay.rs to helpers.rs
Per review feedback from lklimek: no need for a new file, move the function to an existing file. helpers.rs is the best fit since it already contains the related clicked_outside_window() helper. - Moved draw_modal_overlay() to src/ui/helpers.rs - Updated 11 import paths across the codebase - Removed src/ui/components/modal_overlay.rs - Removed pub mod modal_overlay from components/mod.rs
1 parent f5d6bc7 commit 547e854

15 files changed

Lines changed: 45 additions & 47 deletions

src/context/wallet_lifecycle.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use super::AppContext;
22
use super::get_transaction_info;
33
use crate::backend_task::error::TaskError;
44
use crate::database::is_unique_constraint_violation;
5+
use crate::model::feature_gate::FeatureGate;
56
use crate::model::wallet::{
67
AddressInfo as WalletAddressInfo, DerivationPathHelpers, DerivationPathReference,
78
DerivationPathType, TransactionStatus, Wallet, WalletSeedHash, WalletTransaction,
@@ -165,7 +166,7 @@ impl AppContext {
165166
// (protocol version >= 12, i.e., Platform v3.1+). On mainnet (which
166167
// doesn't support shielded transactions yet), skip entirely to avoid
167168
// unnecessary sync attempts and log noise.
168-
if self.supports_shielded() {
169+
if FeatureGate::Shielded.is_available(self) {
169170
match self.initialize_shielded_wallet(seed_hash) {
170171
Ok(_) => {
171172
tracing::trace!(

src/ui/components/confirmation_dialog.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::ui::components::component_trait::{Component, ComponentResponse};
2-
use crate::ui::components::modal_overlay::draw_modal_overlay;
32
use crate::ui::helpers::clicked_outside_window;
3+
use crate::ui::helpers::draw_modal_overlay;
44
use crate::ui::theme::{ComponentStyles, DashColors};
55
use egui::{InnerResponse, Ui, WidgetText};
66

src/ui/components/info_popup.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
use crate::ui::components::modal_overlay::draw_modal_overlay;
21
use crate::ui::helpers::clicked_outside_window;
2+
use crate::ui::helpers::draw_modal_overlay;
33
use crate::ui::theme::{ComponentStyles, DashColors};
44
use egui::{InnerResponse, Ui, WidgetText};
55
use egui_commonmark::{CommonMarkCache, CommonMarkViewer};

src/ui/components/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ pub mod info_popup;
1111
pub mod left_panel;
1212
pub mod left_wallet_panel;
1313
pub mod message_banner;
14-
pub mod modal_overlay;
1514
pub mod password_input;
1615
pub mod selection_dialog;
1716
pub mod styled;

src/ui/components/modal_overlay.rs

Lines changed: 0 additions & 32 deletions
This file was deleted.

src/ui/components/selection_dialog.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::ui::components::component_trait::{Component, ComponentResponse};
2-
use crate::ui::components::modal_overlay::draw_modal_overlay;
32
use crate::ui::helpers::clicked_outside_window;
3+
use crate::ui::helpers::draw_modal_overlay;
44
use crate::ui::theme::{ComponentStyles, DashColors};
55
use egui::{InnerResponse, Ui, WidgetText};
66

src/ui/components/wallet_unlock_popup.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
use crate::context::AppContext;
22
use crate::model::wallet::Wallet;
3-
use crate::ui::components::modal_overlay::draw_modal_overlay;
43
use crate::ui::components::password_input::PasswordInput;
54
use crate::ui::helpers::clicked_outside_window;
5+
use crate::ui::helpers::draw_modal_overlay;
66
use crate::ui::theme::{ComponentStyles, DashColors};
77
use egui;
88
use std::sync::{Arc, RwLock};

src/ui/dashpay/profile_screen.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ use crate::ui::components::component_trait::Component;
1010
use crate::ui::components::confirmation_dialog::{ConfirmationDialog, ConfirmationStatus};
1111
use crate::ui::components::identity_selector::IdentitySelector;
1212
use crate::ui::components::info_popup::InfoPopup;
13-
use crate::ui::components::modal_overlay::draw_modal_overlay;
1413
use crate::ui::components::wallet_unlock_popup::{
1514
WalletUnlockPopup, WalletUnlockResult, try_open_wallet_no_password, wallet_needs_unlock,
1615
};
1716
use crate::ui::components::{MessageBanner, ResultBannerExt};
1817
use crate::ui::helpers::clicked_outside_window;
18+
use crate::ui::helpers::draw_modal_overlay;
1919
use crate::ui::identities::get_selected_wallet;
2020
use crate::ui::theme::{ComponentStyles, DashColors, ResponseExt};
2121
use dash_sdk::dpp::identity::accessors::IdentityGettersV0;

src/ui/helpers.rs

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,40 @@
1-
use crate::ui::theme::ResponseExt;
1+
use crate::ui::theme::{DashColors, ResponseExt};
22
use std::sync::Arc;
33

44
// Re-export from the model layer so existing callers don't break.
55
pub use crate::model::address::is_platform_address_string;
66

7+
/// Paint a semi-transparent modal overlay that blocks pointer events
8+
/// from reaching background widgets.
9+
///
10+
/// Uses an `egui::Area` to both paint the overlay and consume all
11+
/// pointer events (click, drag, hover) so they cannot pass through
12+
/// to widgets rendered behind the overlay.
13+
///
14+
/// The overlay uses `Order::Background` so it sits below modal dialog
15+
/// windows (`Order::Middle`) but above panel content. Within the same
16+
/// order, this Area wins hit-testing over earlier-drawn panel widgets
17+
/// because it is created later in the frame, and egui's `layer_order`
18+
/// processes layers back-to-front.
19+
///
20+
/// **Do not use `Order::Foreground`** — that would place the overlay
21+
/// *above* the dialog windows, blocking interaction with the dialog
22+
/// itself.
23+
pub fn draw_modal_overlay(ctx: &egui::Context, id: &str) {
24+
egui::Area::new(egui::Id::new(id))
25+
.fixed_pos(egui::Pos2::ZERO)
26+
.order(egui::Order::Background)
27+
.interactable(true)
28+
.show(ctx, |ui| {
29+
let screen_rect = ctx.content_rect();
30+
ui.set_min_size(screen_rect.size());
31+
let painter = ui.painter();
32+
painter.rect_filled(screen_rect, 0.0, DashColors::modal_overlay());
33+
// Consume all pointer events so clicks don't pass through
34+
ui.allocate_response(screen_rect.size(), egui::Sense::click_and_drag());
35+
});
36+
}
37+
738
/// Returns true if the user left-clicked outside the given window rect this frame.
839
/// Use after painting a modal overlay and showing the dialog window.
940
pub fn clicked_outside_window(ctx: &egui::Context, window_rect: egui::Rect) -> bool {
@@ -20,7 +51,6 @@ use crate::{
2051
context::AppContext,
2152
model::{qualified_contract::QualifiedContract, qualified_identity::QualifiedIdentity},
2253
ui::contracts_documents::group_actions_screen::GroupActionsScreen,
23-
ui::theme::DashColors,
2454
ui::{RootScreenType, Screen, identities::keys::add_key_screen::AddKeyScreen},
2555
};
2656
use arboard::Clipboard;

src/ui/identities/identities_screen.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ use crate::model::qualified_identity::PrivateKeyTarget::{
99
use crate::model::qualified_identity::{IdentityStatus, IdentityType, QualifiedIdentity};
1010
use crate::model::wallet::WalletSeedHash;
1111
use crate::ui::components::left_panel::add_left_panel;
12-
use crate::ui::components::modal_overlay::draw_modal_overlay;
1312
use crate::ui::components::styled::{ConfirmationDialog, ConfirmationStatus, island_central_panel};
1413
use crate::ui::components::top_panel::add_top_panel;
1514
use crate::ui::components::{BannerHandle, MessageBanner, OptionBannerExt};
1615
use crate::ui::helpers::clicked_outside_window;
16+
use crate::ui::helpers::draw_modal_overlay;
1717
use crate::ui::identities::keys::add_key_screen::AddKeyScreen;
1818
use crate::ui::identities::keys::key_info_screen::KeyInfoScreen;
1919
use crate::ui::identities::register_dpns_name_screen::{

0 commit comments

Comments
 (0)