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