ui: selected wallet title

This commit is contained in:
ardocrat 2023-08-09 22:58:07 +03:00
parent e235123516
commit 065f7d6cd5
2 changed files with 21 additions and 3 deletions

View file

@ -229,13 +229,22 @@ impl WalletsContent {
dual_panel: bool,
create_wallet: bool,
show_wallet: bool) {
// Setup title text.
let show_list = self.show_wallets_at_dual_panel;
// Setup title.
let title_text = if create_wallet {
t!("wallets.add")
} else {
t!("wallets.title")
};
let title_content = TitleType::Single(title_text.to_uppercase());
let title_content = if self.wallets.is_selected_open() && (!dual_panel
|| (dual_panel && !show_list)) {
let title_text = t!("wallets.wallet").to_uppercase();
let subtitle_text = self.wallets.selected_name();
TitleType::WithSubTitle(title_text, subtitle_text, false)
} else {
TitleType::Single(title_text.to_uppercase())
};
// Draw title panel.
TitlePanel::ui(title_content, |ui, frame| {
@ -248,7 +257,6 @@ impl WalletsContent {
self.creation_content.back();
});
} else if show_wallet && dual_panel {
let show_list = self.show_wallets_at_dual_panel;
let list_icon = if show_list {
SIDEBAR_SIMPLE
} else {

View file

@ -88,6 +88,16 @@ impl Wallets {
self.selected_id = id;
}
/// Get selected [`Wallet`] name.
pub fn selected_name(&self) -> String {
for w in &self.list {
if Some(w.config.id) == self.selected_id {
return w.config.name.to_owned()
}
}
t!("wallets.unlocked")
}
/// Check if [`Wallet`] is selected for provided identifier.
pub fn is_selected(&self, id: i64) -> bool {
return Some(id) == self.selected_id;