Skip to content
Merged
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
8 changes: 8 additions & 0 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use crate::database::Database;
use crate::logging::initialize_logger;
use crate::model::settings::Settings;
use crate::ui::contracts_documents::contracts_documents_screen::DocumentQueryScreen;
use crate::ui::contracts_documents::dashpay_coming_soon_screen::DashPayComingSoonScreen;
use crate::ui::dpns::dpns_contested_names_screen::{
DPNSScreen, DPNSSubscreen, ScheduledVoteCastingStatus,
};
Expand Down Expand Up @@ -226,6 +227,7 @@ impl AppState {
TokensScreen::new(&mainnet_app_context, TokensSubscreen::SearchTokens);
let mut token_creator_screen =
TokensScreen::new(&mainnet_app_context, TokensSubscreen::TokenCreator);
let mut contracts_dashpay_screen = DashPayComingSoonScreen::new(&mainnet_app_context);

let mut network_chooser_screen = NetworkChooserScreen::new(
&mainnet_app_context,
Expand Down Expand Up @@ -263,6 +265,7 @@ impl AppState {
proof_log_screen = ProofLogScreen::new(testnet_app_context);
platform_info_screen = PlatformInfoScreen::new(testnet_app_context);
masternode_list_diff_screen = MasternodeListDiffScreen::new(testnet_app_context);
contracts_dashpay_screen = DashPayComingSoonScreen::new(testnet_app_context);
tokens_balances_screen =
TokensScreen::new(testnet_app_context, TokensSubscreen::MyTokens);
token_search_screen =
Expand Down Expand Up @@ -312,6 +315,7 @@ impl AppState {
masternode_list_diff_screen = MasternodeListDiffScreen::new(local_app_context);
proof_log_screen = ProofLogScreen::new(local_app_context);
platform_info_screen = PlatformInfoScreen::new(local_app_context);
contracts_dashpay_screen = DashPayComingSoonScreen::new(local_app_context);
tokens_balances_screen =
TokensScreen::new(local_app_context, TokensSubscreen::MyTokens);
token_search_screen =
Expand Down Expand Up @@ -445,6 +449,10 @@ impl AppState {
RootScreenType::RootScreenDocumentQuery,
Screen::DocumentQueryScreen(document_query_screen),
),
(
RootScreenType::RootScreenContractsDashPay,
Screen::DashPayComingSoonScreen(contracts_dashpay_screen),
),
(
RootScreenType::RootScreenNetworkChooser,
Screen::NetworkChooserScreen(network_chooser_screen),
Expand Down
9 changes: 3 additions & 6 deletions src/components/core_p2p_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,17 +176,15 @@ impl CoreP2PHandler {
.stream
.read_timeout()
.map_err(|e| format!("get_read_timeout failed: {}", e))?;
self
.stream
self.stream
.set_read_timeout(Some(socket_timeout))
.map_err(|e| format!("set_read_timeout failed: {}", e))?;
let start_time = std::time::Instant::now();
let timeout = overall_timeout;
loop {
if start_time.elapsed() > timeout {
// Restore previous socket timeout before returning
self
.stream
self.stream
.set_read_timeout(previous_socket_timeout)
.map_err(|e| format!("restore set_read_timeout failed: {}", e))?;
return Err("Timeout waiting for qrinfo message".to_string());
Expand All @@ -205,8 +203,7 @@ impl CoreP2PHandler {
if command == "qrinfo" {
println!("Got qrinfo message");
// Restore previous socket timeout
self
.stream
self.stream
.set_read_timeout(previous_socket_timeout)
.map_err(|e| format!("restore set_read_timeout failed: {}", e))?;
break;
Expand Down
2 changes: 1 addition & 1 deletion src/ui/components/contract_chooser_panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ pub fn add_contract_chooser_panel(

SidePanel::left("contract_chooser_panel")
// Let the user resize this panel horizontally
.resizable(true)
.resizable(false)
.default_width(270.0) // Increased to account for margins
.frame(
Frame::new()
Expand Down
128 changes: 128 additions & 0 deletions src/ui/components/contracts_subscreen_chooser_panel.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
use crate::app::AppAction;
use crate::context::AppContext;
use crate::ui::theme::{DashColors, Shadow, Shape, Spacing, Typography};
use crate::ui::{self, RootScreenType};
use egui::{Context, Frame, Margin, RichText, SidePanel};

#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum ContractsSubscreen {
Contracts,
DPNS,
DashPay,
}

impl ContractsSubscreen {
pub fn display_name(&self) -> &'static str {
match self {
ContractsSubscreen::Contracts => "All Contracts",
ContractsSubscreen::DPNS => "DPNS",
ContractsSubscreen::DashPay => "DashPay",
}
}
}

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

let subscreens = vec![
ContractsSubscreen::Contracts,
ContractsSubscreen::DPNS,
ContractsSubscreen::DashPay,
];

// Determine active selection from settings; default to Contracts
let active_screen = match app_context.get_settings() {
Ok(Some(settings)) => match settings.root_screen_type {
ui::RootScreenType::RootScreenDocumentQuery => ContractsSubscreen::Contracts,
ui::RootScreenType::RootScreenDPNSActiveContests
| ui::RootScreenType::RootScreenDPNSPastContests
| ui::RootScreenType::RootScreenDPNSOwnedNames
| ui::RootScreenType::RootScreenDPNSScheduledVotes => ContractsSubscreen::DPNS,
ui::RootScreenType::RootScreenContractsDashPay => ContractsSubscreen::DashPay,
_ => ContractsSubscreen::Contracts,
},
_ => ContractsSubscreen::Contracts,
};

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

SidePanel::left("contracts_subscreen_chooser_panel")
.resizable(false)
.default_width(270.0)
.frame(
Frame::new()
.fill(DashColors::background(dark_mode))
.inner_margin(Margin::symmetric(10, 10)),
)
.show(ctx, |ui| {
let available_height = ui.available_height();

Frame::new()
.fill(DashColors::surface(dark_mode))
.stroke(egui::Stroke::new(1.0, DashColors::border_light(dark_mode)))
.inner_margin(Margin::same(Spacing::XL as i8))
.corner_radius(egui::CornerRadius::same(Shape::RADIUS_LG))
.shadow(Shadow::elevated())
.show(ui, |ui| {
ui.set_min_height(available_height - 2.0 - (Spacing::XL * 2.0));
ui.vertical(|ui| {
ui.label(
RichText::new("Contracts")
.font(Typography::heading_small())
.color(DashColors::text_primary(dark_mode)),
);
ui.add_space(Spacing::MD);

for subscreen in subscreens {
let is_active = active_screen == subscreen;

let button = if is_active {
egui::Button::new(
RichText::new(subscreen.display_name())
.color(DashColors::WHITE)
.size(Typography::SCALE_SM),
)
.fill(DashColors::DASH_BLUE)
.stroke(egui::Stroke::NONE)
.corner_radius(egui::CornerRadius::same(Shape::RADIUS_MD))
.min_size(egui::Vec2::new(150.0, 28.0))
} else {
egui::Button::new(
RichText::new(subscreen.display_name())
.color(DashColors::text_primary(dark_mode))
.size(Typography::SCALE_SM),
)
.fill(DashColors::glass_white(dark_mode))
.stroke(egui::Stroke::new(1.0, DashColors::border(dark_mode)))
.corner_radius(egui::CornerRadius::same(Shape::RADIUS_MD))
.min_size(egui::Vec2::new(150.0, 28.0))
};

if ui.add(button).clicked() {
action = match subscreen {
ContractsSubscreen::Contracts => {
AppAction::SetMainScreenThenGoToMainScreen(
RootScreenType::RootScreenDocumentQuery,
)
}
ContractsSubscreen::DPNS => {
AppAction::SetMainScreenThenGoToMainScreen(
RootScreenType::RootScreenDPNSActiveContests,
)
}
ContractsSubscreen::DashPay => {
AppAction::SetMainScreenThenGoToMainScreen(
RootScreenType::RootScreenContractsDashPay,
)
}
};
}

ui.add_space(Spacing::SM);
}
});
});
});

action
}
17 changes: 7 additions & 10 deletions src/ui/components/dpns_subscreen_chooser_panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,31 +24,28 @@ pub fn add_dpns_subscreen_chooser_panel(ctx: &Context, app_context: &AppContext)
ui::RootScreenType::RootScreenDPNSScheduledVotes => DPNSSubscreen::ScheduledVotes,
_ => DPNSSubscreen::Active,
},
_ => DPNSSubscreen::Active, // Fallback to Active screen if settings unavailable
_ => DPNSSubscreen::Active,
};

SidePanel::left("dpns_subscreen_chooser_panel")
.default_width(270.0) // Increased to account for margins
.resizable(true)
.default_width(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
.fill(DashColors::background(dark_mode))
.inner_margin(Margin::symmetric(10, 10)),
)
.show(ctx, |ui| {
// Fill the entire available height
let available_height = ui.available_height();

// Create an island panel with rounded edges that fills the height
Frame::new()
.fill(DashColors::surface(dark_mode))
.stroke(egui::Stroke::new(1.0, DashColors::border_light(dark_mode)))
.inner_margin(Margin::same(Spacing::MD_I8))
.inner_margin(Margin::same(Spacing::XL as i8))
.corner_radius(egui::CornerRadius::same(Shape::RADIUS_LG))
.shadow(Shadow::elevated())
.show(ui, |ui| {
// Account for both outer margin (10px * 2) and inner margin
ui.set_min_height(available_height - 2.0 - (Spacing::MD_I8 as f32 * 2.0));
// Display subscreen names
ui.set_min_height(available_height - 2.0 - (Spacing::XL * 2.0));
ui.vertical(|ui| {
ui.label(
RichText::new("DPNS Subscreens")
Expand Down
44 changes: 34 additions & 10 deletions src/ui/components/left_panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,21 +56,36 @@ pub fn add_left_panel(

// Define the button details directly in this function
let buttons = [
("I", RootScreenType::RootScreenIdentities, "identity.png"),
("Q", RootScreenType::RootScreenDocumentQuery, "doc.png"),
("O", RootScreenType::RootScreenMyTokenBalances, "tokens.png"),
(
"C",
RootScreenType::RootScreenDPNSActiveContests,
"voting.png",
"Identities",
RootScreenType::RootScreenIdentities,
"identity.png",
),
("W", RootScreenType::RootScreenWalletsBalances, "wallet.png"),
(
"T",
RootScreenType::RootScreenToolsProofLogScreen,
"Contracts",
RootScreenType::RootScreenDocumentQuery,
"doc.png",
),
(
"Tokens",
RootScreenType::RootScreenMyTokenBalances,
"tokens.png",
),
(
"Wallets",
RootScreenType::RootScreenWalletsBalances,
"wallet.png",
),
(
"Tools",
RootScreenType::RootScreenToolsPlatformInfoScreen,
"tools.png",
),
("N", RootScreenType::RootScreenNetworkChooser, "config.png"),
(
"Settings",
RootScreenType::RootScreenNetworkChooser,
"config.png",
),
];

let panel_width = 60.0 + (Spacing::MD * 2.0); // Button width + margins
Expand All @@ -79,6 +94,7 @@ pub fn add_left_panel(

SidePanel::left("left_panel")
.default_width(panel_width + 20.0) // Add extra width for margins
.resizable(false)
.frame(
Frame::new()
.fill(DashColors::background(dark_mode))
Expand Down Expand Up @@ -118,6 +134,14 @@ pub fn add_left_panel(
} else if added.hovered() {
ui.ctx().set_cursor_icon(egui::CursorIcon::PointingHand);
}
// Put the label beneath the icon
let color = if is_selected {
DashColors::DASH_BLUE
} else {
DashColors::DEEP_BLUE
};
let label_text = RichText::new(*label).color(color).size(13.0);
ui.label(label_text);
} else {
// Fallback to a modern gradient button if texture loading fails
if is_selected {
Expand Down
1 change: 1 addition & 0 deletions src/ui/components/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ pub mod amount_input;
pub mod component_trait;
pub mod confirmation_dialog;
pub mod contract_chooser_panel;
pub mod contracts_subscreen_chooser_panel;
pub mod dpns_subscreen_chooser_panel;
pub mod entropy_grid;
pub mod identity_selector;
Expand Down
10 changes: 3 additions & 7 deletions src/ui/components/tokens_subscreen_chooser_panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,26 +27,22 @@ pub fn add_tokens_subscreen_chooser_panel(ctx: &Context, app_context: &AppContex
let dark_mode = ctx.style().visuals.dark_mode;

SidePanel::left("tokens_subscreen_chooser_panel")
.resizable(true)
.default_width(270.0) // Increased to account for margins
.resizable(false)
.default_width(270.0)
.frame(
Frame::new()
.fill(DashColors::background(dark_mode))
.inner_margin(Margin::symmetric(10, 10)), // Add margins for island effect
.inner_margin(Margin::symmetric(10, 10)),
)
.show(ctx, |ui| {
// Fill the entire available height
let available_height = ui.available_height();

// Create an island panel with rounded edges that fills the height
Frame::new()
.fill(DashColors::surface(dark_mode))
.stroke(egui::Stroke::new(1.0, DashColors::border_light(dark_mode)))
.inner_margin(Margin::same(Spacing::XL as i8))
.corner_radius(egui::CornerRadius::same(Shape::RADIUS_LG))
.shadow(Shadow::elevated())
.show(ui, |ui| {
// Account for both outer margin (10px * 2) and inner margin
ui.set_min_height(available_height - 2.0 - (Spacing::XL * 2.0));
// Display subscreen names
ui.vertical(|ui| {
Expand Down
Loading
Loading