mirror of
https://github.com/jwinterm/grim.git
synced 2026-10-17 22:21:27 +02:00
ui + wallet: add wallet content scroll, rename wallet module, add wallet tabs ids
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -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::*;
|
||||
|
||||
Reference in New Issue
Block a user