ui: fix wallets title navigation, change lock icon

This commit is contained in:
ardocrat 2023-08-01 17:23:09 +03:00
parent 9fabce685d
commit 65c27d250b

View file

@ -16,7 +16,7 @@ use egui::{Align, Align2, Layout, Margin, RichText, Rounding, ScrollArea, TextSt
use egui_extras::{Size, StripBuilder}; use egui_extras::{Size, StripBuilder};
use crate::gui::Colors; use crate::gui::Colors;
use crate::gui::icons::{ARROW_LEFT, CARET_RIGHT, COMPUTER_TOWER, EYE, EYE_SLASH, FOLDER_LOCK, FOLDER_OPEN, GEAR, GLOBE, GLOBE_SIMPLE, PLUS, SIDEBAR_SIMPLE, SUITCASE}; use crate::gui::icons::{ARROW_LEFT, CARET_RIGHT, COMPUTER_TOWER, EYE, EYE_SLASH, FOLDER_LOCK, FOLDER_OPEN, GEAR, GLOBE, GLOBE_SIMPLE, LOCK_KEY, PLUS, SIDEBAR_SIMPLE, SUITCASE};
use crate::gui::platform::PlatformCallbacks; use crate::gui::platform::PlatformCallbacks;
use crate::gui::views::{Modal, ModalContainer, ModalPosition, Root, TitlePanel, TitleType, View}; use crate::gui::views::{Modal, ModalContainer, ModalPosition, Root, TitlePanel, TitleType, View};
use crate::gui::views::wallets::creation::{MnemonicSetup, WalletCreation}; use crate::gui::views::wallets::creation::{MnemonicSetup, WalletCreation};
@ -115,14 +115,15 @@ impl WalletsContent {
let available_width_zero = ui.available_width() == 0.0; let available_width_zero = ui.available_width() == 0.0;
// Show title panel. // Show title panel.
self.title_ui(ui, frame, dual_panel); self.title_ui(ui, frame, dual_panel, create_wallet, show_wallet);
// Show wallet panel content. // Show wallet panel content.
egui::SidePanel::right("wallet_panel") egui::SidePanel::right("wallet_panel")
.resizable(false) .resizable(false)
.min_width(wallet_panel_width) .min_width(wallet_panel_width)
.frame(egui::Frame { .frame(egui::Frame {
fill: if empty_list && !create_wallet { fill: if empty_list && !create_wallet
|| (dual_panel && !self.show_list_at_dual_panel) {
Colors::FILL_DARK Colors::FILL_DARK
} else { } else {
Colors::WHITE Colors::WHITE
@ -202,9 +203,14 @@ impl WalletsContent {
} }
/// Draw [`TitlePanel`] content. /// Draw [`TitlePanel`] content.
fn title_ui(&mut self, ui: &mut egui::Ui, frame: &mut eframe::Frame, dual_panel: bool) { fn title_ui(&mut self,
ui: &mut egui::Ui,
frame: &mut eframe::Frame,
dual_panel: bool,
create_wallet: bool,
show_wallet: bool) {
// Setup title text. // Setup title text.
let title_text = if self.creation_content.can_go_back() { let title_text = if create_wallet {
t!("wallets.add") t!("wallets.add")
} else { } else {
t!("wallets.title") t!("wallets.title")
@ -213,15 +219,15 @@ impl WalletsContent {
// Draw title panel. // Draw title panel.
TitlePanel::ui(title_content, |ui, frame| { TitlePanel::ui(title_content, |ui, frame| {
if Wallets::selected_id().is_some() && !dual_panel { if show_wallet && !dual_panel {
View::title_button(ui, ARROW_LEFT, || { View::title_button(ui, ARROW_LEFT, || {
Wallets::select(None); Wallets::select(None);
}); });
} else if self.creation_content.can_go_back() { } else if create_wallet {
View::title_button(ui, ARROW_LEFT, || { View::title_button(ui, ARROW_LEFT, || {
self.creation_content.back(); self.creation_content.back();
}); });
} else if dual_panel { } else if show_wallet && dual_panel {
let show_list = self.show_list_at_dual_panel; let show_list = self.show_list_at_dual_panel;
let list_icon = if show_list { let list_icon = if show_list {
SIDEBAR_SIMPLE SIDEBAR_SIMPLE
@ -355,7 +361,7 @@ impl WalletsContent {
}); });
// Show button to close opened wallet. // Show button to close opened wallet.
View::item_button(ui, [false, false], FOLDER_LOCK, || { View::item_button(ui, [false, false], LOCK_KEY, || {
Wallets::close(id).unwrap() Wallets::close(id).unwrap()
}); });
} }