mirror of
https://github.com/jwinterm/grim.git
synced 2026-10-31 02:48:33 +01:00
ui: remove unused eframe argument
This commit is contained in:
+14
-9
@@ -27,31 +27,29 @@ lazy_static! {
|
||||
}
|
||||
|
||||
/// Implements ui entry point and contains platform-specific callbacks.
|
||||
pub struct PlatformApp<Platform> {
|
||||
pub struct App<Platform> {
|
||||
/// Platform specific callbacks handler.
|
||||
pub(crate) platform: Platform,
|
||||
/// Main ui content.
|
||||
root: Root
|
||||
}
|
||||
|
||||
impl<Platform> PlatformApp<Platform> {
|
||||
impl<Platform: PlatformCallbacks> App<Platform> {
|
||||
pub fn new(platform: Platform) -> Self {
|
||||
Self { platform, root: Root::default() }
|
||||
}
|
||||
}
|
||||
|
||||
impl<Platform: PlatformCallbacks> eframe::App for PlatformApp<Platform> {
|
||||
fn update(&mut self, ctx: &Context, frame: &mut eframe::Frame) {
|
||||
/// Draw application content.
|
||||
pub fn ui(&mut self, ctx: &Context) {
|
||||
// Handle Esc keyboard key event and platform Back button key event.
|
||||
let back_button_pressed = BACK_BUTTON_PRESSED.load(Ordering::Relaxed);
|
||||
if ctx.input_mut(|i| i.consume_key(Modifiers::NONE, egui::Key::Escape)) || back_button_pressed {
|
||||
self.root.on_back();
|
||||
// Request repaint to update previous content.
|
||||
ctx.request_repaint();
|
||||
|
||||
if back_button_pressed {
|
||||
BACK_BUTTON_PRESSED.store(false, Ordering::Relaxed);
|
||||
}
|
||||
// Request repaint to update previous content.
|
||||
ctx.request_repaint();
|
||||
}
|
||||
|
||||
// Handle Close event (on desktop).
|
||||
@@ -77,11 +75,18 @@ impl<Platform: PlatformCallbacks> eframe::App for PlatformApp<Platform> {
|
||||
..Default::default()
|
||||
})
|
||||
.show(ctx, |ui| {
|
||||
self.root.ui(ui, frame, &self.platform);
|
||||
self.root.ui(ui, &self.platform);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/// To draw with egui`s eframe (for wgpu, glow backends and wasm target).
|
||||
impl<Platform: PlatformCallbacks> eframe::App for App<Platform> {
|
||||
fn update(&mut self, ctx: &Context, _: &mut eframe::Frame) {
|
||||
self.ui(ctx);
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
#[cfg(target_os = "android")]
|
||||
#[allow(non_snake_case)]
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@
|
||||
|
||||
|
||||
mod app;
|
||||
pub use app::PlatformApp;
|
||||
pub use app::App;
|
||||
|
||||
mod colors;
|
||||
pub use colors::Colors;
|
||||
|
||||
@@ -66,7 +66,6 @@ impl ModalContainer for ConnectionsContent {
|
||||
|
||||
fn modal_ui(&mut self,
|
||||
ui: &mut egui::Ui,
|
||||
_: &mut eframe::Frame,
|
||||
modal: &Modal,
|
||||
cb: &dyn PlatformCallbacks) {
|
||||
match modal.id {
|
||||
@@ -80,9 +79,9 @@ impl ConnectionsContent {
|
||||
/// External connection [`Modal`] identifier.
|
||||
pub const NETWORK_EXT_CONNECTION_MODAL: &'static str = "network_ext_connection_modal";
|
||||
|
||||
pub fn ui(&mut self, ui: &mut egui::Ui, frame: &mut eframe::Frame, cb: &dyn PlatformCallbacks) {
|
||||
pub fn ui(&mut self, ui: &mut egui::Ui, cb: &dyn PlatformCallbacks) {
|
||||
// Draw modal content for current ui container.
|
||||
self.current_modal_ui(ui, frame, cb);
|
||||
self.current_modal_ui(ui, cb);
|
||||
|
||||
ui.add_space(2.0);
|
||||
|
||||
|
||||
@@ -43,12 +43,12 @@ impl Default for NetworkContent {
|
||||
}
|
||||
|
||||
impl NetworkContent {
|
||||
pub fn ui(&mut self, ui: &mut egui::Ui, frame: &mut eframe::Frame, cb: &dyn PlatformCallbacks) {
|
||||
pub fn ui(&mut self, ui: &mut egui::Ui, cb: &dyn PlatformCallbacks) {
|
||||
// Flag to show connections or integrated node content.
|
||||
let show_connections = AppConfig::show_connections_network_panel();
|
||||
|
||||
// Show title panel.
|
||||
self.title_ui(ui, frame, show_connections, cb);
|
||||
self.title_ui(ui, show_connections);
|
||||
|
||||
// Show integrated node tabs content.
|
||||
egui::TopBottomPanel::bottom("node_tabs_panel")
|
||||
@@ -94,7 +94,7 @@ impl NetworkContent {
|
||||
})
|
||||
.show_inside(ui, |ui| {
|
||||
// Draw node tab content.
|
||||
self.node_tab_content.ui(ui, frame, cb);
|
||||
self.node_tab_content.ui(ui, cb);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -140,7 +140,7 @@ impl NetworkContent {
|
||||
ui.available_width()
|
||||
};
|
||||
View::max_width_ui(ui, max_width, |ui| {
|
||||
self.connections.ui(ui, frame, cb);
|
||||
self.connections.ui(ui, cb);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -188,11 +188,7 @@ impl NetworkContent {
|
||||
}
|
||||
|
||||
/// Draw title content.
|
||||
fn title_ui(&mut self,
|
||||
ui: &mut egui::Ui,
|
||||
frame: &mut eframe::Frame,
|
||||
show_connections: bool,
|
||||
_: &dyn PlatformCallbacks) {
|
||||
fn title_ui(&mut self, ui: &mut egui::Ui, show_connections: bool) {
|
||||
// Setup values for title panel.
|
||||
let title_text = self.node_tab_content.get_type().title().to_uppercase();
|
||||
let subtitle_text = Node::get_sync_status_text();
|
||||
@@ -204,7 +200,7 @@ impl NetworkContent {
|
||||
};
|
||||
|
||||
// Draw title panel.
|
||||
TitlePanel::ui(TitleType::Single(title_content), |ui, _| {
|
||||
TitlePanel::ui(TitleType::Single(title_content), |ui| {
|
||||
if !show_connections {
|
||||
View::title_button(ui, DOTS_THREE_OUTLINE_VERTICAL, || {
|
||||
AppConfig::toggle_show_connections_network_panel();
|
||||
@@ -213,13 +209,13 @@ impl NetworkContent {
|
||||
}
|
||||
});
|
||||
}
|
||||
}, |ui, _| {
|
||||
}, |ui| {
|
||||
if !Root::is_dual_panel_mode(ui) {
|
||||
View::title_button(ui, BRIEFCASE, || {
|
||||
Root::toggle_network_panel();
|
||||
});
|
||||
}
|
||||
}, ui, frame);
|
||||
}, ui);
|
||||
}
|
||||
|
||||
/// Content to draw when node is disabled.
|
||||
|
||||
@@ -36,7 +36,7 @@ impl NetworkTab for NetworkMetrics {
|
||||
NetworkTabType::Metrics
|
||||
}
|
||||
|
||||
fn ui(&mut self, ui: &mut egui::Ui, _: &mut eframe::Frame, _: &dyn PlatformCallbacks) {
|
||||
fn ui(&mut self, ui: &mut egui::Ui, _: &dyn PlatformCallbacks) {
|
||||
// Show an error content when available.
|
||||
let node_err = Node::get_error();
|
||||
if node_err.is_some() {
|
||||
|
||||
@@ -44,7 +44,7 @@ impl NetworkTab for NetworkMining {
|
||||
NetworkTabType::Mining
|
||||
}
|
||||
|
||||
fn ui(&mut self, ui: &mut egui::Ui, frame: &mut eframe::Frame, cb: &dyn PlatformCallbacks) {
|
||||
fn ui(&mut self, ui: &mut egui::Ui, cb: &dyn PlatformCallbacks) {
|
||||
// Show an error content when available.
|
||||
let node_err = Node::get_error();
|
||||
if node_err.is_some() {
|
||||
@@ -83,7 +83,7 @@ impl NetworkTab for NetworkMining {
|
||||
ui.add_space(1.0);
|
||||
ui.vertical_centered(|ui| {
|
||||
View::max_width_ui(ui, Root::SIDE_PANEL_WIDTH * 1.3, |ui| {
|
||||
self.stratum_server_setup.ui(ui, frame, cb);
|
||||
self.stratum_server_setup.ui(ui, cb);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -32,7 +32,7 @@ impl NetworkTab for NetworkNode {
|
||||
NetworkTabType::Node
|
||||
}
|
||||
|
||||
fn ui(&mut self, ui: &mut egui::Ui, _: &mut eframe::Frame, _: &dyn PlatformCallbacks) {
|
||||
fn ui(&mut self, ui: &mut egui::Ui, _: &dyn PlatformCallbacks) {
|
||||
// Show an error content when available.
|
||||
let node_err = Node::get_error();
|
||||
if node_err.is_some() {
|
||||
|
||||
@@ -66,7 +66,6 @@ impl ModalContainer for NetworkSettings {
|
||||
|
||||
fn modal_ui(&mut self,
|
||||
ui: &mut egui::Ui,
|
||||
_: &mut eframe::Frame,
|
||||
modal: &Modal,
|
||||
_: &dyn PlatformCallbacks) {
|
||||
match modal.id {
|
||||
@@ -81,9 +80,9 @@ impl NetworkTab for NetworkSettings {
|
||||
NetworkTabType::Settings
|
||||
}
|
||||
|
||||
fn ui(&mut self, ui: &mut egui::Ui, frame: &mut eframe::Frame, cb: &dyn PlatformCallbacks) {
|
||||
fn ui(&mut self, ui: &mut egui::Ui, cb: &dyn PlatformCallbacks) {
|
||||
// Draw modal content for current ui container.
|
||||
self.current_modal_ui(ui, frame, cb);
|
||||
self.current_modal_ui(ui, cb);
|
||||
|
||||
ScrollArea::vertical()
|
||||
.id_source("network_settings")
|
||||
@@ -94,35 +93,35 @@ impl NetworkTab for NetworkSettings {
|
||||
ui.vertical_centered(|ui| {
|
||||
View::max_width_ui(ui, Root::SIDE_PANEL_WIDTH * 1.3, |ui| {
|
||||
// Draw node setup section.
|
||||
self.node.ui(ui, frame, cb);
|
||||
self.node.ui(ui, cb);
|
||||
|
||||
ui.add_space(6.0);
|
||||
View::horizontal_line(ui, Colors::stroke());
|
||||
ui.add_space(4.0);
|
||||
|
||||
// Draw P2P server setup section.
|
||||
self.p2p.ui(ui, frame, cb);
|
||||
self.p2p.ui(ui, cb);
|
||||
|
||||
ui.add_space(6.0);
|
||||
View::horizontal_line(ui, Colors::stroke());
|
||||
ui.add_space(4.0);
|
||||
|
||||
// Draw Stratum server setup section.
|
||||
self.stratum.ui(ui, frame, cb);
|
||||
self.stratum.ui(ui, cb);
|
||||
|
||||
ui.add_space(6.0);
|
||||
View::horizontal_line(ui, Colors::stroke());
|
||||
ui.add_space(4.0);
|
||||
|
||||
// Draw pool setup section.
|
||||
self.pool.ui(ui, frame, cb);
|
||||
self.pool.ui(ui, cb);
|
||||
|
||||
ui.add_space(6.0);
|
||||
View::horizontal_line(ui, Colors::stroke());
|
||||
ui.add_space(4.0);
|
||||
|
||||
// Draw Dandelion server setup section.
|
||||
self.dandelion.ui(ui, frame, cb);
|
||||
self.dandelion.ui(ui, cb);
|
||||
|
||||
ui.add_space(6.0);
|
||||
View::horizontal_line(ui, Colors::stroke());
|
||||
|
||||
@@ -73,7 +73,6 @@ impl ModalContainer for DandelionSetup {
|
||||
|
||||
fn modal_ui(&mut self,
|
||||
ui: &mut egui::Ui,
|
||||
_: &mut eframe::Frame,
|
||||
modal: &Modal,
|
||||
cb: &dyn PlatformCallbacks) {
|
||||
match modal.id {
|
||||
@@ -87,9 +86,9 @@ impl ModalContainer for DandelionSetup {
|
||||
}
|
||||
|
||||
impl DandelionSetup {
|
||||
pub fn ui(&mut self, ui: &mut egui::Ui, frame: &mut eframe::Frame, cb: &dyn PlatformCallbacks) {
|
||||
pub fn ui(&mut self, ui: &mut egui::Ui, cb: &dyn PlatformCallbacks) {
|
||||
// Draw modal content for current ui container.
|
||||
self.current_modal_ui(ui, frame, cb);
|
||||
self.current_modal_ui(ui, cb);
|
||||
|
||||
View::sub_title(ui, format!("{} {}", GRAPH, "Dandelion"));
|
||||
View::horizontal_line(ui, Colors::stroke());
|
||||
|
||||
@@ -84,7 +84,6 @@ impl ModalContainer for NodeSetup {
|
||||
|
||||
fn modal_ui(&mut self,
|
||||
ui: &mut egui::Ui,
|
||||
_: &mut eframe::Frame,
|
||||
modal: &Modal,
|
||||
cb: &dyn PlatformCallbacks) {
|
||||
match modal.id {
|
||||
@@ -98,9 +97,9 @@ impl ModalContainer for NodeSetup {
|
||||
}
|
||||
|
||||
impl NodeSetup {
|
||||
pub fn ui(&mut self, ui: &mut egui::Ui, frame: &mut eframe::Frame, cb: &dyn PlatformCallbacks) {
|
||||
pub fn ui(&mut self, ui: &mut egui::Ui, cb: &dyn PlatformCallbacks) {
|
||||
// Draw modal content for current ui container.
|
||||
self.current_modal_ui(ui, frame, cb);
|
||||
self.current_modal_ui(ui, cb);
|
||||
|
||||
View::sub_title(ui, format!("{} {}", COMPUTER_TOWER, t!("network_settings.server")));
|
||||
View::horizontal_line(ui, Colors::stroke());
|
||||
|
||||
@@ -132,7 +132,6 @@ impl ModalContainer for P2PSetup {
|
||||
|
||||
fn modal_ui(&mut self,
|
||||
ui: &mut egui::Ui,
|
||||
_: &mut eframe::Frame,
|
||||
modal: &Modal,
|
||||
cb: &dyn PlatformCallbacks) {
|
||||
match modal.id {
|
||||
@@ -153,9 +152,9 @@ impl P2PSetup {
|
||||
/// Title for custom DNS Seeds setup section.
|
||||
const DNS_SEEDS_TITLE: &'static str = "DNS Seeds";
|
||||
|
||||
pub fn ui(&mut self, ui: &mut egui::Ui, frame: &mut eframe::Frame, cb: &dyn PlatformCallbacks) {
|
||||
pub fn ui(&mut self, ui: &mut egui::Ui, cb: &dyn PlatformCallbacks) {
|
||||
// Draw modal content for current ui container.
|
||||
self.current_modal_ui(ui, frame, cb);
|
||||
self.current_modal_ui(ui, cb);
|
||||
|
||||
View::sub_title(ui, format!("{} {}", HANDSHAKE, t!("network_settings.p2p_server")));
|
||||
View::horizontal_line(ui, Colors::stroke());
|
||||
|
||||
@@ -80,7 +80,6 @@ impl ModalContainer for PoolSetup {
|
||||
|
||||
fn modal_ui(&mut self,
|
||||
ui: &mut egui::Ui,
|
||||
_: &mut eframe::Frame,
|
||||
modal: &Modal,
|
||||
cb: &dyn PlatformCallbacks) {
|
||||
match modal.id {
|
||||
@@ -95,9 +94,9 @@ impl ModalContainer for PoolSetup {
|
||||
}
|
||||
|
||||
impl PoolSetup {
|
||||
pub fn ui(&mut self, ui: &mut egui::Ui, frame: &mut eframe::Frame, cb: &dyn PlatformCallbacks) {
|
||||
pub fn ui(&mut self, ui: &mut egui::Ui, cb: &dyn PlatformCallbacks) {
|
||||
// Draw modal content for current ui container.
|
||||
self.current_modal_ui(ui, frame, cb);
|
||||
self.current_modal_ui(ui, cb);
|
||||
|
||||
View::sub_title(ui, format!("{} {}", CHART_SCATTER, t!("network_settings.tx_pool")));
|
||||
View::horizontal_line(ui, Colors::stroke());
|
||||
|
||||
@@ -79,7 +79,6 @@ impl ModalContainer for StratumSetup {
|
||||
|
||||
fn modal_ui(&mut self,
|
||||
ui: &mut egui::Ui,
|
||||
_: &mut eframe::Frame,
|
||||
modal: &Modal,
|
||||
cb: &dyn PlatformCallbacks) {
|
||||
match modal.id {
|
||||
@@ -92,9 +91,9 @@ impl ModalContainer for StratumSetup {
|
||||
}
|
||||
|
||||
impl StratumSetup {
|
||||
pub fn ui(&mut self, ui: &mut egui::Ui, frame: &mut eframe::Frame, cb: &dyn PlatformCallbacks) {
|
||||
pub fn ui(&mut self, ui: &mut egui::Ui, cb: &dyn PlatformCallbacks) {
|
||||
// Draw modal content for current ui container.
|
||||
self.current_modal_ui(ui, frame, cb);
|
||||
self.current_modal_ui(ui, cb);
|
||||
|
||||
View::sub_title(ui, format!("{} {}", HARD_DRIVES, t!("network_mining.server")));
|
||||
View::horizontal_line(ui, Colors::stroke());
|
||||
|
||||
@@ -17,7 +17,7 @@ use crate::gui::platform::PlatformCallbacks;
|
||||
/// Network tab content interface.
|
||||
pub trait NetworkTab {
|
||||
fn get_type(&self) -> NetworkTabType;
|
||||
fn ui(&mut self, ui: &mut egui::Ui, frame: &mut eframe::Frame, cb: &dyn PlatformCallbacks);
|
||||
fn ui(&mut self, ui: &mut egui::Ui, cb: &dyn PlatformCallbacks);
|
||||
}
|
||||
|
||||
/// Type of [`NetworkTab`] content.
|
||||
|
||||
@@ -76,7 +76,6 @@ impl ModalContainer for Root {
|
||||
|
||||
fn modal_ui(&mut self,
|
||||
ui: &mut egui::Ui,
|
||||
_: &mut eframe::Frame,
|
||||
modal: &Modal,
|
||||
_: &dyn PlatformCallbacks) {
|
||||
match modal.id {
|
||||
@@ -100,9 +99,9 @@ impl Root {
|
||||
/// Default width of side panel at application UI.
|
||||
pub const SIDE_PANEL_WIDTH: f32 = 400.0;
|
||||
|
||||
pub fn ui(&mut self, ui: &mut egui::Ui, frame: &mut eframe::Frame, cb: &dyn PlatformCallbacks) {
|
||||
pub fn ui(&mut self, ui: &mut egui::Ui, cb: &dyn PlatformCallbacks) {
|
||||
// Draw modal content for current ui container.
|
||||
self.current_modal_ui(ui, frame, cb);
|
||||
self.current_modal_ui(ui, cb);
|
||||
|
||||
let (is_panel_open, panel_width) = Self::network_panel_state_width(ui);
|
||||
// Show network content.
|
||||
@@ -119,7 +118,7 @@ impl Root {
|
||||
let window_size = View::window_size(ui);
|
||||
rect.set_height(window_size.1);
|
||||
ui.allocate_ui_at_rect(rect, |ui| {
|
||||
self.network.ui(ui, frame, cb);
|
||||
self.network.ui(ui, cb);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -135,7 +134,7 @@ impl Root {
|
||||
let window_size = View::window_size(ui);
|
||||
rect.set_height(window_size.1);
|
||||
ui.allocate_ui_at_rect(rect, |ui| {
|
||||
self.wallets.ui(ui, frame, cb);
|
||||
self.wallets.ui(ui, cb);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -27,10 +27,9 @@ impl TitlePanel {
|
||||
pub const DEFAULT_HEIGHT: f32 = 54.0;
|
||||
|
||||
pub fn ui(title: TitleType,
|
||||
mut left_content: impl FnMut(&mut egui::Ui, &mut eframe::Frame),
|
||||
mut right_content: impl FnMut(&mut egui::Ui, &mut eframe::Frame),
|
||||
ui: &mut egui::Ui,
|
||||
frame: &mut eframe::Frame) {
|
||||
mut left_content: impl FnMut(&mut egui::Ui),
|
||||
mut right_content: impl FnMut(&mut egui::Ui),
|
||||
ui: &mut egui::Ui) {
|
||||
// Setup identifier and title type.
|
||||
let (id, dual_title) = match &title {
|
||||
TitleType::Single(content) => {
|
||||
@@ -85,7 +84,7 @@ impl TitlePanel {
|
||||
strip.cell(|ui| {
|
||||
// Draw left panel action content.
|
||||
ui.centered_and_justified(|ui| {
|
||||
(left_content)(ui, frame);
|
||||
(left_content)(ui);
|
||||
});
|
||||
});
|
||||
// Draw title text content.
|
||||
@@ -104,7 +103,7 @@ impl TitlePanel {
|
||||
strip.cell(|ui| {
|
||||
// Draw right panel action content.
|
||||
ui.centered_and_justified(|ui| {
|
||||
(right_content)(ui, frame);
|
||||
(right_content)(ui);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -54,20 +54,18 @@ pub trait ModalContainer {
|
||||
/// Draw modal ui content.
|
||||
fn modal_ui(&mut self,
|
||||
ui: &mut egui::Ui,
|
||||
frame: &mut eframe::Frame,
|
||||
modal: &Modal,
|
||||
cb: &dyn PlatformCallbacks);
|
||||
|
||||
/// Draw [`Modal`] for current ui container if it's possible.
|
||||
fn current_modal_ui(&mut self,
|
||||
ui: &mut egui::Ui,
|
||||
frame: &mut eframe::Frame,
|
||||
cb: &dyn PlatformCallbacks) {
|
||||
let modal_id = Modal::opened();
|
||||
let draw = modal_id.is_some() && self.modal_ids().contains(&modal_id.unwrap());
|
||||
if draw {
|
||||
Modal::ui(ui.ctx(), |ui, modal| {
|
||||
self.modal_ui(ui, frame, modal, cb);
|
||||
self.modal_ui(ui, modal, cb);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,7 +76,6 @@ impl ModalContainer for WalletsContent {
|
||||
|
||||
fn modal_ui(&mut self,
|
||||
ui: &mut egui::Ui,
|
||||
_: &mut eframe::Frame,
|
||||
modal: &Modal,
|
||||
cb: &dyn PlatformCallbacks) {
|
||||
match modal.id {
|
||||
@@ -90,9 +89,9 @@ impl ModalContainer for WalletsContent {
|
||||
}
|
||||
|
||||
impl WalletsContent {
|
||||
pub fn ui(&mut self, ui: &mut egui::Ui, frame: &mut eframe::Frame, cb: &dyn PlatformCallbacks) {
|
||||
pub fn ui(&mut self, ui: &mut egui::Ui, cb: &dyn PlatformCallbacks) {
|
||||
// Draw modal content for current ui container.
|
||||
self.current_modal_ui(ui, frame, cb);
|
||||
self.current_modal_ui(ui, cb);
|
||||
|
||||
// Setup wallet content flags.
|
||||
let empty_list = self.wallets.is_current_list_empty();
|
||||
@@ -106,7 +105,7 @@ impl WalletsContent {
|
||||
let content_width = ui.available_width();
|
||||
|
||||
// Show title panel.
|
||||
self.title_ui(ui, frame, dual_panel, create_wallet, show_wallet);
|
||||
self.title_ui(ui, dual_panel, create_wallet, show_wallet);
|
||||
|
||||
// Show wallet panel content.
|
||||
egui::SidePanel::right("wallet_panel")
|
||||
@@ -132,7 +131,7 @@ impl WalletsContent {
|
||||
}
|
||||
if create_wallet || !show_wallet {
|
||||
// Show wallet creation content.
|
||||
self.creation_content.ui(ui, frame, cb, |wallet| {
|
||||
self.creation_content.ui(ui, cb, |wallet| {
|
||||
// Add created wallet to list.
|
||||
self.wallets.add(wallet);
|
||||
// Reset wallet content.
|
||||
@@ -153,7 +152,7 @@ impl WalletsContent {
|
||||
rect.set_width(width);
|
||||
// Show wallet content.
|
||||
ui.allocate_ui_at_rect(rect, |ui| {
|
||||
self.wallet_content.ui(ui, frame, wallet, cb);
|
||||
self.wallet_content.ui(ui, wallet, cb);
|
||||
});
|
||||
break;
|
||||
}
|
||||
@@ -224,7 +223,6 @@ impl WalletsContent {
|
||||
/// Draw [`TitlePanel`] content.
|
||||
fn title_ui(&mut self,
|
||||
ui: &mut egui::Ui,
|
||||
frame: &mut eframe::Frame,
|
||||
dual_panel: bool,
|
||||
create_wallet: bool,
|
||||
show_wallet: bool) {
|
||||
@@ -263,7 +261,7 @@ impl WalletsContent {
|
||||
};
|
||||
|
||||
// Draw title panel.
|
||||
TitlePanel::ui(title_content, |ui, _| {
|
||||
TitlePanel::ui(title_content, |ui| {
|
||||
if show_wallet && !dual_panel {
|
||||
View::title_button(ui, ARROW_LEFT, || {
|
||||
self.wallets.select(None);
|
||||
@@ -287,7 +285,7 @@ impl WalletsContent {
|
||||
Root::toggle_network_panel();
|
||||
});
|
||||
};
|
||||
}, |ui, _| {
|
||||
}, |ui| {
|
||||
View::title_button(ui, GEAR, || {
|
||||
// Show settings modal.
|
||||
Modal::new(Root::SETTINGS_MODAL)
|
||||
@@ -295,7 +293,7 @@ impl WalletsContent {
|
||||
.title(t!("settings"))
|
||||
.show();
|
||||
});
|
||||
}, ui, frame);
|
||||
}, ui);
|
||||
}
|
||||
|
||||
/// Calculate [`WalletContent`] panel width.
|
||||
|
||||
@@ -66,7 +66,6 @@ impl WalletCreation {
|
||||
/// Draw wallet creation content.
|
||||
pub fn ui(&mut self,
|
||||
ui: &mut egui::Ui,
|
||||
frame: &mut eframe::Frame,
|
||||
cb: &dyn PlatformCallbacks,
|
||||
on_create: impl FnOnce(Wallet)) {
|
||||
// Show wallet creation step description and confirmation panel.
|
||||
@@ -125,7 +124,7 @@ impl WalletCreation {
|
||||
Root::SIDE_PANEL_WIDTH * 2.0
|
||||
};
|
||||
View::max_width_ui(ui, max_width, |ui| {
|
||||
self.step_content_ui(ui, frame, cb);
|
||||
self.step_content_ui(ui, cb);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -312,10 +311,7 @@ impl WalletCreation {
|
||||
}
|
||||
|
||||
/// Draw wallet creation [`Step`] content.
|
||||
fn step_content_ui(&mut self,
|
||||
ui: &mut egui::Ui,
|
||||
frame: &mut eframe::Frame,
|
||||
cb: &dyn PlatformCallbacks) {
|
||||
fn step_content_ui(&mut self, ui: &mut egui::Ui, cb: &dyn PlatformCallbacks) {
|
||||
match &self.step {
|
||||
None => {
|
||||
// Show wallet creation message if step is empty.
|
||||
@@ -339,14 +335,14 @@ impl WalletCreation {
|
||||
}
|
||||
Some(step) => {
|
||||
match step {
|
||||
Step::EnterMnemonic => self.mnemonic_setup.ui(ui, frame, cb),
|
||||
Step::ConfirmMnemonic => self.mnemonic_setup.confirm_ui(ui, frame, cb),
|
||||
Step::EnterMnemonic => self.mnemonic_setup.ui(ui, cb),
|
||||
Step::ConfirmMnemonic => self.mnemonic_setup.confirm_ui(ui, cb),
|
||||
Step::SetupConnection => {
|
||||
// Redraw if node is running.
|
||||
if Node::is_running() {
|
||||
ui.ctx().request_repaint_after(Node::STATS_UPDATE_DELAY);
|
||||
}
|
||||
self.network_setup.create_ui(ui, frame, cb)
|
||||
self.network_setup.create_ui(ui, cb)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,7 +77,6 @@ impl ModalContainer for MnemonicSetup {
|
||||
|
||||
fn modal_ui(&mut self,
|
||||
ui: &mut egui::Ui,
|
||||
_: &mut eframe::Frame,
|
||||
modal: &Modal,
|
||||
cb: &dyn PlatformCallbacks) {
|
||||
match modal.id {
|
||||
@@ -90,9 +89,9 @@ impl ModalContainer for MnemonicSetup {
|
||||
|
||||
impl MnemonicSetup {
|
||||
/// Draw content for phrase input step.
|
||||
pub fn ui(&mut self, ui: &mut egui::Ui, frame: &mut eframe::Frame, cb: &dyn PlatformCallbacks) {
|
||||
pub fn ui(&mut self, ui: &mut egui::Ui, cb: &dyn PlatformCallbacks) {
|
||||
// Draw modal content for current ui container.
|
||||
self.current_modal_ui(ui, frame, cb);
|
||||
self.current_modal_ui(ui, cb);
|
||||
|
||||
ui.add_space(10.0);
|
||||
|
||||
@@ -108,12 +107,9 @@ impl MnemonicSetup {
|
||||
}
|
||||
|
||||
/// Draw content for phrase confirmation step.
|
||||
pub fn confirm_ui(&mut self,
|
||||
ui: &mut egui::Ui,
|
||||
frame: &mut eframe::Frame,
|
||||
cb: &dyn PlatformCallbacks) {
|
||||
pub fn confirm_ui(&mut self, ui: &mut egui::Ui, cb: &dyn PlatformCallbacks) {
|
||||
// Draw modal content for current ui container.
|
||||
self.current_modal_ui(ui, frame, cb);
|
||||
self.current_modal_ui(ui, cb);
|
||||
|
||||
ui.add_space(4.0);
|
||||
ui.vertical_centered(|ui| {
|
||||
|
||||
@@ -60,11 +60,7 @@ impl Default for CommonSetup {
|
||||
}
|
||||
|
||||
impl CommonSetup {
|
||||
pub fn ui(&mut self,
|
||||
ui: &mut egui::Ui,
|
||||
_: &mut eframe::Frame,
|
||||
wallet: &mut Wallet,
|
||||
cb: &dyn PlatformCallbacks) {
|
||||
pub fn ui(&mut self, ui: &mut egui::Ui, wallet: &mut Wallet, cb: &dyn PlatformCallbacks) {
|
||||
// Show modal content for this ui container.
|
||||
self.modal_content_ui(ui, wallet, cb);
|
||||
|
||||
|
||||
@@ -70,7 +70,6 @@ impl ModalContainer for ConnectionSetup {
|
||||
|
||||
fn modal_ui(&mut self,
|
||||
ui: &mut egui::Ui,
|
||||
_: &mut eframe::Frame,
|
||||
modal: &Modal,
|
||||
cb: &dyn PlatformCallbacks) {
|
||||
match modal.id {
|
||||
@@ -82,41 +81,34 @@ impl ModalContainer for ConnectionSetup {
|
||||
|
||||
impl ConnectionSetup {
|
||||
/// Draw wallet creation setup content.
|
||||
pub fn create_ui(&mut self,
|
||||
ui: &mut egui::Ui,
|
||||
frame: &mut eframe::Frame,
|
||||
cb: &dyn PlatformCallbacks) {
|
||||
self.ui(ui, frame, None, cb);
|
||||
pub fn create_ui(&mut self, ui: &mut egui::Ui, cb: &dyn PlatformCallbacks) {
|
||||
self.ui(ui, None, cb);
|
||||
}
|
||||
|
||||
/// Draw existing wallet connection setup content.
|
||||
pub fn wallet_ui(&mut self,
|
||||
ui: &mut egui::Ui,
|
||||
frame: &mut eframe::Frame,
|
||||
wallet: &mut Wallet,
|
||||
cb: &dyn PlatformCallbacks) {
|
||||
pub fn wallet_ui(&mut self, ui: &mut egui::Ui, w: &mut Wallet, cb: &dyn PlatformCallbacks) {
|
||||
// Setup connection value from provided wallet.
|
||||
match wallet.get_config().ext_conn_id {
|
||||
match w.get_config().ext_conn_id {
|
||||
None => self.method = ConnectionMethod::Integrated,
|
||||
Some(id) => self.method = ConnectionMethod::External(id)
|
||||
}
|
||||
|
||||
// Draw setup content.
|
||||
self.ui(ui, frame, Some(wallet), cb);
|
||||
self.ui(ui, Some(w), cb);
|
||||
|
||||
// Setup wallet connection value after change.
|
||||
let changed = match self.method {
|
||||
ConnectionMethod::Integrated => {
|
||||
let changed = wallet.get_current_ext_conn().is_some();
|
||||
let changed = w.get_current_ext_conn().is_some();
|
||||
if changed {
|
||||
wallet.update_ext_conn_id(None);
|
||||
w.update_ext_conn_id(None);
|
||||
}
|
||||
changed
|
||||
}
|
||||
ConnectionMethod::External(id) => {
|
||||
let changed = wallet.get_config().ext_conn_id != Some(id);
|
||||
let changed = w.get_config().ext_conn_id != Some(id);
|
||||
if changed {
|
||||
wallet.update_ext_conn_id(Some(id));
|
||||
w.update_ext_conn_id(Some(id));
|
||||
}
|
||||
changed
|
||||
}
|
||||
@@ -124,9 +116,9 @@ impl ConnectionSetup {
|
||||
|
||||
// Reopen wallet if connection changed.
|
||||
if changed {
|
||||
if !wallet.reopen_needed() {
|
||||
wallet.set_reopen(true);
|
||||
wallet.close();
|
||||
if !w.reopen_needed() {
|
||||
w.set_reopen(true);
|
||||
w.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -134,11 +126,10 @@ impl ConnectionSetup {
|
||||
/// Draw connection setup content.
|
||||
fn ui(&mut self,
|
||||
ui: &mut egui::Ui,
|
||||
frame: &mut eframe::Frame,
|
||||
wallet: Option<&Wallet>,
|
||||
cb: &dyn PlatformCallbacks) {
|
||||
// Draw modal content for current ui container.
|
||||
self.current_modal_ui(ui, frame, cb);
|
||||
self.current_modal_ui(ui, cb);
|
||||
|
||||
ui.add_space(2.0);
|
||||
View::sub_title(ui, format!("{} {}", GLOBE, t!("wallets.conn_method")));
|
||||
|
||||
@@ -51,11 +51,7 @@ impl Default for RecoverySetup {
|
||||
}
|
||||
|
||||
impl RecoverySetup {
|
||||
pub fn ui(&mut self,
|
||||
ui: &mut egui::Ui,
|
||||
_: &mut eframe::Frame,
|
||||
wallet: &mut Wallet,
|
||||
cb: &dyn PlatformCallbacks) {
|
||||
pub fn ui(&mut self, ui: &mut egui::Ui, wallet: &mut Wallet, cb: &dyn PlatformCallbacks) {
|
||||
// Show modal content for this ui container.
|
||||
self.modal_content_ui(ui, wallet, cb);
|
||||
|
||||
|
||||
@@ -75,7 +75,6 @@ impl WalletContent {
|
||||
/// Draw wallet content.
|
||||
pub fn ui(&mut self,
|
||||
ui: &mut egui::Ui,
|
||||
frame: &mut eframe::Frame,
|
||||
wallet: &mut Wallet,
|
||||
cb: &dyn PlatformCallbacks) {
|
||||
// Show modal content for this ui container.
|
||||
@@ -153,7 +152,7 @@ impl WalletContent {
|
||||
..Default::default()
|
||||
})
|
||||
.show_inside(ui, |ui| {
|
||||
self.current_tab.ui(ui, frame, wallet, cb);
|
||||
self.current_tab.ui(ui, wallet, cb);
|
||||
});
|
||||
|
||||
// Refresh content after 1 second for synced wallet.
|
||||
|
||||
@@ -117,11 +117,7 @@ impl WalletTab for WalletMessages {
|
||||
WalletTabType::Messages
|
||||
}
|
||||
|
||||
fn ui(&mut self,
|
||||
ui: &mut egui::Ui,
|
||||
_: &mut eframe::Frame,
|
||||
wallet: &mut Wallet,
|
||||
cb: &dyn PlatformCallbacks) {
|
||||
fn ui(&mut self, ui: &mut egui::Ui, wallet: &mut Wallet, cb: &dyn PlatformCallbacks) {
|
||||
if WalletContent::sync_ui(ui, wallet) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -52,7 +52,6 @@ impl WalletTab for WalletSettings {
|
||||
|
||||
fn ui(&mut self,
|
||||
ui: &mut egui::Ui,
|
||||
frame: &mut eframe::Frame,
|
||||
wallet: &mut Wallet,
|
||||
cb: &dyn PlatformCallbacks) {
|
||||
// Show loading progress if navigation is blocked.
|
||||
@@ -83,11 +82,11 @@ impl WalletTab for WalletSettings {
|
||||
ui.vertical_centered(|ui| {
|
||||
View::max_width_ui(ui, Root::SIDE_PANEL_WIDTH * 1.3, |ui| {
|
||||
// Show common wallet setup.
|
||||
self.common_setup.ui(ui, frame, wallet, cb);
|
||||
self.common_setup.ui(ui, wallet, cb);
|
||||
// Show wallet connections setup.
|
||||
self.conn_setup.wallet_ui(ui, frame, wallet, cb);
|
||||
self.conn_setup.wallet_ui(ui, wallet, cb);
|
||||
// Show wallet recovery setup.
|
||||
self.recovery_setup.ui(ui, frame, wallet, cb);
|
||||
self.recovery_setup.ui(ui, wallet, cb);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -77,7 +77,6 @@ impl WalletTab for WalletTransport {
|
||||
|
||||
fn ui(&mut self,
|
||||
ui: &mut egui::Ui,
|
||||
_: &mut eframe::Frame,
|
||||
wallet: &mut Wallet,
|
||||
cb: &dyn PlatformCallbacks) {
|
||||
if WalletContent::sync_ui(ui, wallet) {
|
||||
|
||||
@@ -97,11 +97,7 @@ impl WalletTab for WalletTransactions {
|
||||
WalletTabType::Txs
|
||||
}
|
||||
|
||||
fn ui(&mut self,
|
||||
ui: &mut egui::Ui,
|
||||
_: &mut eframe::Frame,
|
||||
wallet: &mut Wallet,
|
||||
cb: &dyn PlatformCallbacks) {
|
||||
fn ui(&mut self, ui: &mut egui::Ui, wallet: &mut Wallet, cb: &dyn PlatformCallbacks) {
|
||||
if WalletContent::sync_ui(ui, wallet) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -25,7 +25,6 @@ pub trait WalletTab {
|
||||
fn get_type(&self) -> WalletTabType;
|
||||
fn ui(&mut self,
|
||||
ui: &mut egui::Ui,
|
||||
frame: &mut eframe::Frame,
|
||||
wallet: &mut Wallet,
|
||||
cb: &dyn PlatformCallbacks);
|
||||
}
|
||||
|
||||
+7
-7
@@ -24,7 +24,7 @@ use winit::platform::android::activity::AndroidApp;
|
||||
pub use settings::AppConfig;
|
||||
pub use settings::Settings;
|
||||
|
||||
use crate::gui::{Colors, PlatformApp};
|
||||
use crate::gui::{Colors, App};
|
||||
use crate::gui::platform::PlatformCallbacks;
|
||||
use crate::gui::views::View;
|
||||
use crate::node::Node;
|
||||
@@ -62,7 +62,7 @@ fn android_main(app: AndroidApp) {
|
||||
|
||||
// Setup system theme if not set.
|
||||
if let None = AppConfig::dark_theme() {
|
||||
let use_dark = system_dark_theme(&platform);
|
||||
let use_dark = use_dark_theme(&platform);
|
||||
AppConfig::set_dark_theme(use_dark);
|
||||
}
|
||||
|
||||
@@ -89,21 +89,21 @@ fn android_main(app: AndroidApp) {
|
||||
builder.with_android_app(app);
|
||||
}));
|
||||
|
||||
let app = PlatformApp::new(platform);
|
||||
let app = App::new(platform);
|
||||
start(options, app_creator(app)).unwrap();
|
||||
}
|
||||
|
||||
/// Check if system is using dark theme.
|
||||
#[allow(dead_code)]
|
||||
#[cfg(target_os = "android")]
|
||||
fn system_dark_theme(platform: &gui::platform::Android) -> bool {
|
||||
fn use_dark_theme(platform: &gui::platform::Android) -> bool {
|
||||
let res = platform.call_java_method("useDarkTheme", "()Z", &[]).unwrap();
|
||||
unsafe { res.z != 0 }
|
||||
}
|
||||
|
||||
/// [`PlatformApp`] setup for [`eframe`].
|
||||
pub fn app_creator<T: 'static>(app: PlatformApp<T>) -> eframe::AppCreator
|
||||
where PlatformApp<T>: eframe::App, T: PlatformCallbacks {
|
||||
/// [`App`] setup for [`eframe`].
|
||||
pub fn app_creator<T: 'static>(app: App<T>) -> eframe::AppCreator
|
||||
where App<T>: eframe::App, T: PlatformCallbacks {
|
||||
Box::new(|cc| {
|
||||
// Setup images support.
|
||||
egui_extras::install_image_loaders(&cc.egui_ctx);
|
||||
|
||||
+12
-3
@@ -12,6 +12,9 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
use grim::gui::App;
|
||||
use grim::gui::platform::Desktop;
|
||||
|
||||
pub fn main() {
|
||||
#[allow(dead_code)]
|
||||
#[cfg(not(target_os = "android"))]
|
||||
@@ -28,7 +31,7 @@ fn real_main() {
|
||||
.init();
|
||||
|
||||
use grim::gui::platform::Desktop;
|
||||
use grim::gui::PlatformApp;
|
||||
use grim::gui::App;
|
||||
use grim::AppConfig;
|
||||
|
||||
use std::sync::Arc;
|
||||
@@ -69,12 +72,18 @@ fn real_main() {
|
||||
..Default::default()
|
||||
};
|
||||
options.renderer = eframe::Renderer::Wgpu;
|
||||
match grim::start(options.clone(), grim::app_creator(PlatformApp::new(platform.clone()))) {
|
||||
|
||||
match grim::start(options.clone(), grim::app_creator(App::new(platform.clone()))) {
|
||||
Ok(_) => {}
|
||||
Err(_) => {
|
||||
// Start with Glow renderer on error.
|
||||
options.renderer = eframe::Renderer::Glow;
|
||||
grim::start(options, grim::app_creator(PlatformApp::new(platform))).unwrap();
|
||||
match grim::start(options, grim::app_creator(App::new(platform))) {
|
||||
Ok(_) => {}
|
||||
Err(_) => {
|
||||
panic!("Impossible to render");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user