mirror of
https://github.com/jwinterm/grim.git
synced 2026-11-20 04:33:55 +01:00
ui + config: modals content drawing refactoring, move connections config to separate file
This commit is contained in:
@@ -20,9 +20,9 @@ use crate::AppConfig;
|
||||
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, LOCK_KEY, PLUS, SIDEBAR_SIMPLE, SUITCASE};
|
||||
use crate::gui::platform::PlatformCallbacks;
|
||||
use crate::gui::views::{Modal, ModalContainer, ModalPosition, Root, TitlePanel, TitleType, View};
|
||||
use crate::gui::views::wallets::creation::{MnemonicSetup, WalletCreation};
|
||||
use crate::gui::views::wallets::setup::ConnectionSetup;
|
||||
use crate::gui::views::{Modal, Root, TitlePanel, View};
|
||||
use crate::gui::views::types::{ModalContainer, ModalPosition, TitleType};
|
||||
use crate::gui::views::wallets::creation::WalletCreation;
|
||||
use crate::gui::views::wallets::WalletContent;
|
||||
use crate::wallet::{Wallet, Wallets};
|
||||
|
||||
@@ -48,10 +48,13 @@ pub struct WalletsContent {
|
||||
/// Flag to show [`Wallet`] list at dual panel mode.
|
||||
show_list_at_dual_panel: bool,
|
||||
|
||||
/// [`Modal`] ids allowed at this ui container.
|
||||
/// [`Modal`] identifiers allowed at this ui container.
|
||||
modal_ids: Vec<&'static str>
|
||||
}
|
||||
|
||||
/// Identifier for wallet opening [`Modal`].
|
||||
const OPEN_WALLET_MODAL: &'static str = "open_wallet_modal";
|
||||
|
||||
impl Default for WalletsContent {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
@@ -64,10 +67,8 @@ impl Default for WalletsContent {
|
||||
creation_content: WalletCreation::default(),
|
||||
show_list_at_dual_panel: true,
|
||||
modal_ids: vec![
|
||||
Self::OPEN_WALLET_MODAL,
|
||||
WalletCreation::NAME_PASS_MODAL,
|
||||
MnemonicSetup::WORD_INPUT_MODAL,
|
||||
ConnectionSetup::ADD_CONNECTION_URL_MODAL
|
||||
OPEN_WALLET_MODAL,
|
||||
WalletCreation::NAME_PASS_MODAL
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -77,38 +78,31 @@ impl ModalContainer for WalletsContent {
|
||||
fn modal_ids(&self) -> &Vec<&'static str> {
|
||||
&self.modal_ids
|
||||
}
|
||||
|
||||
fn modal_ui(&mut self,
|
||||
ui: &mut egui::Ui,
|
||||
_: &mut eframe::Frame,
|
||||
modal: &Modal,
|
||||
cb: &dyn PlatformCallbacks) {
|
||||
match modal.id {
|
||||
OPEN_WALLET_MODAL => self.open_wallet_modal_ui(ui, modal, cb),
|
||||
WalletCreation::NAME_PASS_MODAL => {
|
||||
self.creation_content.name_pass_modal_ui(ui, modal, cb)
|
||||
},
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl WalletsContent {
|
||||
/// Identifier for wallet opening [`Modal`].
|
||||
const OPEN_WALLET_MODAL: &'static str = "open_wallet_modal";
|
||||
|
||||
pub fn ui(&mut self, ui: &mut egui::Ui, frame: &mut eframe::Frame, cb: &dyn PlatformCallbacks) {
|
||||
// Show modal content for current ui container.
|
||||
if self.can_draw_modal() {
|
||||
Modal::ui(ui.ctx(), |ui, modal| {
|
||||
match modal.id {
|
||||
Self::OPEN_WALLET_MODAL => {
|
||||
self.open_wallet_modal_ui(ui, modal, cb);
|
||||
},
|
||||
WalletCreation::NAME_PASS_MODAL => {
|
||||
self.creation_content.modal_ui(ui, modal, cb);
|
||||
},
|
||||
MnemonicSetup::WORD_INPUT_MODAL => {
|
||||
self.creation_content.mnemonic_setup.modal_ui(ui, modal, cb);
|
||||
}
|
||||
ConnectionSetup::ADD_CONNECTION_URL_MODAL => {
|
||||
self.creation_content.network_setup.modal_ui(ui, modal, cb);
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
});
|
||||
}
|
||||
// Draw modal content for current ui container.
|
||||
self.current_modal_ui(ui, frame, cb);
|
||||
|
||||
// Setup list of wallets if chain type was changed.
|
||||
let chain_type = AppConfig::chain_type();
|
||||
if self.chain_type != chain_type {
|
||||
self.wallets.reinit(&chain_type);
|
||||
self.wallets.reinit(chain_type);
|
||||
self.chain_type = chain_type;
|
||||
}
|
||||
let empty_list = self.wallets.list.is_empty();
|
||||
@@ -146,7 +140,7 @@ impl WalletsContent {
|
||||
}
|
||||
if create_wallet || !show_wallet {
|
||||
// Show wallet creation content.
|
||||
self.creation_content.ui(ui, cb, |wallet| {
|
||||
self.creation_content.ui(ui, frame, cb, |wallet| {
|
||||
// Add created wallet to list.
|
||||
self.wallets.add(wallet);
|
||||
});
|
||||
@@ -207,7 +201,7 @@ impl WalletsContent {
|
||||
let mut right_margin = if dual_panel { wallet_panel_width } else { 0.0 };
|
||||
if scroll { right_margin += 6.0 }
|
||||
// Show wallet creation button.
|
||||
self.create_wallet_btn_ui(ui, right_margin);
|
||||
self.create_wallet_btn_ui(ui, right_margin, cb);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -407,7 +401,10 @@ impl WalletsContent {
|
||||
}
|
||||
|
||||
/// Draw floating button to show wallet creation [`Modal`].
|
||||
fn create_wallet_btn_ui(&mut self, ui: &mut egui::Ui, right_margin: f32) {
|
||||
fn create_wallet_btn_ui(&mut self,
|
||||
ui: &mut egui::Ui,
|
||||
right_margin: f32,
|
||||
cb: &dyn PlatformCallbacks) {
|
||||
egui::Window::new("create_wallet_button")
|
||||
.title_bar(false)
|
||||
.resizable(false)
|
||||
@@ -416,7 +413,7 @@ impl WalletsContent {
|
||||
.frame(egui::Frame::default())
|
||||
.show(ui.ctx(), |ui| {
|
||||
View::circle_button(ui, PLUS, || {
|
||||
self.creation_content.show_name_pass_modal();
|
||||
self.creation_content.show_name_pass_modal(cb);
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -428,7 +425,7 @@ impl WalletsContent {
|
||||
self.pass_edit = String::from("");
|
||||
self.wrong_pass = false;
|
||||
// Show modal.
|
||||
Modal::new(Self::OPEN_WALLET_MODAL)
|
||||
Modal::new(OPEN_WALLET_MODAL)
|
||||
.position(ModalPosition::CenterTop)
|
||||
.title(t!("wallets.open"))
|
||||
.show();
|
||||
|
||||
@@ -19,7 +19,8 @@ use crate::built_info;
|
||||
use crate::gui::Colors;
|
||||
use crate::gui::icons::{CHECK, EYE, EYE_SLASH, FOLDER_PLUS, SHARE_FAT};
|
||||
use crate::gui::platform::PlatformCallbacks;
|
||||
use crate::gui::views::{Modal, ModalPosition, View};
|
||||
use crate::gui::views::{Modal, View};
|
||||
use crate::gui::views::types::ModalPosition;
|
||||
use crate::gui::views::wallets::creation::MnemonicSetup;
|
||||
use crate::gui::views::wallets::creation::types::Step;
|
||||
use crate::gui::views::wallets::setup::ConnectionSetup;
|
||||
@@ -71,8 +72,10 @@ impl WalletCreation {
|
||||
/// Wallet name/password input modal identifier.
|
||||
pub const NAME_PASS_MODAL: &'static str = "name_pass_modal";
|
||||
|
||||
/// Draw wallet creation content.
|
||||
pub fn ui(&mut self,
|
||||
ui: &mut egui::Ui,
|
||||
frame: &mut eframe::Frame,
|
||||
cb: &dyn PlatformCallbacks,
|
||||
on_create: impl FnOnce(Wallet)) {
|
||||
// Show wallet creation step description and confirmation panel.
|
||||
@@ -109,7 +112,7 @@ impl WalletCreation {
|
||||
..Default::default()
|
||||
})
|
||||
.show_inside(ui, |ui| {
|
||||
self.step_content_ui(ui, cb);
|
||||
self.step_content_ui(ui, frame, cb);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -184,7 +187,10 @@ impl WalletCreation {
|
||||
}
|
||||
|
||||
/// Draw wallet creation [`Step`] content.
|
||||
fn step_content_ui(&mut self, ui: &mut egui::Ui, cb: &dyn PlatformCallbacks) {
|
||||
fn step_content_ui(&mut self,
|
||||
ui: &mut egui::Ui,
|
||||
frame: &mut eframe::Frame,
|
||||
cb: &dyn PlatformCallbacks) {
|
||||
match &self.step {
|
||||
None => {
|
||||
// Show wallet creation message if step is empty.
|
||||
@@ -210,15 +216,15 @@ impl WalletCreation {
|
||||
ui.add_space(8.0);
|
||||
let add_text = format!("{} {}", FOLDER_PLUS, t!("wallets.add"));
|
||||
View::button(ui, add_text, Colors::BUTTON, || {
|
||||
self.show_name_pass_modal();
|
||||
self.show_name_pass_modal(cb);
|
||||
});
|
||||
});
|
||||
}
|
||||
Some(step) => {
|
||||
match step {
|
||||
Step::EnterMnemonic => self.mnemonic_setup.ui(ui),
|
||||
Step::ConfirmMnemonic => self.mnemonic_setup.confirm_ui(ui),
|
||||
Step::SetupConnection => self.network_setup.ui(ui, cb)
|
||||
Step::EnterMnemonic => self.mnemonic_setup.ui(ui, frame, cb),
|
||||
Step::ConfirmMnemonic => self.mnemonic_setup.confirm_ui(ui, frame, cb),
|
||||
Step::SetupConnection => self.network_setup.ui(ui, frame, cb)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -271,7 +277,7 @@ impl WalletCreation {
|
||||
wallet.open(pass).unwrap();
|
||||
// Pass created wallet to callback.
|
||||
(on_create.unwrap())(wallet);
|
||||
// Reset creation data.
|
||||
// Reset input data.
|
||||
self.reset();
|
||||
None
|
||||
}
|
||||
@@ -282,7 +288,7 @@ impl WalletCreation {
|
||||
}
|
||||
|
||||
/// Start wallet creation from showing [`Modal`] to enter name and password.
|
||||
pub fn show_name_pass_modal(&mut self) {
|
||||
pub fn show_name_pass_modal(&mut self, cb: &dyn PlatformCallbacks) {
|
||||
// Reset modal values.
|
||||
self.hide_pass = true;
|
||||
self.modal_just_opened = true;
|
||||
@@ -293,10 +299,14 @@ impl WalletCreation {
|
||||
.position(ModalPosition::CenterTop)
|
||||
.title(t!("wallets.add"))
|
||||
.show();
|
||||
cb.show_keyboard();
|
||||
}
|
||||
|
||||
/// Draw wallet creation [`Modal`] content.
|
||||
pub fn modal_ui(&mut self, ui: &mut egui::Ui, modal: &Modal, cb: &dyn PlatformCallbacks) {
|
||||
/// Draw creating wallet name/password input [`Modal`] content.
|
||||
pub fn name_pass_modal_ui(&mut self,
|
||||
ui: &mut egui::Ui,
|
||||
modal: &Modal,
|
||||
cb: &dyn PlatformCallbacks) {
|
||||
ui.add_space(6.0);
|
||||
ui.vertical_centered(|ui| {
|
||||
ui.label(RichText::new(t!("wallets.name"))
|
||||
|
||||
@@ -17,7 +17,8 @@ use egui::{Id, RichText, ScrollArea, TextStyle, Widget};
|
||||
use crate::gui::Colors;
|
||||
use crate::gui::icons::PENCIL;
|
||||
use crate::gui::platform::PlatformCallbacks;
|
||||
use crate::gui::views::{Modal, ModalPosition, Root, View};
|
||||
use crate::gui::views::{Modal, Root, View};
|
||||
use crate::gui::views::types::{ModalContainer, ModalPosition};
|
||||
use crate::wallet::Mnemonic;
|
||||
use crate::wallet::types::{PhraseMode, PhraseSize};
|
||||
|
||||
@@ -34,9 +35,15 @@ pub struct MnemonicSetup {
|
||||
/// Entered word value for [`Modal`].
|
||||
word_edit: String,
|
||||
/// Flag to check if entered word is valid.
|
||||
valid_word_edit: bool
|
||||
valid_word_edit: bool,
|
||||
|
||||
/// [`Modal`] identifiers allowed at this ui container.
|
||||
modal_ids: Vec<&'static str>
|
||||
}
|
||||
|
||||
/// Identifier for word input [`Modal`].
|
||||
pub const WORD_INPUT_MODAL: &'static str = "word_input_modal";
|
||||
|
||||
impl Default for MnemonicSetup {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
@@ -44,17 +51,37 @@ impl Default for MnemonicSetup {
|
||||
valid_phrase: true,
|
||||
word_num_edit: 0,
|
||||
word_edit: String::from(""),
|
||||
valid_word_edit: true
|
||||
valid_word_edit: true,
|
||||
modal_ids: vec![
|
||||
WORD_INPUT_MODAL
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl ModalContainer for MnemonicSetup {
|
||||
fn modal_ids(&self) -> &Vec<&'static str> {
|
||||
&self.modal_ids
|
||||
}
|
||||
|
||||
fn modal_ui(&mut self,
|
||||
ui: &mut egui::Ui,
|
||||
_: &mut eframe::Frame,
|
||||
modal: &Modal,
|
||||
cb: &dyn PlatformCallbacks) {
|
||||
match modal.id {
|
||||
WORD_INPUT_MODAL => self.word_modal_ui(ui, modal, cb),
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl MnemonicSetup {
|
||||
/// Identifier for word input [`Modal`].
|
||||
pub const WORD_INPUT_MODAL: &'static str = "word_input_modal";
|
||||
/// Draw content for phrase input step.
|
||||
pub fn ui(&mut self, ui: &mut egui::Ui, frame: &mut eframe::Frame, cb: &dyn PlatformCallbacks) {
|
||||
// Draw modal content for current ui container.
|
||||
self.current_modal_ui(ui, frame, cb);
|
||||
|
||||
/// Draw content for input step.
|
||||
pub fn ui(&mut self, ui: &mut egui::Ui) {
|
||||
ScrollArea::vertical()
|
||||
.id_source("input_mnemonic_words_list")
|
||||
.auto_shrink([false; 2])
|
||||
@@ -69,12 +96,18 @@ impl MnemonicSetup {
|
||||
ui.add_space(6.0);
|
||||
|
||||
// Show words setup.
|
||||
self.word_list_ui(ui, self.mnemonic.mode == PhraseMode::Import);
|
||||
self.word_list_ui(ui, self.mnemonic.mode == PhraseMode::Import, cb);
|
||||
});
|
||||
}
|
||||
|
||||
/// Draw content for confirmation step.
|
||||
pub fn confirm_ui(&mut self, ui: &mut egui::Ui) {
|
||||
/// Draw content for phrase confirmation step.
|
||||
pub fn confirm_ui(&mut self,
|
||||
ui: &mut egui::Ui,
|
||||
frame: &mut eframe::Frame,
|
||||
cb: &dyn PlatformCallbacks) {
|
||||
// Draw modal content for current ui container.
|
||||
self.current_modal_ui(ui, frame, cb);
|
||||
|
||||
ui.add_space(4.0);
|
||||
ui.vertical_centered(|ui| {
|
||||
ui.label(RichText::new(t!("wallets.saved_phrase")).size(16.0).color(Colors::GRAY));
|
||||
@@ -85,7 +118,7 @@ impl MnemonicSetup {
|
||||
.auto_shrink([false; 2])
|
||||
.show(ui, |ui| {
|
||||
// Show words setup.
|
||||
self.word_list_ui(ui, true);
|
||||
self.word_list_ui(ui, true, cb);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -134,7 +167,7 @@ impl MnemonicSetup {
|
||||
}
|
||||
|
||||
/// Draw list of words for mnemonic phrase.
|
||||
fn word_list_ui(&mut self, ui: &mut egui::Ui, edit_words: bool) {
|
||||
fn word_list_ui(&mut self, ui: &mut egui::Ui, edit_words: bool, cb: &dyn PlatformCallbacks) {
|
||||
ui.add_space(6.0);
|
||||
ui.scope(|ui| {
|
||||
// Setup spacing between columns.
|
||||
@@ -161,25 +194,25 @@ impl MnemonicSetup {
|
||||
ui.columns(cols, |columns| {
|
||||
columns[0].horizontal(|ui| {
|
||||
let word = chunk.get(0).unwrap();
|
||||
self.word_item_ui(ui, word_number, word, edit_words);
|
||||
self.word_item_ui(ui, word_number, word, edit_words, cb);
|
||||
});
|
||||
columns[1].horizontal(|ui| {
|
||||
word_number += 1;
|
||||
let word = chunk.get(1).unwrap();
|
||||
self.word_item_ui(ui, word_number, word, edit_words);
|
||||
self.word_item_ui(ui, word_number, word, edit_words, cb);
|
||||
});
|
||||
if size > 2 {
|
||||
columns[2].horizontal(|ui| {
|
||||
word_number += 1;
|
||||
let word = chunk.get(2).unwrap();
|
||||
self.word_item_ui(ui, word_number, word, edit_words);
|
||||
self.word_item_ui(ui, word_number, word, edit_words, cb);
|
||||
});
|
||||
}
|
||||
if size > 3 {
|
||||
columns[3].horizontal(|ui| {
|
||||
word_number += 1;
|
||||
let word = chunk.get(3).unwrap();
|
||||
self.word_item_ui(ui, word_number, word, edit_words);
|
||||
self.word_item_ui(ui, word_number, word, edit_words, cb);
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -187,7 +220,7 @@ impl MnemonicSetup {
|
||||
ui.columns(cols, |columns| {
|
||||
columns[0].horizontal(|ui| {
|
||||
let word = chunk.get(0).unwrap();
|
||||
self.word_item_ui(ui, word_number, word, edit_words);
|
||||
self.word_item_ui(ui, word_number, word, edit_words, cb);
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -197,7 +230,12 @@ impl MnemonicSetup {
|
||||
}
|
||||
|
||||
/// Draw word list item for current mode.
|
||||
fn word_item_ui(&mut self, ui: &mut egui::Ui, num: usize, word: &String, edit: bool) {
|
||||
fn word_item_ui(&mut self,
|
||||
ui: &mut egui::Ui,
|
||||
num: usize,
|
||||
word: &String,
|
||||
edit: bool,
|
||||
cb: &dyn PlatformCallbacks) {
|
||||
if edit {
|
||||
ui.add_space(6.0);
|
||||
View::button(ui, PENCIL.to_string(), Colors::BUTTON, || {
|
||||
@@ -206,10 +244,11 @@ impl MnemonicSetup {
|
||||
self.word_edit = word.clone();
|
||||
self.valid_word_edit = true;
|
||||
// Show word edit modal.
|
||||
Modal::new(MnemonicSetup::WORD_INPUT_MODAL)
|
||||
Modal::new(WORD_INPUT_MODAL)
|
||||
.position(ModalPosition::CenterTop)
|
||||
.title(t!("wallets.saved_phrase"))
|
||||
.show();
|
||||
cb.show_keyboard();
|
||||
});
|
||||
ui.label(RichText::new(format!("#{} {}", num, word))
|
||||
.size(17.0)
|
||||
@@ -226,8 +265,8 @@ impl MnemonicSetup {
|
||||
self.mnemonic = Mnemonic::default();
|
||||
}
|
||||
|
||||
/// Show word input [`Modal`] content.
|
||||
pub fn modal_ui(&mut self, ui: &mut egui::Ui, modal: &Modal, cb: &dyn PlatformCallbacks) {
|
||||
/// Draw word input [`Modal`] content.
|
||||
fn word_modal_ui(&mut self, ui: &mut egui::Ui, modal: &Modal, cb: &dyn PlatformCallbacks) {
|
||||
ui.add_space(6.0);
|
||||
ui.vertical_centered(|ui| {
|
||||
ui.label(RichText::new(t!("wallets.enter_word", "number" => self.word_num_edit))
|
||||
|
||||
@@ -18,7 +18,8 @@ use url::Url;
|
||||
use crate::gui::Colors;
|
||||
use crate::gui::icons::{GLOBE, GLOBE_SIMPLE};
|
||||
use crate::gui::platform::PlatformCallbacks;
|
||||
use crate::gui::views::{Modal, ModalPosition, View};
|
||||
use crate::gui::views::{Modal, View};
|
||||
use crate::gui::views::types::{ModalContainer, ModalPosition};
|
||||
use crate::gui::views::wallets::setup::ConnectionMethod;
|
||||
use crate::wallet::{ConnectionsConfig, ExternalConnection};
|
||||
|
||||
@@ -29,14 +30,20 @@ pub struct ConnectionSetup {
|
||||
|
||||
/// Flag to check if modal was just opened.
|
||||
first_modal_launch: bool,
|
||||
/// External node connection URL value for [`Modal`].
|
||||
/// External connection URL value for [`Modal`].
|
||||
ext_node_url_edit: String,
|
||||
/// External node connection API secret value for [`Modal`].
|
||||
/// External connection API secret value for [`Modal`].
|
||||
ext_node_secret_edit: String,
|
||||
/// Flag to show URL format error.
|
||||
ext_node_url_error: bool,
|
||||
|
||||
/// [`Modal`] identifiers allowed at this ui container.
|
||||
modal_ids: Vec<&'static str>
|
||||
}
|
||||
|
||||
/// External connection [`Modal`] identifier.
|
||||
pub const EXT_CONNECTION_MODAL: &'static str = "ext_connection_modal";
|
||||
|
||||
impl Default for ConnectionSetup {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
@@ -44,21 +51,38 @@ impl Default for ConnectionSetup {
|
||||
first_modal_launch: true,
|
||||
ext_node_url_edit: "".to_string(),
|
||||
ext_node_secret_edit: "".to_string(),
|
||||
ext_node_url_error: false
|
||||
ext_node_url_error: false,
|
||||
modal_ids: vec![
|
||||
EXT_CONNECTION_MODAL
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl ModalContainer for ConnectionSetup {
|
||||
fn modal_ids(&self) -> &Vec<&'static str> {
|
||||
&self.modal_ids
|
||||
}
|
||||
|
||||
fn modal_ui(&mut self,
|
||||
ui: &mut egui::Ui,
|
||||
_: &mut eframe::Frame,
|
||||
modal: &Modal,
|
||||
cb: &dyn PlatformCallbacks) {
|
||||
match modal.id {
|
||||
EXT_CONNECTION_MODAL => self.ext_conn_modal_ui(ui, modal, cb),
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl ConnectionSetup {
|
||||
/// External node connection [`Modal`] identifier.
|
||||
pub const ADD_CONNECTION_URL_MODAL: &'static str = "add_connection_url_modal";
|
||||
|
||||
//TODO: Setup for provided wallet
|
||||
// pub fn new() -> Self {
|
||||
// Self { method: ConnectionMethod::Integrated }
|
||||
// }
|
||||
|
||||
/// Get external node connection URL.
|
||||
/// Get external connection URL.
|
||||
pub fn get_ext_conn_url(&self) -> Option<String> {
|
||||
match &self.method {
|
||||
ConnectionMethod::Integrated => None,
|
||||
@@ -66,7 +90,10 @@ impl ConnectionSetup {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn ui(&mut self, ui: &mut egui::Ui, cb: &dyn PlatformCallbacks) {
|
||||
pub fn ui(&mut self, ui: &mut egui::Ui, frame: &mut eframe::Frame, cb: &dyn PlatformCallbacks) {
|
||||
// Draw modal content for current ui container.
|
||||
self.current_modal_ui(ui, frame, cb);
|
||||
|
||||
ScrollArea::vertical()
|
||||
.id_source("wallet_connection_setup")
|
||||
.auto_shrink([false; 2])
|
||||
@@ -96,7 +123,7 @@ impl ConnectionSetup {
|
||||
self.ext_node_secret_edit = "".to_string();
|
||||
self.ext_node_url_error = false;
|
||||
// Show modal.
|
||||
Modal::new(Self::ADD_CONNECTION_URL_MODAL)
|
||||
Modal::new(EXT_CONNECTION_MODAL)
|
||||
.position(ModalPosition::CenterTop)
|
||||
.title(t!("wallets.add_node"))
|
||||
.show();
|
||||
@@ -116,8 +143,11 @@ impl ConnectionSetup {
|
||||
});
|
||||
}
|
||||
|
||||
/// Draw modal content.
|
||||
pub fn modal_ui(&mut self, ui: &mut egui::Ui, modal: &Modal, cb: &dyn PlatformCallbacks) {
|
||||
/// Draw external connection [`Modal`] content.
|
||||
pub fn ext_conn_modal_ui(&mut self,
|
||||
ui: &mut egui::Ui,
|
||||
modal: &Modal,
|
||||
cb: &dyn PlatformCallbacks) {
|
||||
ui.add_space(6.0);
|
||||
ui.vertical_centered(|ui| {
|
||||
ui.label(RichText::new(t!("wallets.node_url"))
|
||||
@@ -197,7 +227,7 @@ impl ConnectionSetup {
|
||||
let ext_conn = ExternalConnection::new(url.clone(), secret);
|
||||
ConnectionsConfig::add_external_connection(ext_conn);
|
||||
|
||||
// Set added method as current.
|
||||
// Set added connection as current.
|
||||
self.method = ConnectionMethod::External(url);
|
||||
|
||||
// Close modal.
|
||||
|
||||
@@ -19,7 +19,7 @@ use crate::gui::platform::PlatformCallbacks;
|
||||
use crate::gui::views::View;
|
||||
use crate::wallet::Wallet;
|
||||
|
||||
/// Selected wallet list item content.
|
||||
/// Selected and opened wallet content.
|
||||
pub struct WalletContent {
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user