ui + wallets: add title panel text alignment, optimize connection creation modal, optimize wallet panels size, make wallet creation callback not optional, update translations, fix wallet list sorting
This commit is contained in:
parent
d466cb1d9c
commit
9d12e95d0b
10 changed files with 56 additions and 37 deletions
|
@ -6,6 +6,7 @@ closing: Closing
|
|||
loading: Loading
|
||||
loading_error: Loading error
|
||||
retry: Retry
|
||||
close: Close
|
||||
wallets:
|
||||
title: Wallets
|
||||
create_desc: Create or import existing wallet from saved recovery phrase.
|
||||
|
|
|
@ -6,6 +6,7 @@ closing: Закрывается
|
|||
loading: Загружается
|
||||
loading_error: Ошибка загрузки
|
||||
retry: Повторить
|
||||
close: Закрыть
|
||||
wallets:
|
||||
title: Кошельки
|
||||
create_desc: Создайте или импортируйте существующий кошелёк из сохранённой фразы восстановления.
|
||||
|
|
|
@ -202,18 +202,7 @@ impl ConnectionsContent {
|
|||
ConnectionsConfig::remove_ext_conn(conn.id);
|
||||
});
|
||||
View::item_button(ui, Rounding::none(), PENCIL, None, || {
|
||||
// Setup values for Modal.
|
||||
self.first_modal_launch = true;
|
||||
self.ext_node_url_edit = conn.url.clone();
|
||||
self.ext_node_secret_edit = conn.secret.clone().unwrap_or("".to_string());
|
||||
self.ext_node_url_error = false;
|
||||
self.ext_conn_id_edit = Some(conn.id);
|
||||
// Show modal.
|
||||
Modal::new(Self::NETWORK_EXT_CONNECTION_MODAL)
|
||||
.position(ModalPosition::CenterTop)
|
||||
.title(t!("wallets.add_node"))
|
||||
.show();
|
||||
cb.show_keyboard();
|
||||
self.show_add_ext_conn_modal(Some(conn), cb);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -246,13 +235,21 @@ impl ConnectionsContent {
|
|||
}
|
||||
|
||||
/// Show [`Modal`] to add external connection.
|
||||
pub fn show_add_ext_conn_modal(&mut self, cb: &dyn PlatformCallbacks) {
|
||||
// Setup values for Modal.
|
||||
pub fn show_add_ext_conn_modal(&mut self,
|
||||
conn: Option<&ExternalConnection>,
|
||||
cb: &dyn PlatformCallbacks) {
|
||||
// Setup values.
|
||||
self.first_modal_launch = true;
|
||||
self.ext_node_url_error = false;
|
||||
if let Some(c) = conn {
|
||||
self.ext_node_url_edit = c.url.to_owned();
|
||||
self.ext_node_secret_edit = c.secret.clone().unwrap_or("".to_string());
|
||||
self.ext_conn_id_edit = Some(c.id);
|
||||
} else {
|
||||
self.ext_node_url_edit = "".to_string();
|
||||
self.ext_node_secret_edit = "".to_string();
|
||||
self.ext_node_url_error = false;
|
||||
self.ext_conn_id_edit = None;
|
||||
}
|
||||
// Show modal.
|
||||
Modal::new(Self::NETWORK_EXT_CONNECTION_MODAL)
|
||||
.position(ModalPosition::CenterTop)
|
||||
|
|
|
@ -199,7 +199,7 @@ impl NetworkContent {
|
|||
let title_content = if !show_connections {
|
||||
TitleType::WithSubTitle(title_text, subtitle_text, !not_syncing)
|
||||
} else {
|
||||
TitleType::Single(t!("network.connections").to_uppercase())
|
||||
TitleType::Single(t!("network.connections").to_uppercase(), false)
|
||||
};
|
||||
|
||||
// Draw title panel.
|
||||
|
@ -213,7 +213,7 @@ impl NetworkContent {
|
|||
});
|
||||
} else {
|
||||
View::title_button(ui, PLUS_CIRCLE, || {
|
||||
self.connections.show_add_ext_conn_modal(cb);
|
||||
self.connections.show_add_ext_conn_modal(None, cb);
|
||||
});
|
||||
}
|
||||
}, |ui, frame| {
|
||||
|
|
|
@ -18,7 +18,7 @@ use egui_extras::{Size, StripBuilder};
|
|||
|
||||
use crate::gui::Colors;
|
||||
use crate::gui::views::types::TitleType;
|
||||
use crate::gui::views::View;
|
||||
use crate::gui::views::{Root, View};
|
||||
|
||||
/// Title panel with left/right action buttons and text in the middle.
|
||||
pub struct TitlePanel;
|
||||
|
@ -32,11 +32,12 @@ impl TitlePanel {
|
|||
mut right_content: impl FnMut(&mut egui::Ui, &mut eframe::Frame),
|
||||
ui: &mut egui::Ui,
|
||||
frame: &mut eframe::Frame) {
|
||||
// Setup identifier.
|
||||
let id = match &title {
|
||||
TitleType::Single(text) => Id::from(text.clone()),
|
||||
TitleType::WithSubTitle(text, _, _) => Id::from(text.clone())
|
||||
// Setup identifier and alignment.
|
||||
let (id, align_left) = match &title {
|
||||
TitleType::Single(text, align_left) => (Id::from(text.clone()), *align_left),
|
||||
TitleType::WithSubTitle(text, _, _) => (Id::from(text.clone()), false)
|
||||
};
|
||||
// Draw title panel.
|
||||
egui::TopBottomPanel::top(id)
|
||||
.resizable(false)
|
||||
.exact_height(Self::DEFAULT_HEIGHT)
|
||||
|
@ -48,16 +49,26 @@ impl TitlePanel {
|
|||
.show_inside(ui, |ui| {
|
||||
StripBuilder::new(ui)
|
||||
.size(Size::exact(Self::DEFAULT_HEIGHT))
|
||||
.size(Size::remainder())
|
||||
.size(if align_left {
|
||||
Size::exact(Root::SIDE_PANEL_WIDTH - 2.0 * Self::DEFAULT_HEIGHT)
|
||||
} else {
|
||||
Size::remainder()
|
||||
})
|
||||
.size(if align_left {
|
||||
Size::remainder()
|
||||
} else {
|
||||
Size::exact(0.0)
|
||||
})
|
||||
.size(Size::exact(Self::DEFAULT_HEIGHT))
|
||||
.horizontal(|mut strip| {
|
||||
strip.cell(|ui| {
|
||||
// Draw left panel action content.
|
||||
ui.centered_and_justified(|ui| {
|
||||
(left_content)(ui, frame);
|
||||
});
|
||||
});
|
||||
match title {
|
||||
TitleType::Single(text) => {
|
||||
TitleType::Single(text, _) => {
|
||||
strip.cell(|ui| {
|
||||
ui.add_space(2.0);
|
||||
ui.centered_and_justified(|ui| {
|
||||
|
@ -71,7 +82,9 @@ impl TitlePanel {
|
|||
});
|
||||
}
|
||||
}
|
||||
strip.empty();
|
||||
strip.cell(|ui| {
|
||||
// Draw right panel action content.
|
||||
ui.centered_and_justified(|ui| {
|
||||
(right_content)(ui, frame);
|
||||
});
|
||||
|
|
|
@ -17,8 +17,8 @@ use crate::gui::views::Modal;
|
|||
|
||||
/// Title content type, can be single title or with animated subtitle.
|
||||
pub enum TitleType {
|
||||
/// Single text.
|
||||
Single(String),
|
||||
/// Single text with possibility to align text at left side at default panel size width.
|
||||
Single(String, bool),
|
||||
/// With animated subtitle text.
|
||||
WithSubTitle(String, String, bool)
|
||||
}
|
||||
|
|
|
@ -135,6 +135,8 @@ impl WalletsContent {
|
|||
if create_wallet || !show_wallet {
|
||||
// Show wallet creation content.
|
||||
self.creation_content.ui(ui, frame, cb, |wallet| {
|
||||
// Reset wallet content.
|
||||
self.wallet_content = WalletContent::default();
|
||||
// Add created wallet to list.
|
||||
self.wallets.add(wallet);
|
||||
});
|
||||
|
@ -240,7 +242,7 @@ impl WalletsContent {
|
|||
let subtitle_text = self.wallets.selected_name();
|
||||
TitleType::WithSubTitle(title_text, subtitle_text, false)
|
||||
} else {
|
||||
TitleType::Single(title_text.to_uppercase())
|
||||
TitleType::Single(title_text.to_uppercase(), show_wallet && dual_panel)
|
||||
};
|
||||
|
||||
// Draw title panel.
|
||||
|
@ -381,6 +383,9 @@ impl WalletsContent {
|
|||
if !is_selected {
|
||||
// Show button to select opened wallet.
|
||||
View::item_button(ui, View::item_rounding(0, 1, true), CARET_RIGHT, None, || {
|
||||
// Reset wallet content.
|
||||
self.wallet_content = WalletContent::default();
|
||||
// Select wallet.
|
||||
self.wallets.select(Some(id));
|
||||
});
|
||||
}
|
||||
|
@ -564,6 +569,8 @@ impl WalletsContent {
|
|||
// Close modal.
|
||||
cb.hide_keyboard();
|
||||
modal.close();
|
||||
// Reset wallet content.
|
||||
self.wallet_content = WalletContent::default();
|
||||
}
|
||||
Err(_) => self.wrong_pass = true
|
||||
}
|
||||
|
|
|
@ -218,7 +218,7 @@ impl WalletCreation {
|
|||
ui.add_space(4.0);
|
||||
// Show button.
|
||||
View::button(ui, next_text.to_uppercase(), color, || {
|
||||
self.forward(Some(on_create));
|
||||
self.forward(on_create);
|
||||
});
|
||||
ui.add_space(4.0);
|
||||
}
|
||||
|
@ -289,7 +289,7 @@ impl WalletCreation {
|
|||
}
|
||||
|
||||
/// Go to the next wallet creation [`Step`].
|
||||
fn forward(&mut self, on_create: Option<impl FnOnce(Wallet)>) {
|
||||
fn forward(&mut self, on_create: impl FnOnce(Wallet)) {
|
||||
self.step = if let Some(step) = &self.step {
|
||||
match step {
|
||||
Step::EnterMnemonic => {
|
||||
|
@ -315,7 +315,7 @@ impl WalletCreation {
|
|||
// Open created wallet.
|
||||
wallet.open(pass).unwrap();
|
||||
// Pass created wallet to callback.
|
||||
(on_create.unwrap())(wallet);
|
||||
(on_create)(wallet);
|
||||
// Reset input data.
|
||||
self.reset();
|
||||
None
|
||||
|
|
|
@ -65,7 +65,7 @@ impl WalletContent {
|
|||
return;
|
||||
}
|
||||
let mut rect = ui.available_rect_before_wrap();
|
||||
let width = f32::min(available_width, Root::SIDE_PANEL_WIDTH * 2.0);
|
||||
let width = f32::min(available_width, Root::SIDE_PANEL_WIDTH * 1.3);
|
||||
rect.set_width(width);
|
||||
|
||||
// Draw wallet tabs.
|
||||
|
@ -96,7 +96,7 @@ impl WalletContent {
|
|||
return;
|
||||
}
|
||||
let mut rect = ui.available_rect_before_wrap();
|
||||
let width = f32::min(available_width, Root::SIDE_PANEL_WIDTH * 2.0);
|
||||
let width = f32::min(available_width, Root::SIDE_PANEL_WIDTH * 1.3);
|
||||
rect.set_width(width);
|
||||
|
||||
// Draw current tab content.
|
||||
|
@ -205,7 +205,7 @@ impl WalletContent {
|
|||
}
|
||||
|
||||
/// Draw wallet loading progress content.
|
||||
fn loading_progress_ui(ui: &mut egui::Ui, wallet: &Wallet) {
|
||||
pub fn loading_progress_ui(ui: &mut egui::Ui, wallet: &Wallet) {
|
||||
View::center_content(ui, 162.0, |ui| {
|
||||
View::big_loading_spinner(ui);
|
||||
ui.add_space(18.0);
|
||||
|
|
|
@ -59,8 +59,8 @@ impl WalletList {
|
|||
}
|
||||
}
|
||||
// Sort wallets by id.
|
||||
main_wallets.sort_by_key(|w| w.config.id);
|
||||
test_wallets.sort_by_key(|w| w.config.id);
|
||||
main_wallets.sort_by_key(|w| -w.config.id);
|
||||
test_wallets.sort_by_key(|w| -w.config.id);
|
||||
(main_wallets, test_wallets)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue