ui + wallet: add wallet content scroll, rename wallet module, add wallet tabs ids
This commit is contained in:
parent
b97cfb5d68
commit
7e9f020e51
3 changed files with 36 additions and 16 deletions
|
@ -14,7 +14,7 @@
|
||||||
|
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
use egui::{Margin, RichText};
|
use egui::{Margin, RichText, ScrollArea};
|
||||||
use grin_chain::SyncStatus;
|
use grin_chain::SyncStatus;
|
||||||
|
|
||||||
use crate::AppConfig;
|
use crate::AppConfig;
|
||||||
|
@ -91,21 +91,29 @@ impl WalletContent {
|
||||||
..Default::default()
|
..Default::default()
|
||||||
})
|
})
|
||||||
.show_inside(ui, |ui| {
|
.show_inside(ui, |ui| {
|
||||||
ui.vertical_centered(|ui| {
|
let scroll_id = format!("wallet_tab_{}_{}",
|
||||||
// Setup tab content width.
|
wallet.config.id,
|
||||||
let available_width = ui.available_width();
|
self.current_tab.get_type().id());
|
||||||
if available_width == 0.0 {
|
ScrollArea::vertical()
|
||||||
return;
|
.id_source(scroll_id)
|
||||||
}
|
.auto_shrink([false; 2])
|
||||||
let mut rect = ui.available_rect_before_wrap();
|
.show(ui, |ui| {
|
||||||
let width = f32::min(available_width, Root::SIDE_PANEL_WIDTH * 1.3);
|
ui.vertical_centered(|ui| {
|
||||||
rect.set_width(width);
|
// 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.
|
// Draw current tab content.
|
||||||
ui.allocate_ui(rect.size(), |ui| {
|
ui.allocate_ui(rect.size(), |ui| {
|
||||||
self.current_tab.ui(ui, frame, wallet, cb);
|
self.current_tab.ui(ui, frame, wallet, cb);
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Refresh content after 1 second for loaded wallet.
|
// Refresh content after 1 second for loaded wallet.
|
||||||
|
|
|
@ -32,4 +32,16 @@ pub enum WalletTabType {
|
||||||
Receive,
|
Receive,
|
||||||
Send,
|
Send,
|
||||||
Settings
|
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()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -24,8 +24,8 @@ pub use mnemonic::Mnemonic;
|
||||||
mod connections;
|
mod connections;
|
||||||
pub use connections::*;
|
pub use connections::*;
|
||||||
|
|
||||||
mod wallets;
|
mod wallet;
|
||||||
pub use wallets::*;
|
pub use wallet::*;
|
||||||
|
|
||||||
mod config;
|
mod config;
|
||||||
pub use config::*;
|
pub use config::*;
|
||||||
|
|
Loading…
Reference in a new issue