mirror of
https://github.com/jwinterm/grim.git
synced 2026-11-24 23:03:57 +01:00
modal: close refactoring
This commit is contained in:
@@ -145,10 +145,10 @@ impl WalletMessages {
|
||||
SCAN_QR_MODAL => {
|
||||
let mut result = None;
|
||||
if let Some(content) = self.scan_modal_content.as_mut() {
|
||||
Modal::ui(ui.ctx(), |ui, modal| {
|
||||
content.ui(ui, modal, cb, |res| {
|
||||
Modal::ui(ui.ctx(), |ui, _| {
|
||||
content.ui(ui, cb, |res| {
|
||||
result = Some(res.clone());
|
||||
modal.close();
|
||||
Modal::close();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -194,7 +194,7 @@ impl MessageRequestModal {
|
||||
View::button(ui, t!("modal.cancel"), Colors::white_or_black(false), || {
|
||||
self.amount_edit = "".to_string();
|
||||
self.request_error = None;
|
||||
modal.close();
|
||||
Modal::close();
|
||||
});
|
||||
});
|
||||
columns[1].vertical_centered_justified(|ui| {
|
||||
|
||||
@@ -73,7 +73,7 @@ impl WalletAccountsModal {
|
||||
match wallet.create_account(label) {
|
||||
Ok(_) => {
|
||||
let _ = wallet.set_active_account(label);
|
||||
modal.close();
|
||||
Modal::close();
|
||||
},
|
||||
Err(_) => m.account_creation_error = true
|
||||
};
|
||||
@@ -111,7 +111,7 @@ impl WalletAccountsModal {
|
||||
columns[0].vertical_centered_justified(|ui| {
|
||||
View::button(ui, t!("modal.cancel"), Colors::white_or_black(false), || {
|
||||
// Close modal.
|
||||
modal.close();
|
||||
Modal::close();
|
||||
});
|
||||
});
|
||||
columns[1].vertical_centered_justified(|ui| {
|
||||
@@ -138,7 +138,7 @@ impl WalletAccountsModal {
|
||||
ui.add_space(4.0);
|
||||
}
|
||||
let acc = self.accounts.get(index).unwrap();
|
||||
account_item_ui(ui, modal, wallet, acc, index, size);
|
||||
account_item_ui(ui, wallet, acc, index, size);
|
||||
if index == size - 1 {
|
||||
ui.add_space(4.0);
|
||||
}
|
||||
@@ -156,7 +156,7 @@ impl WalletAccountsModal {
|
||||
ui.columns(2, |columns| {
|
||||
columns[0].vertical_centered_justified(|ui| {
|
||||
View::button(ui, t!("modal.cancel"), Colors::white_or_black(false), || {
|
||||
modal.close();
|
||||
Modal::close();
|
||||
});
|
||||
});
|
||||
columns[1].vertical_centered_justified(|ui| {
|
||||
@@ -175,7 +175,6 @@ const ACCOUNT_ITEM_HEIGHT: f32 = 75.0;
|
||||
|
||||
/// Draw account item.
|
||||
fn account_item_ui(ui: &mut egui::Ui,
|
||||
modal: &Modal,
|
||||
wallet: &Wallet,
|
||||
acc: &WalletAccount,
|
||||
index: usize,
|
||||
@@ -201,7 +200,7 @@ fn account_item_ui(ui: &mut egui::Ui,
|
||||
let button_rounding = View::item_rounding(index, size, true);
|
||||
View::item_button(ui, button_rounding, CHECK, None, || {
|
||||
let _ = wallet.set_active_account(&acc.label);
|
||||
modal.close();
|
||||
Modal::close();
|
||||
});
|
||||
} else {
|
||||
ui.add_space(12.0);
|
||||
|
||||
@@ -175,7 +175,7 @@ impl CommonSettings {
|
||||
let on_save = |c: &mut CommonSettings| {
|
||||
if !c.name_edit.is_empty() {
|
||||
wallet.change_name(c.name_edit.clone());
|
||||
modal.close();
|
||||
Modal::close();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -203,7 +203,7 @@ impl CommonSettings {
|
||||
columns[0].vertical_centered_justified(|ui| {
|
||||
View::button(ui, t!("modal.cancel"), Colors::white_or_black(false), || {
|
||||
// Close modal.
|
||||
modal.close();
|
||||
Modal::close();
|
||||
});
|
||||
});
|
||||
columns[1].vertical_centered_justified(|ui| {
|
||||
@@ -235,7 +235,7 @@ impl CommonSettings {
|
||||
c.old_pass_edit = "".to_string();
|
||||
c.new_pass_edit = "".to_string();
|
||||
// Close modal.
|
||||
modal.close();
|
||||
Modal::close();
|
||||
}
|
||||
Err(_) => c.wrong_pass = true
|
||||
}
|
||||
@@ -298,7 +298,7 @@ impl CommonSettings {
|
||||
columns[0].vertical_centered_justified(|ui| {
|
||||
View::button(ui, t!("modal.cancel"), Colors::white_or_black(false), || {
|
||||
// Close modal.
|
||||
modal.close();
|
||||
Modal::close();
|
||||
});
|
||||
});
|
||||
columns[1].vertical_centered_justified(|ui| {
|
||||
@@ -320,7 +320,7 @@ impl CommonSettings {
|
||||
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();
|
||||
Modal::close();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -357,7 +357,7 @@ impl CommonSettings {
|
||||
columns[0].vertical_centered_justified(|ui| {
|
||||
View::button(ui, t!("modal.cancel"), Colors::white_or_black(false), || {
|
||||
// Close modal.
|
||||
modal.close();
|
||||
Modal::close();
|
||||
});
|
||||
});
|
||||
columns[1].vertical_centered_justified(|ui| {
|
||||
|
||||
@@ -153,8 +153,8 @@ impl RecoverySettings {
|
||||
});
|
||||
}
|
||||
DELETE_CONFIRMATION_MODAL => {
|
||||
Modal::ui(ui.ctx(), |ui, modal| {
|
||||
self.deletion_modal_ui(ui, wallet, modal);
|
||||
Modal::ui(ui.ctx(), |ui, _| {
|
||||
self.deletion_modal_ui(ui, wallet);
|
||||
});
|
||||
}
|
||||
_ => {}
|
||||
@@ -205,7 +205,7 @@ impl RecoverySettings {
|
||||
ui.vertical_centered_justified(|ui| {
|
||||
View::button(ui, t!("close"), Colors::white_or_black(false), || {
|
||||
self.recovery_phrase = None;
|
||||
modal.close();
|
||||
Modal::close();
|
||||
});
|
||||
});
|
||||
} else {
|
||||
@@ -248,7 +248,7 @@ impl RecoverySettings {
|
||||
columns[0].vertical_centered_justified(|ui| {
|
||||
View::button(ui, t!("modal.cancel"), Colors::white_or_black(false), || {
|
||||
self.recovery_phrase = None;
|
||||
modal.close();
|
||||
Modal::close();
|
||||
});
|
||||
});
|
||||
columns[1].vertical_centered_justified(|ui| {
|
||||
@@ -265,8 +265,7 @@ impl RecoverySettings {
|
||||
/// Draw wallet deletion [`Modal`] content.
|
||||
fn deletion_modal_ui(&mut self,
|
||||
ui: &mut egui::Ui,
|
||||
wallet: &Wallet,
|
||||
modal: &Modal) {
|
||||
wallet: &Wallet) {
|
||||
ui.add_space(8.0);
|
||||
ui.vertical_centered(|ui| {
|
||||
ui.label(RichText::new(t!("wallets.delete_conf"))
|
||||
@@ -283,13 +282,13 @@ impl RecoverySettings {
|
||||
ui.columns(2, |columns| {
|
||||
columns[0].vertical_centered_justified(|ui| {
|
||||
View::button(ui, t!("modal.cancel"), Colors::white_or_black(false), || {
|
||||
modal.close();
|
||||
Modal::close();
|
||||
});
|
||||
});
|
||||
columns[1].vertical_centered_justified(|ui| {
|
||||
View::button(ui, t!("delete"), Colors::white_or_black(false), || {
|
||||
wallet.delete_wallet();
|
||||
modal.close();
|
||||
Modal::close();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -109,8 +109,8 @@ impl WalletTransport {
|
||||
}
|
||||
}
|
||||
QR_ADDRESS_MODAL => {
|
||||
Modal::ui(ui.ctx(), |ui, modal| {
|
||||
self.qr_address_modal_ui(ui, modal, cb);
|
||||
Modal::ui(ui.ctx(), |ui, _| {
|
||||
self.qr_address_modal_ui(ui, cb);
|
||||
});
|
||||
}
|
||||
_ => {}
|
||||
@@ -316,7 +316,6 @@ impl WalletTransport {
|
||||
/// Draw QR code image address [`Modal`] content.
|
||||
fn qr_address_modal_ui(&mut self,
|
||||
ui: &mut egui::Ui,
|
||||
modal: &Modal,
|
||||
cb: &dyn PlatformCallbacks) {
|
||||
ui.add_space(6.0);
|
||||
|
||||
@@ -324,14 +323,14 @@ impl WalletTransport {
|
||||
if let Some(content) = self.qr_address_content.as_mut() {
|
||||
content.ui(ui, cb);
|
||||
} else {
|
||||
modal.close();
|
||||
Modal::close();
|
||||
return;
|
||||
}
|
||||
|
||||
ui.vertical_centered_justified(|ui| {
|
||||
View::button(ui, t!("close"), Colors::white_or_black(false), || {
|
||||
self.qr_address_content = None;
|
||||
modal.close();
|
||||
Modal::close();
|
||||
});
|
||||
});
|
||||
ui.add_space(6.0);
|
||||
|
||||
@@ -117,7 +117,7 @@ impl TransportSendModal {
|
||||
View::button(ui, t!("close"), Colors::white_or_black(false), || {
|
||||
on_stop();
|
||||
self.address_scan_content = None;
|
||||
modal.close();
|
||||
Modal::close();
|
||||
});
|
||||
});
|
||||
cols[1].vertical_centered_justified(|ui| {
|
||||
@@ -235,7 +235,7 @@ impl TransportSendModal {
|
||||
ui.columns(2, |columns| {
|
||||
columns[0].vertical_centered_justified(|ui| {
|
||||
View::button(ui, t!("modal.cancel"), Colors::white_or_black(false), || {
|
||||
self.close(modal);
|
||||
self.close();
|
||||
});
|
||||
});
|
||||
columns[1].vertical_centered_justified(|ui| {
|
||||
@@ -263,7 +263,7 @@ impl TransportSendModal {
|
||||
ui.columns(2, |columns| {
|
||||
columns[0].vertical_centered_justified(|ui| {
|
||||
View::button(ui, t!("modal.cancel"), Colors::white_or_black(false), || {
|
||||
self.close(modal);
|
||||
self.close();
|
||||
});
|
||||
});
|
||||
columns[1].vertical_centered_justified(|ui| {
|
||||
@@ -276,7 +276,7 @@ impl TransportSendModal {
|
||||
}
|
||||
|
||||
/// Close modal and clear data.
|
||||
fn close(&mut self, modal: &Modal) {
|
||||
fn close(&mut self) {
|
||||
self.amount_edit = "".to_string();
|
||||
self.address_edit = "".to_string();
|
||||
|
||||
@@ -286,7 +286,7 @@ impl TransportSendModal {
|
||||
self.tx_info_content = None;
|
||||
self.address_scan_content = None;
|
||||
|
||||
modal.close();
|
||||
Modal::close();
|
||||
}
|
||||
|
||||
/// Send entered amount to address.
|
||||
|
||||
@@ -84,7 +84,7 @@ impl TransportSettingsModal {
|
||||
View::button(ui, t!("close"), Colors::white_or_black(false), || {
|
||||
on_stop();
|
||||
self.bridge_qr_scan_content = None;
|
||||
modal.close();
|
||||
Modal::close();
|
||||
});
|
||||
});
|
||||
cols[1].vertical_centered_justified(|ui| {
|
||||
@@ -246,7 +246,7 @@ impl TransportSettingsModal {
|
||||
Tor::rebuild_client();
|
||||
}
|
||||
}
|
||||
modal.close();
|
||||
Modal::close();
|
||||
});
|
||||
});
|
||||
ui.add_space(6.0);
|
||||
|
||||
@@ -253,8 +253,8 @@ impl WalletTransactions {
|
||||
});
|
||||
}
|
||||
CANCEL_TX_CONFIRMATION_MODAL => {
|
||||
Modal::ui(ui.ctx(), |ui, modal| {
|
||||
self.cancel_confirmation_modal(ui, wallet, modal);
|
||||
Modal::ui(ui.ctx(), |ui, _| {
|
||||
self.cancel_confirmation_modal(ui, wallet);
|
||||
});
|
||||
}
|
||||
_ => {}
|
||||
@@ -463,7 +463,7 @@ impl WalletTransactions {
|
||||
}
|
||||
|
||||
/// Confirmation [`Modal`] to cancel transaction.
|
||||
fn cancel_confirmation_modal(&mut self, ui: &mut egui::Ui, wallet: &Wallet, modal: &Modal) {
|
||||
fn cancel_confirmation_modal(&mut self, ui: &mut egui::Ui, wallet: &Wallet) {
|
||||
ui.add_space(6.0);
|
||||
ui.vertical_centered(|ui| {
|
||||
// Setup confirmation text.
|
||||
@@ -473,7 +473,7 @@ impl WalletTransactions {
|
||||
.filter(|tx| tx.data.id == self.confirm_cancel_tx_id.unwrap())
|
||||
.collect::<Vec<WalletTransaction>>();
|
||||
if txs.is_empty() {
|
||||
modal.close();
|
||||
Modal::close();
|
||||
return;
|
||||
}
|
||||
let tx = txs.get(0).unwrap();
|
||||
@@ -501,14 +501,14 @@ impl WalletTransactions {
|
||||
columns[0].vertical_centered_justified(|ui| {
|
||||
View::button(ui, t!("modal.cancel"), Colors::white_or_black(false), || {
|
||||
self.confirm_cancel_tx_id = None;
|
||||
modal.close();
|
||||
Modal::close();
|
||||
});
|
||||
});
|
||||
columns[1].vertical_centered_justified(|ui| {
|
||||
View::button(ui, "OK".to_string(), Colors::white_or_black(false), || {
|
||||
wallet.cancel(self.confirm_cancel_tx_id.unwrap());
|
||||
self.confirm_cancel_tx_id = None;
|
||||
modal.close();
|
||||
Modal::close();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -107,7 +107,7 @@ impl WalletTransactionModal {
|
||||
// Check values and setup transaction data.
|
||||
let wallet_data = wallet.get_data();
|
||||
if wallet_data.is_none() {
|
||||
modal.close();
|
||||
Modal::close();
|
||||
return;
|
||||
}
|
||||
let data = wallet_data.unwrap();
|
||||
@@ -116,7 +116,7 @@ impl WalletTransactionModal {
|
||||
.filter(|tx| tx.data.id == self.tx_id)
|
||||
.collect::<Vec<WalletTransaction>>();
|
||||
if txs.is_empty() {
|
||||
modal.close();
|
||||
Modal::close();
|
||||
return;
|
||||
}
|
||||
let tx = txs.get(0).unwrap();
|
||||
@@ -141,7 +141,7 @@ impl WalletTransactionModal {
|
||||
cols[0].vertical_centered_justified(|ui| {
|
||||
View::button(ui, t!("close"), Colors::white_or_black(false), || {
|
||||
self.qr_code_content = None;
|
||||
modal.close();
|
||||
Modal::close();
|
||||
});
|
||||
});
|
||||
cols[1].vertical_centered_justified(|ui| {
|
||||
@@ -158,7 +158,7 @@ impl WalletTransactionModal {
|
||||
View::button(ui, t!("close"), Colors::white_or_black(false), || {
|
||||
cb.stop_camera();
|
||||
self.scan_qr_content = None;
|
||||
modal.close();
|
||||
Modal::close();
|
||||
});
|
||||
});
|
||||
cols[1].vertical_centered_justified(|ui| {
|
||||
@@ -177,7 +177,7 @@ impl WalletTransactionModal {
|
||||
// Show button to close modal.
|
||||
ui.vertical_centered_justified(|ui| {
|
||||
View::button(ui, t!("close"), Colors::white_or_black(false), || {
|
||||
modal.close();
|
||||
Modal::close();
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -483,7 +483,7 @@ impl WalletTransactionModal {
|
||||
if tx.can_finalize {
|
||||
self.show_finalization = true;
|
||||
} else {
|
||||
modal.close();
|
||||
Modal::close();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user