From 7e9f020e51b162aa74365e861e002a8dd0492918 Mon Sep 17 00:00:00 2001 From: ardocrat Date: Sat, 12 Aug 2023 20:08:14 +0300 Subject: [PATCH] ui + wallet: add wallet content scroll, rename wallet module, add wallet tabs ids --- src/gui/views/wallets/wallet/content.rs | 36 +++++++++++++++---------- src/gui/views/wallets/wallet/types.rs | 12 +++++++++ src/wallet/mod.rs | 4 +-- 3 files changed, 36 insertions(+), 16 deletions(-) diff --git a/src/gui/views/wallets/wallet/content.rs b/src/gui/views/wallets/wallet/content.rs index 35a2406..44d1a01 100644 --- a/src/gui/views/wallets/wallet/content.rs +++ b/src/gui/views/wallets/wallet/content.rs @@ -14,7 +14,7 @@ use std::time::Duration; -use egui::{Margin, RichText}; +use egui::{Margin, RichText, ScrollArea}; use grin_chain::SyncStatus; use crate::AppConfig; @@ -91,21 +91,29 @@ impl WalletContent { ..Default::default() }) .show_inside(ui, |ui| { - ui.vertical_centered(|ui| { - // Setup tab content width. - let available_width = ui.available_width(); - if available_width == 0.0 { - return; - } - let mut rect = ui.available_rect_before_wrap(); - let width = f32::min(available_width, Root::SIDE_PANEL_WIDTH * 1.3); - rect.set_width(width); + let scroll_id = format!("wallet_tab_{}_{}", + wallet.config.id, + self.current_tab.get_type().id()); + ScrollArea::vertical() + .id_source(scroll_id) + .auto_shrink([false; 2]) + .show(ui, |ui| { + ui.vertical_centered(|ui| { + // Setup tab content width. + let available_width = ui.available_width(); + if available_width == 0.0 { + return; + } + let mut rect = ui.available_rect_before_wrap(); + let width = f32::min(available_width, Root::SIDE_PANEL_WIDTH * 1.3); + rect.set_width(width); - // Draw current tab content. - ui.allocate_ui(rect.size(), |ui| { - self.current_tab.ui(ui, frame, wallet, cb); + // Draw current tab content. + ui.allocate_ui(rect.size(), |ui| { + self.current_tab.ui(ui, frame, wallet, cb); + }); + }); }); - }); }); // Refresh content after 1 second for loaded wallet. diff --git a/src/gui/views/wallets/wallet/types.rs b/src/gui/views/wallets/wallet/types.rs index 0dc2504..b090c44 100644 --- a/src/gui/views/wallets/wallet/types.rs +++ b/src/gui/views/wallets/wallet/types.rs @@ -32,4 +32,16 @@ pub enum WalletTabType { Receive, Send, Settings +} + +impl WalletTabType { + /// Identifier representing wallet tab type. + pub fn id(&self) -> String { + match *self { + WalletTabType::Info => "info".to_owned(), + WalletTabType::Receive => "receive".to_owned(), + WalletTabType::Send => "send".to_owned(), + WalletTabType::Settings => "settings".to_owned() + } + } } \ No newline at end of file diff --git a/src/wallet/mod.rs b/src/wallet/mod.rs index 3f2e25b..7f57528 100644 --- a/src/wallet/mod.rs +++ b/src/wallet/mod.rs @@ -24,8 +24,8 @@ pub use mnemonic::Mnemonic; mod connections; pub use connections::*; -mod wallets; -pub use wallets::*; +mod wallet; +pub use wallet::*; mod config; pub use config::*;