Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ Screen::ui() → AppAction::BackendTask(task)
## Screen Pattern

All screens implement the `ScreenLike` trait:
- `ui(&mut self, ctx: &Context) -> AppAction` - Render UI, return actions
- `ui(&mut self, ui: &mut egui::Ui) -> AppAction` - Render UI, return actions
- `display_task_result(&mut self, result: BackendTaskSuccessResult)` - Handle async results
- `display_message(&mut self, msg: &str, type: MessageType)` - Show user feedback
- `refresh(&mut self)` / `refresh_on_arrival(&mut self)` - Re-fetch data
Expand Down
10 changes: 5 additions & 5 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -940,8 +940,8 @@ impl AppState {
}

impl App for AppState {
fn ui(&mut self, _ui: &mut egui::Ui, _frame: &mut eframe::Frame) {
let ctx = _ui.ctx().clone();
fn ui(&mut self, ui: &mut egui::Ui, _frame: &mut eframe::Frame) {
let ctx = ui.ctx().clone();
let ctx = &ctx;
// ── Graceful shutdown: intercept window close so the UI stays responsive ──
// When the user closes the window we cancel the native close, show a banner,
Expand Down Expand Up @@ -984,7 +984,7 @@ impl App for AppState {
}
// Render a minimal UI that shows the shutdown banner.
self.theme.poll_and_apply(ctx);
crate::ui::components::styled::island_central_panel(ctx, |_ui| {});
crate::ui::components::styled::island_central_panel(ui, |_ui| {});
return;
}

Expand Down Expand Up @@ -1278,9 +1278,9 @@ impl App for AppState {
if self.show_welcome_screen
&& let Some(welcome_screen) = &mut self.welcome_screen
{
actions.push(welcome_screen.ui(ctx));
actions.push(welcome_screen.ui(ui));
} else {
actions.push(self.visible_screen_mut().ui(ctx));
actions.push(self.visible_screen_mut().ui(ui));
};

// Schedule connection status refresh
Expand Down
11 changes: 6 additions & 5 deletions src/ui/components/contract_chooser_panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use dash_sdk::dpp::data_contract::{
};
use dash_sdk::dpp::platform_value::string_encoding::Encoding;
use dash_sdk::dpp::serialization::PlatformSerializableWithPlatformVersion;
use egui::{Color32, Context as EguiContext, Frame, Margin, Panel, RichText};
use egui::{Color32, Frame, Margin, Panel, RichText, Ui};
use std::collections::HashMap;
use std::sync::Arc;
use tracing::error;
Expand Down Expand Up @@ -145,7 +145,7 @@ fn render_collapsing_header(

#[allow(clippy::too_many_arguments)]
pub fn add_contract_chooser_panel(
ctx: &EguiContext,
ui: &mut Ui,
current_search_term: &mut String,
app_context: &Arc<AppContext>,
selected_data_contract: &mut QualifiedContract,
Expand All @@ -156,6 +156,8 @@ pub fn add_contract_chooser_panel(
pending_fields_selection: &mut HashMap<String, bool>,
chooser_state: &mut ContractChooserState,
) -> AppAction {
let ctx = ui.ctx().clone();
let ctx = &ctx;
let mut action = AppAction::None;

// Retrieve the list of known contracts
Expand All @@ -180,17 +182,16 @@ pub fn add_contract_chooser_panel(

let dark_mode = ctx.global_style().visuals.dark_mode;

#[allow(deprecated)]
Panel::left("contract_chooser_panel")
// Let the user resize this panel horizontally
.resizable(true)
.default_width(270.0)
.default_size(270.0)
.frame(
Frame::new()
.fill(DashColors::background(dark_mode))
.inner_margin(Margin::symmetric(10, 10)), // Add margins for island effect
)
.show(ctx, |ui| {
.show_inside(ui, |ui| {
// Fill the entire available height
let available_height = ui.available_height();

Expand Down
11 changes: 5 additions & 6 deletions src/ui/components/dashpay_subscreen_chooser_panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ use crate::model::feature_gate::FeatureGate;
use crate::ui::RootScreenType;
use crate::ui::dashpay::dashpay_screen::DashPaySubscreen;
use crate::ui::theme::{DashColors, Shadow, Shape, Spacing, Typography};
use egui::{Context, Frame, Margin, Panel, RichText};
use egui::{Frame, Margin, Panel, RichText, Ui};
use std::sync::Arc;

pub fn add_dashpay_subscreen_chooser_panel(
ctx: &Context,
ui: &mut Ui,
app_context: &Arc<AppContext>,
current_subscreen: DashPaySubscreen,
) -> AppAction {
let mut action = AppAction::None;
let dark_mode = ctx.global_style().visuals.dark_mode;
let dark_mode = ui.ctx().global_style().visuals.dark_mode;

// Build subscreens list - Payment History is experimental (developer mode only)
let mut subscreens = vec![DashPaySubscreen::Profile, DashPaySubscreen::Contacts];
Expand All @@ -26,15 +26,14 @@ pub fn add_dashpay_subscreen_chooser_panel(

let active_screen = current_subscreen;

#[allow(deprecated)]
Panel::left("dashpay_subscreen_chooser_panel")
.default_width(270.0)
.default_size(270.0)
.frame(
Frame::new()
.fill(DashColors::background(dark_mode)) // Light background instead of transparent
.inner_margin(Margin::symmetric(10, 10)), // Add margins for island effect
)
.show(ctx, |ui| {
.show_inside(ui, |ui| {
// Fill the entire available height
let available_height = ui.available_height();

Expand Down
11 changes: 5 additions & 6 deletions src/ui/components/dpns_subscreen_chooser_panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ use crate::ui::RootScreenType;
use crate::ui::dpns::dpns_contested_names_screen::DPNSSubscreen;
use crate::ui::theme::{DashColors, Shadow, Shape, Spacing, Typography};
use crate::{app::AppAction, ui};
use egui::{Context, Frame, Margin, Panel, RichText};
use egui::{Frame, Margin, Panel, RichText, Ui};

pub fn add_dpns_subscreen_chooser_panel(ctx: &Context, app_context: &AppContext) -> AppAction {
pub fn add_dpns_subscreen_chooser_panel(ui: &mut Ui, app_context: &AppContext) -> AppAction {
let mut action = AppAction::None;
let dark_mode = ctx.global_style().visuals.dark_mode;
let dark_mode = ui.ctx().global_style().visuals.dark_mode;

let subscreens = vec![
DPNSSubscreen::Active,
Expand All @@ -27,16 +27,15 @@ pub fn add_dpns_subscreen_chooser_panel(ctx: &Context, app_context: &AppContext)
_ => DPNSSubscreen::Active,
};

#[allow(deprecated)]
Panel::left("dpns_subscreen_chooser_panel")
.resizable(true)
.default_width(270.0)
.default_size(270.0)
.frame(
Frame::new()
.fill(DashColors::background(dark_mode))
.inner_margin(Margin::symmetric(10, 10)),
)
.show(ctx, |ui| {
.show_inside(ui, |ui| {
let available_height = ui.available_height();

Frame::new()
Expand Down
13 changes: 7 additions & 6 deletions src/ui/components/left_panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::ui::components::styled::GradientButton;
use crate::ui::theme::{DashColors, ResponseExt, Shadow, Shape, Spacing};
use dash_sdk::dashcore_rpc::dashcore::Network;
use eframe::epaint::Margin;
use egui::{Context, Frame, Image, Panel, RichText, TextureHandle};
use egui::{Context, Frame, Image, Panel, RichText, TextureHandle, Ui};
use egui_extras::{Size, StripBuilder};
use rust_embed::RustEmbed;
use std::sync::Arc;
Expand Down Expand Up @@ -110,10 +110,12 @@ pub fn load_svg_icon(ctx: &Context, path: &str, width: u32, height: u32) -> Opti
}

pub fn add_left_panel(
ctx: &Context,
ui: &mut Ui,
app_context: &Arc<AppContext>,
selected_screen: RootScreenType,
) -> AppAction {
let ctx = ui.ctx().clone();
let ctx = &ctx;
let mut action = AppAction::None;

// Define the button details directly in this function.
Expand Down Expand Up @@ -166,17 +168,16 @@ pub fn add_left_panel(

let dark_mode = ctx.global_style().visuals.dark_mode;

#[allow(deprecated)]
Panel::left("left_panel")
.min_width(140.0)
.max_width(140.0)
.min_size(140.0)
.max_size(140.0)
.resizable(false)
.frame(
Frame::new()
.fill(DashColors::background(dark_mode))
.inner_margin(Margin::symmetric(10, 10)), // Add margins for island effect
)
.show(ctx, |ui| {
.show_inside(ui, |ui| {
// Create an island panel with rounded edges
Frame::new()
.fill(DashColors::surface(dark_mode))
Expand Down
11 changes: 6 additions & 5 deletions src/ui/components/left_wallet_panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::context::AppContext;
use crate::ui::RootScreenType;
use crate::ui::theme::DashColors;
use eframe::epaint::Margin;
use egui::{Context, Frame, Image, Panel, TextureHandle};
use egui::{Context, Frame, Image, Panel, TextureHandle, Ui};
use rust_embed::RustEmbed;
use std::sync::Arc;
use tracing::error;
Expand Down Expand Up @@ -40,10 +40,12 @@ fn load_icon(ctx: &Context, path: &str) -> Option<TextureHandle> {

#[allow(dead_code)]
pub fn add_left_panel(
ctx: &Context,
ui: &mut Ui,
_app_context: &Arc<AppContext>,
selected_screen: RootScreenType,
) -> AppAction {
let ctx = ui.ctx().clone();
let ctx = &ctx;
let mut action = AppAction::None;

// Define the button details directly in this function
Expand All @@ -65,9 +67,8 @@ pub fn add_left_panel(

let panel_width = 50.0 + 20.0; // Button width (50) + 10px margin on each side (20 total)

#[allow(deprecated)]
Panel::left("left_panel")
.default_width(panel_width)
.default_size(panel_width)
.frame(
Frame::new()
.fill(ctx.global_style().visuals.panel_fill)
Expand All @@ -78,7 +79,7 @@ pub fn add_left_panel(
bottom: 0,
}),
)
.show(ctx, |ui| {
.show_inside(ui, |ui| {
ui.vertical_centered(|ui| {
for (label, screen_type, icon_path) in buttons.iter() {
if *screen_type == RootScreenType::RootScreenDocumentQuery {
Expand Down
20 changes: 5 additions & 15 deletions src/ui/components/styled.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ use crate::{
ui::theme::{DashColors, Shadow, Shape, Spacing, Typography},
};
use egui::{
Button, CentralPanel, Color32, Context, Frame, Margin, Response, RichText, Stroke, TextEdit,
Ui, Vec2,
Button, CentralPanel, Color32, Frame, Margin, Response, RichText, Stroke, TextEdit, Ui, Vec2,
};

// Re-export commonly used components
Expand Down Expand Up @@ -536,25 +535,16 @@ pub fn styled_text_edit_multiline(text: &mut String, dark_mode: bool) -> TextEdi
}

/// Helper function to create an island-style central panel.
///
/// Wraps `CentralPanel::show(ctx, ...)`, which is deprecated in egui 0.34 in
/// favor of `show_inside(ui, ...)`. The deprecation is silenced at this single
/// boundary so the screen layer can keep its `&Context`-driven `ui()` shape.
// TODO(egui-0.35): migrate to `Panel::central(...).show_inside(ui, ...)` and
// thread `&mut Ui` from `App::ui` instead of `&Context`. Defers a 60+ call-site
// refactor that exceeded the egui 0.34 upgrade scope. The current
// `#[allow(deprecated)]` containment must be removed when this happens.
pub fn island_central_panel<R>(ctx: &Context, content: impl FnOnce(&mut Ui) -> R) -> R {
let dark_mode = ctx.global_style().visuals.dark_mode;

#[allow(deprecated)]
pub fn island_central_panel<R>(ui: &mut Ui, content: impl FnOnce(&mut Ui) -> R) -> R {
let dark_mode = ui.ctx().global_style().visuals.dark_mode;

CentralPanel::default()
.frame(
Frame::new()
.fill(DashColors::background(dark_mode))
.inner_margin(Margin::symmetric(10, 10)), // Standard margins for all panels
)
.show(ctx, |ui| {
.show_inside(ui, |ui| {
// Calculate responsive margins based on available width, but ensure minimum spacing
let available_width = ui.available_width();
let inner_margin = if available_width > 1200.0 {
Expand Down
11 changes: 5 additions & 6 deletions src/ui/components/tokens_subscreen_chooser_panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ use crate::ui::RootScreenType;
use crate::ui::theme::{DashColors, Shadow, Shape, Spacing, Typography};
use crate::ui::tokens::tokens_screen::TokensSubscreen;
use crate::{app::AppAction, ui};
use egui::{Context, Frame, Margin, Panel, RichText};
use egui::{Frame, Margin, Panel, RichText, Ui};

pub fn add_tokens_subscreen_chooser_panel(ctx: &Context, app_context: &AppContext) -> AppAction {
pub fn add_tokens_subscreen_chooser_panel(ui: &mut Ui, app_context: &AppContext) -> AppAction {
let mut action = AppAction::None;

let subscreens = vec![
Expand All @@ -24,18 +24,17 @@ pub fn add_tokens_subscreen_chooser_panel(ctx: &Context, app_context: &AppContex
_ => TokensSubscreen::MyTokens, // Fallback to Active screen if settings unavailable
};

let dark_mode = ctx.global_style().visuals.dark_mode;
let dark_mode = ui.ctx().global_style().visuals.dark_mode;

#[allow(deprecated)]
Panel::left("tokens_subscreen_chooser_panel")
.resizable(false)
.default_width(270.0)
.default_size(270.0)
.frame(
Frame::new()
.fill(DashColors::background(dark_mode))
.inner_margin(Margin::symmetric(10, 10)),
)
.show(ctx, |ui| {
.show_inside(ui, |ui| {
let available_height = ui.available_height();
Frame::new()
.fill(DashColors::surface(dark_mode))
Expand Down
11 changes: 5 additions & 6 deletions src/ui/components/tools_subscreen_chooser_panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::spv::CoreBackendMode;
use crate::ui::RootScreenType;
use crate::ui::theme::{DashColors, Shadow, Shape, Spacing, Typography};
use crate::{app::AppAction, ui};
use egui::{Context, Frame, Margin, Panel, RichText, ScrollArea};
use egui::{Frame, Margin, Panel, RichText, ScrollArea, Ui};

#[derive(PartialEq)]
pub enum ToolsSubscreen {
Expand Down Expand Up @@ -45,9 +45,9 @@ impl ToolsSubscreen {
}
}

pub fn add_tools_subscreen_chooser_panel(ctx: &Context, app_context: &AppContext) -> AppAction {
pub fn add_tools_subscreen_chooser_panel(ui: &mut Ui, app_context: &AppContext) -> AppAction {
let mut action = AppAction::None;
let dark_mode = ctx.global_style().visuals.dark_mode;
let dark_mode = ui.ctx().global_style().visuals.dark_mode;
let is_rpc_mode = app_context.core_backend_mode() == CoreBackendMode::Rpc;

let subscreens = vec![
Expand Down Expand Up @@ -93,16 +93,15 @@ pub fn add_tools_subscreen_chooser_panel(ctx: &Context, app_context: &AppContext
_ => ToolsSubscreen::PlatformInfo, // Fallback to Active screen if settings unavailable
};

#[allow(deprecated)]
Panel::left("tools_subscreen_chooser_panel")
.resizable(false)
.default_width(270.0)
.default_size(270.0)
.frame(
Frame::new()
.fill(DashColors::background(dark_mode))
.inner_margin(Margin::symmetric(10, 10)),
)
.show(ctx, |ui| {
.show_inside(ui, |ui| {
let available_height = ui.available_height();
Frame::new()
.fill(DashColors::surface(dark_mode))
Expand Down
7 changes: 4 additions & 3 deletions src/ui/components/top_panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,23 +201,24 @@ fn add_connection_indicator(ui: &mut Ui, app_context: &Arc<AppContext>) -> AppAc
}

pub fn add_top_panel(
ctx: &Context,
ui: &mut Ui,
app_context: &Arc<AppContext>,
location: Vec<(&str, AppAction)>,
right_buttons: Vec<(&str, DesiredAppAction)>,
) -> AppAction {
let ctx = ui.ctx().clone();
let ctx = &ctx;
let mut action = AppAction::None;
let dark_mode = ctx.global_style().visuals.dark_mode;
let network_accent = DashColors::network_accent(app_context.network, dark_mode);

#[allow(deprecated)]
Panel::top("top_panel")
.frame(
Frame::new()
.fill(DashColors::background(dark_mode))
.inner_margin(Margin::same(10)), // 10px margin on all sides
)
.show(ctx, |ui| {
.show_inside(ui, |ui| {
// Create an island panel with rounded edges
Frame::new()
.fill(DashColors::surface(dark_mode))
Expand Down
Loading