mirror of
https://github.com/jwinterm/grim.git
synced 2026-11-24 23:03:57 +01:00
ui: input refactoring
This commit is contained in:
@@ -21,8 +21,7 @@ use grin_wallet_libwallet::Error;
|
||||
|
||||
use crate::gui::Colors;
|
||||
use crate::gui::platform::PlatformCallbacks;
|
||||
use crate::gui::views::{Modal, View};
|
||||
use crate::gui::views::types::TextEditOptions;
|
||||
use crate::gui::views::{Modal, TextEdit, View};
|
||||
use crate::gui::views::wallets::wallet::WalletTransactionModal;
|
||||
use crate::wallet::types::WalletTransaction;
|
||||
use crate::wallet::Wallet;
|
||||
@@ -163,10 +162,10 @@ impl MessageRequestModal {
|
||||
ui.add_space(8.0);
|
||||
|
||||
// Draw request amount text input.
|
||||
let amount_edit_id = Id::from(modal.id).with(wallet.get_config().id);
|
||||
let mut amount_edit_opts = TextEditOptions::new(amount_edit_id).h_center();
|
||||
let mut amount_edit = TextEdit::new(Id::from(modal.id).with(wallet.get_config().id))
|
||||
.h_center();
|
||||
let amount_edit_before = self.amount_edit.clone();
|
||||
View::text_edit(ui, cb, &mut self.amount_edit, &mut amount_edit_opts);
|
||||
amount_edit.ui(ui, &mut self.amount_edit, cb);
|
||||
|
||||
// Check value if input was changed.
|
||||
if amount_edit_before != self.amount_edit {
|
||||
|
||||
@@ -19,8 +19,7 @@ use grin_core::core::amount_to_hr_string;
|
||||
use crate::gui::Colors;
|
||||
use crate::gui::icons::{CHECK, CHECK_FAT, FOLDER_USER, PATH};
|
||||
use crate::gui::platform::PlatformCallbacks;
|
||||
use crate::gui::views::{Modal, View};
|
||||
use crate::gui::views::types::TextEditOptions;
|
||||
use crate::gui::views::{Modal, TextEdit, View};
|
||||
use crate::gui::views::wallets::wallet::types::GRIN;
|
||||
use crate::wallet::types::WalletAccount;
|
||||
use crate::wallet::{Wallet, WalletConfig};
|
||||
@@ -66,6 +65,20 @@ impl WalletAccountsModal {
|
||||
modal: &Modal,
|
||||
cb: &dyn PlatformCallbacks) {
|
||||
if self.account_creating {
|
||||
let on_create = |m: &mut WalletAccountsModal| {
|
||||
if m.account_label_edit.is_empty() {
|
||||
return;
|
||||
}
|
||||
let label = &m.account_label_edit;
|
||||
match wallet.create_account(label) {
|
||||
Ok(_) => {
|
||||
let _ = wallet.set_active_account(label);
|
||||
modal.close();
|
||||
},
|
||||
Err(_) => m.account_creation_error = true
|
||||
};
|
||||
};
|
||||
|
||||
ui.add_space(6.0);
|
||||
ui.vertical_centered(|ui| {
|
||||
ui.label(RichText::new(t!("wallets.new_account_desc"))
|
||||
@@ -74,11 +87,13 @@ impl WalletAccountsModal {
|
||||
ui.add_space(8.0);
|
||||
|
||||
// Draw account name edit.
|
||||
let text_edit_id = Id::from(modal.id).with(wallet.get_config().id);
|
||||
let mut text_edit_opts = TextEditOptions::new(text_edit_id);
|
||||
View::text_edit(ui, cb, &mut self.account_label_edit, &mut text_edit_opts);
|
||||
let mut name_edit = TextEdit::new(Id::from(modal.id).with(wallet.get_config().id));
|
||||
name_edit.ui(ui, &mut self.account_label_edit, cb);
|
||||
if name_edit.enter_pressed {
|
||||
on_create(self);
|
||||
}
|
||||
|
||||
// Show error occurred during account creation..
|
||||
// Show error occurred during account creation.
|
||||
if self.account_creation_error {
|
||||
ui.add_space(12.0);
|
||||
ui.label(RichText::new(t!("error"))
|
||||
@@ -100,25 +115,9 @@ impl WalletAccountsModal {
|
||||
});
|
||||
});
|
||||
columns[1].vertical_centered_justified(|ui| {
|
||||
// Create button callback.
|
||||
let mut on_create = || {
|
||||
if !self.account_label_edit.is_empty() {
|
||||
let label = &self.account_label_edit;
|
||||
match wallet.create_account(label) {
|
||||
Ok(_) => {
|
||||
let _ = wallet.set_active_account(label);
|
||||
modal.close();
|
||||
},
|
||||
Err(_) => self.account_creation_error = true
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
View::on_enter_key(ui, || {
|
||||
(on_create)();
|
||||
View::button(ui, t!("create"), Colors::white_or_black(false), || {
|
||||
on_create(self);
|
||||
});
|
||||
|
||||
View::button(ui, t!("create"), Colors::white_or_black(false), on_create);
|
||||
});
|
||||
});
|
||||
ui.add_space(6.0);
|
||||
|
||||
@@ -17,8 +17,8 @@ use egui::{Id, RichText};
|
||||
use crate::gui::Colors;
|
||||
use crate::gui::icons::{CLOCK_COUNTDOWN, PASSWORD, PENCIL};
|
||||
use crate::gui::platform::PlatformCallbacks;
|
||||
use crate::gui::views::{Modal, View};
|
||||
use crate::gui::views::types::{ModalPosition, TextEditOptions};
|
||||
use crate::gui::views::{Modal, TextEdit, View};
|
||||
use crate::gui::views::types::ModalPosition;
|
||||
use crate::wallet::Wallet;
|
||||
|
||||
/// Common wallet settings content.
|
||||
@@ -26,8 +26,6 @@ pub struct CommonSettings {
|
||||
/// Wallet name [`Modal`] value.
|
||||
name_edit: String,
|
||||
|
||||
/// Flag to check if password change [`Modal`] was opened at first time to focus input field.
|
||||
first_edit_pass_opening: bool,
|
||||
/// Flag to check if wrong password was entered.
|
||||
wrong_pass: bool,
|
||||
/// Current wallet password [`Modal`] value.
|
||||
@@ -50,7 +48,6 @@ impl Default for CommonSettings {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
name_edit: "".to_string(),
|
||||
first_edit_pass_opening: true,
|
||||
wrong_pass: false,
|
||||
old_pass_edit: "".to_string(),
|
||||
new_pass_edit: "".to_string(),
|
||||
@@ -99,7 +96,6 @@ impl CommonSettings {
|
||||
let pass_text = format!("{} {}", PASSWORD, t!("change"));
|
||||
View::button(ui, pass_text, Colors::white_or_black(false), || {
|
||||
// Setup modal values.
|
||||
self.first_edit_pass_opening = true;
|
||||
self.old_pass_edit = "".to_string();
|
||||
self.new_pass_edit = "".to_string();
|
||||
self.wrong_pass = false;
|
||||
@@ -176,17 +172,25 @@ impl CommonSettings {
|
||||
wallet: &Wallet,
|
||||
modal: &Modal,
|
||||
cb: &dyn PlatformCallbacks) {
|
||||
let on_save = |c: &mut CommonSettings| {
|
||||
if !c.name_edit.is_empty() {
|
||||
wallet.change_name(c.name_edit.clone());
|
||||
modal.close();
|
||||
}
|
||||
};
|
||||
|
||||
ui.add_space(6.0);
|
||||
ui.vertical_centered(|ui| {
|
||||
ui.label(RichText::new(t!("wallets.name"))
|
||||
.size(17.0)
|
||||
.color(Colors::gray()));
|
||||
ui.add_space(8.0);
|
||||
|
||||
// Show wallet name text edit.
|
||||
let name_edit_id = Id::from(modal.id).with(wallet.get_config().id);
|
||||
let mut name_edit_opts = TextEditOptions::new(name_edit_id);
|
||||
View::text_edit(ui, cb, &mut self.name_edit, &mut name_edit_opts);
|
||||
let mut name_edit = TextEdit::new(Id::from(modal.id).with(wallet.get_config().id));
|
||||
name_edit.ui(ui, &mut self.name_edit, cb);
|
||||
if name_edit.enter_pressed {
|
||||
on_save(self);
|
||||
}
|
||||
ui.add_space(12.0);
|
||||
});
|
||||
|
||||
@@ -203,19 +207,9 @@ impl CommonSettings {
|
||||
});
|
||||
});
|
||||
columns[1].vertical_centered_justified(|ui| {
|
||||
// Save button callback.
|
||||
let on_save = || {
|
||||
if !self.name_edit.is_empty() {
|
||||
wallet.change_name(self.name_edit.clone());
|
||||
modal.close();
|
||||
}
|
||||
};
|
||||
|
||||
View::on_enter_key(ui, || {
|
||||
(on_save)();
|
||||
View::button(ui, t!("modal.save"), Colors::white_or_black(false), || {
|
||||
on_save(self);
|
||||
});
|
||||
|
||||
View::button(ui, t!("modal.save"), Colors::white_or_black(false), on_save);
|
||||
});
|
||||
});
|
||||
ui.add_space(6.0);
|
||||
@@ -229,6 +223,23 @@ impl CommonSettings {
|
||||
modal: &Modal,
|
||||
cb: &dyn PlatformCallbacks) {
|
||||
let wallet_id = wallet.get_config().id;
|
||||
let on_continue = |c: &mut CommonSettings| {
|
||||
if c.new_pass_edit.is_empty() {
|
||||
return;
|
||||
}
|
||||
let old_pass = c.old_pass_edit.clone();
|
||||
let new_pass = c.new_pass_edit.clone();
|
||||
match wallet.change_password(old_pass, new_pass) {
|
||||
Ok(_) => {
|
||||
// Clear password values.
|
||||
c.old_pass_edit = "".to_string();
|
||||
c.new_pass_edit = "".to_string();
|
||||
// Close modal.
|
||||
modal.close();
|
||||
}
|
||||
Err(_) => c.wrong_pass = true
|
||||
}
|
||||
};
|
||||
|
||||
ui.add_space(6.0);
|
||||
ui.vertical_centered(|ui| {
|
||||
@@ -239,12 +250,10 @@ impl CommonSettings {
|
||||
|
||||
// Draw old password text edit.
|
||||
let pass_edit_id = Id::from(modal.id).with(wallet_id).with("old_pass");
|
||||
let mut pass_edit_opts = TextEditOptions::new(pass_edit_id).password().no_focus();
|
||||
if self.first_edit_pass_opening {
|
||||
self.first_edit_pass_opening = false;
|
||||
pass_edit_opts.focus = true;
|
||||
}
|
||||
View::text_edit(ui, cb, &mut self.old_pass_edit, &mut pass_edit_opts);
|
||||
let mut pass_edit = TextEdit::new(pass_edit_id)
|
||||
.password()
|
||||
.focus(Modal::first_draw());
|
||||
pass_edit.ui(ui, &mut self.old_pass_edit, cb);
|
||||
ui.add_space(8.0);
|
||||
|
||||
ui.label(RichText::new(t!("wallets.new_pass"))
|
||||
@@ -254,10 +263,16 @@ impl CommonSettings {
|
||||
|
||||
// Draw new password text edit.
|
||||
let new_pass_edit_id = Id::from(modal.id).with(wallet_id).with("new_pass");
|
||||
let mut new_pass_edit_opts = TextEditOptions::new(new_pass_edit_id)
|
||||
let mut new_pass_edit = TextEdit::new(new_pass_edit_id)
|
||||
.password()
|
||||
.no_focus();
|
||||
View::text_edit(ui, cb, &mut self.new_pass_edit, &mut new_pass_edit_opts);
|
||||
.focus(false);
|
||||
if pass_edit.enter_pressed {
|
||||
new_pass_edit.focus_request();
|
||||
}
|
||||
new_pass_edit.ui(ui, &mut self.new_pass_edit, cb);
|
||||
if new_pass_edit.enter_pressed {
|
||||
on_continue(self);
|
||||
}
|
||||
|
||||
// Show information when password is empty.
|
||||
if self.old_pass_edit.is_empty() || self.new_pass_edit.is_empty() {
|
||||
@@ -287,31 +302,9 @@ impl CommonSettings {
|
||||
});
|
||||
});
|
||||
columns[1].vertical_centered_justified(|ui| {
|
||||
// Callback for button to continue.
|
||||
let mut on_continue = || {
|
||||
if self.new_pass_edit.is_empty() {
|
||||
return;
|
||||
}
|
||||
let old_pass = self.old_pass_edit.clone();
|
||||
let new_pass = self.new_pass_edit.clone();
|
||||
match wallet.change_password(old_pass, new_pass) {
|
||||
Ok(_) => {
|
||||
// Clear password values.
|
||||
self.old_pass_edit = "".to_string();
|
||||
self.new_pass_edit = "".to_string();
|
||||
// Close modal.
|
||||
modal.close();
|
||||
}
|
||||
Err(_) => self.wrong_pass = true
|
||||
}
|
||||
};
|
||||
|
||||
// Continue on Enter key press.
|
||||
View::on_enter_key(ui, || {
|
||||
(on_continue)();
|
||||
View::button(ui, t!("change"), Colors::white_or_black(false), || {
|
||||
on_continue(self);
|
||||
});
|
||||
|
||||
View::button(ui, t!("change"), Colors::white_or_black(false), on_continue);
|
||||
});
|
||||
});
|
||||
ui.add_space(6.0);
|
||||
@@ -324,6 +317,13 @@ impl CommonSettings {
|
||||
wallet: &Wallet,
|
||||
modal: &Modal,
|
||||
cb: &dyn PlatformCallbacks) {
|
||||
let on_save = |c: &mut CommonSettings| {
|
||||
if let Ok(min_conf) = c.min_confirmations_edit.parse::<u64>() {
|
||||
wallet.update_min_confirmations(min_conf);
|
||||
modal.close();
|
||||
}
|
||||
};
|
||||
|
||||
ui.add_space(6.0);
|
||||
ui.vertical_centered(|ui| {
|
||||
ui.label(RichText::new(t!("wallets.min_tx_conf_count"))
|
||||
@@ -332,8 +332,11 @@ impl CommonSettings {
|
||||
ui.add_space(8.0);
|
||||
|
||||
// Minimum amount of confirmations text edit.
|
||||
let mut text_edit_opts = TextEditOptions::new(Id::from(modal.id)).h_center();
|
||||
View::text_edit(ui, cb, &mut self.min_confirmations_edit, &mut text_edit_opts);
|
||||
let mut min_confirmations_edit = TextEdit::new(Id::from(modal.id)).h_center();
|
||||
min_confirmations_edit.ui(ui, &mut self.min_confirmations_edit, cb);
|
||||
if min_confirmations_edit.enter_pressed {
|
||||
on_save(self);
|
||||
}
|
||||
|
||||
// Show error when specified value is not valid or reminder to restart enabled node.
|
||||
if self.min_confirmations_edit.parse::<u64>().is_err() {
|
||||
@@ -358,19 +361,9 @@ impl CommonSettings {
|
||||
});
|
||||
});
|
||||
columns[1].vertical_centered_justified(|ui| {
|
||||
// Save button callback.
|
||||
let on_save = || {
|
||||
if let Ok(min_conf) = self.min_confirmations_edit.parse::<u64>() {
|
||||
wallet.update_min_confirmations(min_conf);
|
||||
modal.close();
|
||||
}
|
||||
};
|
||||
|
||||
View::on_enter_key(ui, || {
|
||||
(on_save)();
|
||||
View::button(ui, t!("modal.save"), Colors::white_or_black(false), || {
|
||||
on_save(self);
|
||||
});
|
||||
|
||||
View::button(ui, t!("modal.save"), Colors::white_or_black(false), on_save);
|
||||
});
|
||||
});
|
||||
ui.add_space(6.0);
|
||||
|
||||
@@ -19,8 +19,8 @@ use grin_util::ZeroingString;
|
||||
use crate::gui::Colors;
|
||||
use crate::gui::icons::{EYE, LIFEBUOY, STETHOSCOPE, TRASH, WRENCH};
|
||||
use crate::gui::platform::PlatformCallbacks;
|
||||
use crate::gui::views::{Modal, View};
|
||||
use crate::gui::views::types::{ModalPosition, TextEditOptions};
|
||||
use crate::gui::views::{Modal, TextEdit, View};
|
||||
use crate::gui::views::types::ModalPosition;
|
||||
use crate::node::Node;
|
||||
use crate::wallet::types::ConnectionMethod;
|
||||
use crate::wallet::Wallet;
|
||||
@@ -182,6 +182,18 @@ impl RecoverySettings {
|
||||
wallet: &Wallet,
|
||||
modal: &Modal,
|
||||
cb: &dyn PlatformCallbacks) {
|
||||
let on_next = |c: &mut RecoverySettings| {
|
||||
match wallet.get_recovery(c.pass_edit.clone()) {
|
||||
Ok(phrase) => {
|
||||
c.wrong_pass = false;
|
||||
c.recovery_phrase = Some(phrase);
|
||||
}
|
||||
Err(_) => {
|
||||
c.wrong_pass = true;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
ui.add_space(6.0);
|
||||
if self.recovery_phrase.is_some() {
|
||||
ui.vertical_centered(|ui| {
|
||||
@@ -205,8 +217,12 @@ impl RecoverySettings {
|
||||
|
||||
// Draw current wallet password text edit.
|
||||
let pass_edit_id = Id::from(modal.id).with(wallet.get_config().id);
|
||||
let mut pass_edit_opts = TextEditOptions::new(pass_edit_id).password();
|
||||
View::text_edit(ui, cb, &mut self.pass_edit, &mut pass_edit_opts);
|
||||
let mut pass_edit = TextEdit::new(pass_edit_id)
|
||||
.password();
|
||||
pass_edit.ui(ui, &mut self.pass_edit, cb);
|
||||
if pass_edit.enter_pressed {
|
||||
on_next(self);
|
||||
}
|
||||
|
||||
// Show information when password is empty or wrong.
|
||||
if self.pass_edit.is_empty() {
|
||||
@@ -236,22 +252,8 @@ impl RecoverySettings {
|
||||
});
|
||||
});
|
||||
columns[1].vertical_centered_justified(|ui| {
|
||||
let mut on_next = || {
|
||||
match wallet.get_recovery(self.pass_edit.clone()) {
|
||||
Ok(phrase) => {
|
||||
self.wrong_pass = false;
|
||||
self.recovery_phrase = Some(phrase);
|
||||
}
|
||||
Err(_) => {
|
||||
self.wrong_pass = true;
|
||||
}
|
||||
}
|
||||
};
|
||||
View::on_enter_key(ui, || {
|
||||
(on_next)();
|
||||
});
|
||||
View::button(ui, "OK".to_owned(), Colors::white_or_black(false), || {
|
||||
on_next();
|
||||
on_next(self);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -21,17 +21,13 @@ use parking_lot::RwLock;
|
||||
|
||||
use crate::gui::Colors;
|
||||
use crate::gui::platform::PlatformCallbacks;
|
||||
use crate::gui::views::{CameraContent, Modal, View};
|
||||
use crate::gui::views::types::TextEditOptions;
|
||||
use crate::gui::views::{CameraContent, Modal, TextEdit, View};
|
||||
use crate::gui::views::wallets::wallet::WalletTransactionModal;
|
||||
use crate::wallet::types::WalletTransaction;
|
||||
use crate::wallet::Wallet;
|
||||
|
||||
/// Transport sending [`Modal`] content.
|
||||
pub struct TransportSendModal {
|
||||
/// Flag to focus on first input field after opening.
|
||||
first_draw: bool,
|
||||
|
||||
/// Flag to check if transaction is sending to show progress.
|
||||
sending: bool,
|
||||
/// Flag to check if there is an error to repeat.
|
||||
@@ -57,7 +53,6 @@ impl TransportSendModal {
|
||||
/// Create new instance from provided address.
|
||||
pub fn new(addr: Option<String>) -> Self {
|
||||
Self {
|
||||
first_draw: true,
|
||||
sending: false,
|
||||
error: false,
|
||||
send_result: Arc::new(RwLock::new(None)),
|
||||
@@ -100,8 +95,7 @@ impl TransportSendModal {
|
||||
ui.add_space(6.0);
|
||||
// Draw QR code scanner content if requested.
|
||||
if let Some(scanner) = self.address_scan_content.as_mut() {
|
||||
let mut on_stop = || {
|
||||
self.first_draw = true;
|
||||
let on_stop = || {
|
||||
cb.stop_camera();
|
||||
modal.enable_closing();
|
||||
};
|
||||
@@ -150,13 +144,11 @@ impl TransportSendModal {
|
||||
|
||||
// Draw amount text edit.
|
||||
let amount_edit_id = Id::from(modal.id).with("amount").with(wallet.get_config().id);
|
||||
let mut amount_edit_opts = TextEditOptions::new(amount_edit_id).h_center().no_focus();
|
||||
let mut amount_edit = TextEdit::new(amount_edit_id)
|
||||
.h_center()
|
||||
.focus(Modal::first_draw());
|
||||
let amount_edit_before = self.amount_edit.clone();
|
||||
if self.first_draw {
|
||||
self.first_draw = false;
|
||||
amount_edit_opts.focus = true;
|
||||
}
|
||||
View::text_edit(ui, cb, &mut self.amount_edit, &mut amount_edit_opts);
|
||||
amount_edit.ui(ui, &mut self.amount_edit, cb);
|
||||
ui.add_space(8.0);
|
||||
|
||||
// Check value if input was changed.
|
||||
@@ -173,7 +165,7 @@ impl TransportSendModal {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
// Check input after ".".
|
||||
// Check input after `.`.
|
||||
let parts = self.amount_edit.split(".").collect::<Vec<&str>>();
|
||||
if parts.len() == 2 && parts[1].len() > 9 {
|
||||
self.amount_edit = amount_edit_before;
|
||||
@@ -211,15 +203,17 @@ impl TransportSendModal {
|
||||
// Draw address text edit.
|
||||
let addr_edit_before = self.address_edit.clone();
|
||||
let address_edit_id = Id::from(modal.id).with("_address").with(wallet.get_config().id);
|
||||
let mut address_edit_opts = TextEditOptions::new(address_edit_id)
|
||||
let mut address_edit = TextEdit::new(address_edit_id)
|
||||
.paste()
|
||||
.no_focus()
|
||||
.focus(false)
|
||||
.scan_qr();
|
||||
View::text_edit(ui, cb, &mut self.address_edit, &mut address_edit_opts);
|
||||
if amount_edit.enter_pressed {
|
||||
address_edit.focus_request();
|
||||
}
|
||||
address_edit.ui(ui, &mut self.address_edit, cb);
|
||||
// Check if scan button was pressed.
|
||||
if address_edit_opts.scan_pressed {
|
||||
if address_edit.scan_pressed {
|
||||
modal.disable_closing();
|
||||
address_edit_opts.scan_pressed = false;
|
||||
self.address_scan_content = Some(CameraContent::default());
|
||||
}
|
||||
ui.add_space(12.0);
|
||||
@@ -229,6 +223,11 @@ impl TransportSendModal {
|
||||
self.address_error = false;
|
||||
}
|
||||
|
||||
// Send on Enter press.
|
||||
if address_edit.enter_pressed {
|
||||
self.send(wallet, modal);
|
||||
}
|
||||
|
||||
// Setup spacing between buttons.
|
||||
ui.spacing_mut().item_spacing = egui::Vec2::new(8.0, 0.0);
|
||||
|
||||
|
||||
@@ -17,8 +17,7 @@ use egui::{Id, RichText};
|
||||
|
||||
use crate::gui::Colors;
|
||||
use crate::gui::platform::PlatformCallbacks;
|
||||
use crate::gui::views::{CameraContent, Modal, View};
|
||||
use crate::gui::views::types::TextEditOptions;
|
||||
use crate::gui::views::{CameraContent, Modal, TextEdit, View};
|
||||
use crate::tor::{Tor, TorBridge, TorConfig};
|
||||
use crate::wallet::Wallet;
|
||||
|
||||
@@ -160,16 +159,16 @@ impl TransportSettingsModal {
|
||||
let bin_edit_id = Id::from(modal.id)
|
||||
.with(wallet.get_config().id)
|
||||
.with("_bin_edit");
|
||||
let mut bin_edit_opts = TextEditOptions::new(bin_edit_id)
|
||||
let mut bin_edit = TextEdit::new(bin_edit_id)
|
||||
.paste()
|
||||
.no_focus();
|
||||
.focus(false);
|
||||
let bin_edit_before = self.bridge_bin_path_edit.clone();
|
||||
ui.vertical_centered(|ui| {
|
||||
ui.label(RichText::new(t!("transport.bin_file"))
|
||||
.size(17.0)
|
||||
.color(Colors::inactive_text()));
|
||||
ui.add_space(6.0);
|
||||
View::text_edit(ui, cb, &mut self.bridge_bin_path_edit, &mut bin_edit_opts);
|
||||
bin_edit.ui(ui, &mut self.bridge_bin_path_edit, cb);
|
||||
ui.add_space(6.0);
|
||||
});
|
||||
|
||||
@@ -178,20 +177,19 @@ impl TransportSettingsModal {
|
||||
let conn_edit_id = Id::from(modal.id)
|
||||
.with(wallet.get_config().id)
|
||||
.with("_conn_edit");
|
||||
let mut conn_edit_opts = TextEditOptions::new(conn_edit_id)
|
||||
let mut conn_edit = TextEdit::new(conn_edit_id)
|
||||
.paste()
|
||||
.no_focus()
|
||||
.focus(false)
|
||||
.scan_qr();
|
||||
ui.vertical_centered(|ui| {
|
||||
ui.label(RichText::new(t!("transport.conn_line"))
|
||||
.size(17.0)
|
||||
.color(Colors::inactive_text()));
|
||||
ui.add_space(6.0);
|
||||
View::text_edit(ui, cb, &mut self.bridge_conn_line_edit, &mut conn_edit_opts);
|
||||
conn_edit.ui(ui, &mut self.bridge_conn_line_edit, cb);
|
||||
// Check if scan button was pressed.
|
||||
if conn_edit_opts.scan_pressed {
|
||||
if conn_edit.scan_pressed {
|
||||
modal.disable_closing();
|
||||
conn_edit_opts.scan_pressed = false;
|
||||
self.bridge_qr_scan_content = Some(CameraContent::default());
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user