mirror of
https://github.com/jwinterm/grim.git
synced 2026-11-24 23:03:57 +01:00
ui: content container
This commit is contained in:
@@ -23,7 +23,7 @@ use crate::gui::Colors;
|
||||
use crate::gui::icons::{ARROWS_CLOCKWISE, BRIDGE, CAMERA_ROTATE, CHAT_CIRCLE_TEXT, FOLDER_USER, GEAR_FINE, GRAPH, PACKAGE, POWER, SCAN, SPINNER, USERS_THREE};
|
||||
use crate::gui::platform::PlatformCallbacks;
|
||||
use crate::gui::views::{Modal, Content, View, CameraContent};
|
||||
use crate::gui::views::types::{LinePosition, ModalContainer, ModalPosition, QrScanResult};
|
||||
use crate::gui::views::types::{LinePosition, ContentContainer, ModalPosition, QrScanResult};
|
||||
use crate::gui::views::wallets::{WalletTransactions, WalletMessages, WalletTransport};
|
||||
use crate::gui::views::wallets::types::{GRIN, WalletTab, WalletTabType};
|
||||
use crate::gui::views::wallets::wallet::modals::WalletAccountsModal;
|
||||
@@ -40,48 +40,47 @@ pub struct WalletContent {
|
||||
pub current_tab: Box<dyn WalletTab>,
|
||||
|
||||
/// Wallet accounts [`Modal`] content.
|
||||
accounts_modal_content: Option<WalletAccountsModal>,
|
||||
accounts_modal_content: WalletAccountsModal,
|
||||
|
||||
/// QR code scan content.
|
||||
pub qr_scan_content: Option<CameraContent>,
|
||||
|
||||
/// List of allowed [`Modal`] ids for this [`ModalContainer`].
|
||||
allowed_modal_ids: Vec<&'static str>
|
||||
}
|
||||
|
||||
/// Identifier for account list [`Modal`].
|
||||
const ACCOUNT_LIST_MODAL: &'static str = "account_list_modal";
|
||||
|
||||
impl ModalContainer for WalletContent {
|
||||
fn modal_ids(&self) -> &Vec<&'static str> {
|
||||
&self.allowed_modal_ids
|
||||
impl ContentContainer for WalletContent {
|
||||
fn modal_ids(&self) -> Vec<&'static str> {
|
||||
vec![
|
||||
ACCOUNT_LIST_MODAL,
|
||||
]
|
||||
}
|
||||
|
||||
fn modal_ui(&mut self, ui: &mut egui::Ui, modal: &Modal, cb: &dyn PlatformCallbacks) {
|
||||
match modal.id {
|
||||
ACCOUNT_LIST_MODAL => {
|
||||
if let Some(content) = self.accounts_modal_content.as_mut() {
|
||||
Modal::ui(ui.ctx(), |ui, modal| {
|
||||
content.ui(ui, &self.wallet, modal, cb);
|
||||
});
|
||||
}
|
||||
self.accounts_modal_content.ui(ui, &self.wallet, modal, cb);
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
fn on_back(&mut self, _: &dyn PlatformCallbacks) -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
fn container_ui(&mut self, _: &mut egui::Ui, _: &dyn PlatformCallbacks) {}
|
||||
}
|
||||
|
||||
impl WalletContent {
|
||||
/// Create new instance with optional data.
|
||||
pub fn new(wallet: Wallet, data: Option<String>) -> Self {
|
||||
let accounts_modal = WalletAccountsModal::new(wallet.accounts());
|
||||
let mut content = Self {
|
||||
wallet,
|
||||
accounts_modal_content: None,
|
||||
accounts_modal_content: accounts_modal,
|
||||
qr_scan_content: None,
|
||||
current_tab: Box::new(WalletTransactions::default()),
|
||||
allowed_modal_ids: vec![
|
||||
ACCOUNT_LIST_MODAL,
|
||||
],
|
||||
};
|
||||
if data.is_some() {
|
||||
content.on_data(data);
|
||||
@@ -97,7 +96,6 @@ impl WalletContent {
|
||||
/// Draw wallet content.
|
||||
pub fn ui(&mut self, ui: &mut egui::Ui, cb: &dyn PlatformCallbacks) {
|
||||
ui.ctx().request_repaint_after(Duration::from_millis(1000));
|
||||
self.current_modal_ui(ui, cb);
|
||||
|
||||
let dual_panel = Content::is_dual_panel_mode(ui.ctx());
|
||||
let show_wallets_dual = AppConfig::show_wallets_at_dual_panel();
|
||||
@@ -302,9 +300,7 @@ impl WalletContent {
|
||||
|
||||
// Draw button to show list of accounts.
|
||||
View::item_button(ui, View::item_rounding(1, 3, true), USERS_THREE, None, || {
|
||||
self.accounts_modal_content = Some(
|
||||
WalletAccountsModal::new(self.wallet.accounts())
|
||||
);
|
||||
self.accounts_modal_content = WalletAccountsModal::new(self.wallet.accounts());
|
||||
Modal::new(ACCOUNT_LIST_MODAL)
|
||||
.position(ModalPosition::CenterTop)
|
||||
.title(t!("wallets.accounts"))
|
||||
|
||||
@@ -37,10 +37,10 @@ pub struct WalletMessages {
|
||||
first_draw: bool,
|
||||
|
||||
/// Invoice or sending request creation [`Modal`] content.
|
||||
request_modal_content: Option<MessageRequestModal>,
|
||||
request_modal_content: MessageRequestModal,
|
||||
|
||||
/// Wallet transaction [`Modal`] content.
|
||||
tx_info_content: Option<WalletTransactionModal>,
|
||||
tx_info_content: WalletTransactionModal,
|
||||
|
||||
/// Slatepacks message input text.
|
||||
message_edit: String,
|
||||
@@ -85,8 +85,8 @@ impl WalletMessages {
|
||||
message_loading: false,
|
||||
message_error: "".to_string(),
|
||||
message_result: Arc::new(Default::default()),
|
||||
tx_info_content: None,
|
||||
request_modal_content: None,
|
||||
tx_info_content: WalletTransactionModal::new(None, false),
|
||||
request_modal_content: MessageRequestModal::new(false),
|
||||
file_pick_button: FilePickButton::default(),
|
||||
scan_modal_content: None,
|
||||
}
|
||||
@@ -129,23 +129,19 @@ impl WalletMessages {
|
||||
Some(id) => {
|
||||
match id {
|
||||
REQUEST_MODAL => {
|
||||
if let Some(content) = self.request_modal_content.as_mut() {
|
||||
Modal::ui(ui.ctx(), |ui, modal| {
|
||||
content.ui(ui, wallet, modal, cb);
|
||||
});
|
||||
}
|
||||
Modal::ui(ui.ctx(), cb, |ui, modal, cb| {
|
||||
self.request_modal_content.ui(ui, wallet, modal, cb);
|
||||
});
|
||||
}
|
||||
TX_INFO_MODAL => {
|
||||
if let Some(content) = self.tx_info_content.as_mut() {
|
||||
Modal::ui(ui.ctx(), |ui, modal| {
|
||||
content.ui(ui, wallet, modal, cb);
|
||||
});
|
||||
}
|
||||
Modal::ui(ui.ctx(), cb, |ui, modal, cb| {
|
||||
self.tx_info_content.ui(ui, wallet, modal, cb);
|
||||
});
|
||||
}
|
||||
SCAN_QR_MODAL => {
|
||||
let mut result = None;
|
||||
if let Some(content) = self.scan_modal_content.as_mut() {
|
||||
Modal::ui(ui.ctx(), |ui, _| {
|
||||
Modal::ui(ui.ctx(), cb, |ui, _, cb| {
|
||||
content.ui(ui, cb, |res| {
|
||||
result = Some(res.clone());
|
||||
Modal::close();
|
||||
@@ -217,7 +213,7 @@ impl WalletMessages {
|
||||
|
||||
/// Show [`Modal`] to create invoice or sending request.
|
||||
fn show_request_modal(&mut self, invoice: bool) {
|
||||
self.request_modal_content = Some(MessageRequestModal::new(invoice));
|
||||
self.request_modal_content = MessageRequestModal::new(invoice);
|
||||
let title = if invoice {
|
||||
t!("wallets.receive")
|
||||
} else {
|
||||
@@ -299,7 +295,7 @@ impl WalletMessages {
|
||||
Ok(tx) => {
|
||||
self.message_edit.clear();
|
||||
// Show transaction modal on success.
|
||||
self.tx_info_content = Some(WalletTransactionModal::new(wallet, tx, false));
|
||||
self.tx_info_content = WalletTransactionModal::new(Some(tx.data.id), false);
|
||||
Modal::new(TX_INFO_MODAL)
|
||||
.position(ModalPosition::CenterTop)
|
||||
.title(t!("wallets.tx"))
|
||||
@@ -322,9 +318,8 @@ impl WalletMessages {
|
||||
// Show tx modal or show default error message.
|
||||
if let Some(tx) = wallet.tx_by_slate(&slate).as_ref() {
|
||||
self.message_edit.clear();
|
||||
self.tx_info_content = Some(
|
||||
WalletTransactionModal::new(wallet, tx, false)
|
||||
);
|
||||
self.tx_info_content =
|
||||
WalletTransactionModal::new(Some(tx.data.id), false);
|
||||
Modal::new(TX_INFO_MODAL)
|
||||
.position(ModalPosition::CenterTop)
|
||||
.title(t!("wallets.tx"))
|
||||
@@ -427,7 +422,7 @@ impl WalletMessages {
|
||||
if exists {
|
||||
if let Some(tx) = wallet.tx_by_slate(&slate).as_ref() {
|
||||
self.message_edit.clear();
|
||||
self.tx_info_content = Some(WalletTransactionModal::new(wallet, tx, false));
|
||||
self.tx_info_content = WalletTransactionModal::new(Some(tx.data.id), false);
|
||||
Modal::new(TX_INFO_MODAL)
|
||||
.position(ModalPosition::CenterTop)
|
||||
.title(t!("wallets.tx"))
|
||||
|
||||
@@ -229,7 +229,8 @@ impl MessageRequestModal {
|
||||
let result = r_request.as_ref().unwrap();
|
||||
match result {
|
||||
Ok(tx) => {
|
||||
self.result_tx_content = Some(WalletTransactionModal::new(wallet, tx, false));
|
||||
self.result_tx_content =
|
||||
Some(WalletTransactionModal::new(Some(tx.data.id), false));
|
||||
}
|
||||
Err(err) => {
|
||||
match err {
|
||||
|
||||
@@ -146,17 +146,17 @@ impl CommonSettings {
|
||||
Some(id) => {
|
||||
match id {
|
||||
NAME_EDIT_MODAL => {
|
||||
Modal::ui(ui.ctx(), |ui, modal| {
|
||||
Modal::ui(ui.ctx(), cb, |ui, modal, cb| {
|
||||
self.name_modal_ui(ui, wallet, modal, cb);
|
||||
});
|
||||
}
|
||||
PASS_EDIT_MODAL => {
|
||||
Modal::ui(ui.ctx(), |ui, modal| {
|
||||
Modal::ui(ui.ctx(), cb, |ui, modal, cb| {
|
||||
self.pass_modal_ui(ui, wallet, modal, cb);
|
||||
});
|
||||
}
|
||||
MIN_CONFIRMATIONS_EDIT_MODAL => {
|
||||
Modal::ui(ui.ctx(), |ui, modal| {
|
||||
Modal::ui(ui.ctx(), cb, |ui, modal, cb| {
|
||||
self.min_conf_modal_ui(ui, wallet, modal, cb);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ use crate::gui::platform::PlatformCallbacks;
|
||||
use crate::gui::views::{Modal, View};
|
||||
use crate::gui::views::network::ConnectionsContent;
|
||||
use crate::gui::views::network::modals::ExternalConnectionModal;
|
||||
use crate::gui::views::types::{ModalContainer, ModalPosition};
|
||||
use crate::gui::views::types::{ContentContainer, ModalPosition};
|
||||
use crate::wallet::{ConnectionsConfig, ExternalConnection, Wallet};
|
||||
use crate::wallet::types::ConnectionMethod;
|
||||
|
||||
@@ -31,9 +31,6 @@ pub struct ConnectionSettings {
|
||||
|
||||
/// External connection [`Modal`] content.
|
||||
ext_conn_modal: ExternalConnectionModal,
|
||||
|
||||
/// [`Modal`] identifiers allowed at this ui container.
|
||||
modal_ids: Vec<&'static str>
|
||||
}
|
||||
|
||||
impl Default for ConnectionSettings {
|
||||
@@ -41,16 +38,15 @@ impl Default for ConnectionSettings {
|
||||
Self {
|
||||
method: ConnectionMethod::Integrated,
|
||||
ext_conn_modal: ExternalConnectionModal::new(None),
|
||||
modal_ids: vec![
|
||||
ExternalConnectionModal::WALLET_ID
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl ModalContainer for ConnectionSettings {
|
||||
fn modal_ids(&self) -> &Vec<&'static str> {
|
||||
&self.modal_ids
|
||||
impl ContentContainer for ConnectionSettings {
|
||||
fn modal_ids(&self) -> Vec<&'static str> {
|
||||
vec![
|
||||
ExternalConnectionModal::WALLET_ID
|
||||
]
|
||||
}
|
||||
|
||||
fn modal_ui(&mut self,
|
||||
@@ -64,20 +60,21 @@ impl ModalContainer for ConnectionSettings {
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
fn on_back(&mut self, _: &dyn PlatformCallbacks) -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
fn container_ui(&mut self, _: &mut egui::Ui, _: &dyn PlatformCallbacks) {}
|
||||
}
|
||||
|
||||
impl ConnectionSettings {
|
||||
/// Draw wallet creation setup content.
|
||||
pub fn create_ui(&mut self, ui: &mut egui::Ui, cb: &dyn PlatformCallbacks) {
|
||||
self.ui(ui, cb);
|
||||
}
|
||||
|
||||
/// Draw existing wallet connection setup content.
|
||||
pub fn wallet_ui(&mut self, ui: &mut egui::Ui, wallet: &Wallet, cb: &dyn PlatformCallbacks) {
|
||||
self.method = wallet.get_current_connection();
|
||||
|
||||
// Draw setup content.
|
||||
let changed = self.ui(ui, cb);
|
||||
let changed = self.content_ui(ui, cb);
|
||||
|
||||
if changed {
|
||||
wallet.update_connection(&self.method);
|
||||
@@ -90,10 +87,9 @@ impl ConnectionSettings {
|
||||
}
|
||||
|
||||
/// Draw connection setup content, returning `true` if connection was changed.
|
||||
fn ui(&mut self, ui: &mut egui::Ui, cb: &dyn PlatformCallbacks) -> bool {
|
||||
pub fn content_ui(&mut self, ui: &mut egui::Ui, cb: &dyn PlatformCallbacks) -> bool {
|
||||
self.ui(ui, cb);
|
||||
let mut changed = false;
|
||||
// Draw modal content for current ui container.
|
||||
self.current_modal_ui(ui, cb);
|
||||
|
||||
ui.add_space(2.0);
|
||||
View::sub_title(ui, format!("{} {}", GLOBE, t!("wallets.conn_method")));
|
||||
|
||||
@@ -148,12 +148,12 @@ impl RecoverySettings {
|
||||
Some(id) => {
|
||||
match id {
|
||||
RECOVERY_PHRASE_MODAL => {
|
||||
Modal::ui(ui.ctx(), |ui, modal| {
|
||||
Modal::ui(ui.ctx(), cb, |ui, modal, cb| {
|
||||
self.recovery_phrase_modal_ui(ui, wallet, modal, cb);
|
||||
});
|
||||
}
|
||||
DELETE_CONFIRMATION_MODAL => {
|
||||
Modal::ui(ui.ctx(), |ui, _| {
|
||||
Modal::ui(ui.ctx(), cb, |ui, _, _| {
|
||||
self.deletion_modal_ui(ui, wallet);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -96,20 +96,20 @@ impl WalletTransport {
|
||||
match id {
|
||||
SEND_TOR_MODAL => {
|
||||
if let Some(content) = self.send_modal_content.as_mut() {
|
||||
Modal::ui(ui.ctx(), |ui, modal| {
|
||||
Modal::ui(ui.ctx(), cb, |ui, modal, cb| {
|
||||
content.ui(ui, wallet, modal, cb);
|
||||
});
|
||||
}
|
||||
}
|
||||
TOR_SETTINGS_MODAL => {
|
||||
if let Some(content) = self.settings_modal_content.as_mut() {
|
||||
Modal::ui(ui.ctx(), |ui, modal| {
|
||||
Modal::ui(ui.ctx(), cb, |ui, modal, cb| {
|
||||
content.ui(ui, wallet, modal, cb);
|
||||
});
|
||||
}
|
||||
}
|
||||
QR_ADDRESS_MODAL => {
|
||||
Modal::ui(ui.ctx(), |ui, _| {
|
||||
Modal::ui(ui.ctx(), cb, |ui, _, cb| {
|
||||
self.qr_address_modal_ui(ui, cb);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -342,7 +342,7 @@ impl TransportSendModal {
|
||||
match res {
|
||||
Ok(tx) => {
|
||||
self.tx_info_content =
|
||||
Some(WalletTransactionModal::new(wallet, &tx, false));
|
||||
Some(WalletTransactionModal::new(Some(tx.data.id), false));
|
||||
}
|
||||
Err(_) => {
|
||||
self.error = true;
|
||||
|
||||
@@ -165,7 +165,7 @@ impl WalletTransactions {
|
||||
r.nw = 0.0 as u8;
|
||||
r.sw = 0.0 as u8;
|
||||
View::item_button(ui, r, FILE_TEXT, None, || {
|
||||
self.show_tx_info_modal(wallet, tx, false);
|
||||
self.show_tx_info_modal(tx, false);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -175,7 +175,7 @@ impl WalletTransactions {
|
||||
if wallet_loaded && tx.can_finalize {
|
||||
let (icon, color) = (CHECK, Some(Colors::green()));
|
||||
View::item_button(ui, CornerRadius::default(), icon, color, || {
|
||||
self.show_tx_info_modal(wallet, tx, true);
|
||||
self.show_tx_info_modal(tx, true);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -246,14 +246,14 @@ impl WalletTransactions {
|
||||
Some(id) => {
|
||||
match id {
|
||||
TX_INFO_MODAL => {
|
||||
Modal::ui(ui.ctx(), |ui, modal| {
|
||||
Modal::ui(ui.ctx(), cb, |ui, modal, cb| {
|
||||
if let Some(content) = self.tx_info_content.as_mut() {
|
||||
content.ui(ui, wallet, modal, cb);
|
||||
}
|
||||
});
|
||||
}
|
||||
CANCEL_TX_CONFIRMATION_MODAL => {
|
||||
Modal::ui(ui.ctx(), |ui, _| {
|
||||
Modal::ui(ui.ctx(), cb, |ui, _, cb| {
|
||||
self.cancel_confirmation_modal(ui, wallet);
|
||||
});
|
||||
}
|
||||
@@ -453,8 +453,8 @@ impl WalletTransactions {
|
||||
}
|
||||
|
||||
/// Show transaction information [`Modal`].
|
||||
fn show_tx_info_modal(&mut self, wallet: &Wallet, tx: &WalletTransaction, finalize: bool) {
|
||||
let modal = WalletTransactionModal::new(wallet, tx, finalize);
|
||||
fn show_tx_info_modal(&mut self, tx: &WalletTransaction, finalize: bool) {
|
||||
let modal = WalletTransactionModal::new(Some(tx.data.id), finalize);
|
||||
self.tx_info_content = Some(modal);
|
||||
Modal::new(TX_INFO_MODAL)
|
||||
.position(ModalPosition::CenterTop)
|
||||
|
||||
@@ -36,7 +36,7 @@ pub struct WalletTransactionModal {
|
||||
tx_id: u32,
|
||||
|
||||
/// Response Slatepack message input value.
|
||||
response_edit: String,
|
||||
response_edit: Option<String>,
|
||||
|
||||
/// Flag to show transaction finalization input.
|
||||
show_finalization: bool,
|
||||
@@ -61,32 +61,10 @@ pub struct WalletTransactionModal {
|
||||
|
||||
impl WalletTransactionModal {
|
||||
/// Create new content instance with [`Wallet`] from provided [`WalletTransaction`].
|
||||
pub fn new(wallet: &Wallet, tx: &WalletTransaction, show_finalization: bool) -> Self {
|
||||
pub fn new(tx_id: Option<u32>, show_finalization: bool) -> Self {
|
||||
Self {
|
||||
tx_id: tx.data.id,
|
||||
response_edit: if !tx.cancelling && !tx.finalizing && !tx.data.confirmed &&
|
||||
tx.data.tx_slate_id.is_some() &&
|
||||
(tx.data.tx_type == TxLogEntryType::TxSent ||
|
||||
tx.data.tx_type == TxLogEntryType::TxReceived) {
|
||||
let mut slate = Slate::blank(1, false);
|
||||
slate.state = if tx.can_finalize {
|
||||
if tx.data.tx_type == TxLogEntryType::TxSent {
|
||||
SlateState::Standard1
|
||||
} else {
|
||||
SlateState::Invoice1
|
||||
}
|
||||
} else {
|
||||
if tx.data.tx_type == TxLogEntryType::TxReceived {
|
||||
SlateState::Standard2
|
||||
} else {
|
||||
SlateState::Invoice2
|
||||
}
|
||||
};
|
||||
slate.id = tx.data.tx_slate_id.unwrap();
|
||||
wallet.read_slatepack(&slate).unwrap_or("".to_string())
|
||||
} else {
|
||||
"".to_string()
|
||||
},
|
||||
tx_id: tx_id.unwrap(),
|
||||
response_edit: None,
|
||||
finalize_edit: "".to_string(),
|
||||
finalize_error: false,
|
||||
show_finalization,
|
||||
@@ -121,13 +99,42 @@ impl WalletTransactionModal {
|
||||
}
|
||||
let tx = txs.get(0).unwrap();
|
||||
|
||||
// Check if response was loaded.
|
||||
if self.response_edit.is_none() {
|
||||
self.response_edit = Some(
|
||||
if !tx.cancelling && !tx.finalizing && !tx.data.confirmed &&
|
||||
tx.data.tx_slate_id.is_some() &&
|
||||
(tx.data.tx_type == TxLogEntryType::TxSent ||
|
||||
tx.data.tx_type == TxLogEntryType::TxReceived) {
|
||||
let mut slate = Slate::blank(1, false);
|
||||
slate.state = if tx.can_finalize {
|
||||
if tx.data.tx_type == TxLogEntryType::TxSent {
|
||||
SlateState::Standard1
|
||||
} else {
|
||||
SlateState::Invoice1
|
||||
}
|
||||
} else {
|
||||
if tx.data.tx_type == TxLogEntryType::TxReceived {
|
||||
SlateState::Standard2
|
||||
} else {
|
||||
SlateState::Invoice2
|
||||
}
|
||||
};
|
||||
slate.id = tx.data.tx_slate_id.unwrap();
|
||||
wallet.read_slatepack(&slate).unwrap_or("".to_string())
|
||||
} else {
|
||||
"".to_string()
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
// Show transaction information.
|
||||
if self.qr_code_content.is_none() && self.scan_qr_content.is_none() {
|
||||
self.info_ui(ui, tx, wallet, cb);
|
||||
}
|
||||
|
||||
// Show Slatepack message interaction.
|
||||
if !self.response_edit.is_empty() {
|
||||
if !self.response_edit.as_ref().unwrap().is_empty() {
|
||||
self.message_ui(ui, tx, wallet, modal, cb);
|
||||
}
|
||||
|
||||
@@ -201,7 +208,7 @@ impl WalletTransactionModal {
|
||||
if let Ok(_) = res {
|
||||
self.show_finalization = false;
|
||||
self.finalize_edit = "".to_string();
|
||||
self.response_edit = "".to_string();
|
||||
self.response_edit = Some("".to_string());
|
||||
} else {
|
||||
self.finalize_error = true;
|
||||
}
|
||||
@@ -370,7 +377,7 @@ impl WalletTransactionModal {
|
||||
let message_edit = if self.show_finalization {
|
||||
&mut self.finalize_edit
|
||||
} else {
|
||||
&mut self.response_edit
|
||||
&mut self.response_edit.as_mut().unwrap()
|
||||
};
|
||||
let message_before = message_edit.clone();
|
||||
|
||||
@@ -471,14 +478,14 @@ impl WalletTransactionModal {
|
||||
let qr_text = format!("{} {}", QR_CODE, t!("qr_code"));
|
||||
View::button(ui, qr_text.clone(), Colors::white_or_black(false), || {
|
||||
let text = self.response_edit.clone();
|
||||
self.qr_code_content = Some(QrCodeContent::new(text, true));
|
||||
self.qr_code_content = Some(QrCodeContent::new(text.unwrap(), true));
|
||||
});
|
||||
});
|
||||
columns[1].vertical_centered_justified(|ui| {
|
||||
// Draw copy button.
|
||||
let copy_text = format!("{} {}", COPY, t!("copy"));
|
||||
View::button(ui, copy_text, Colors::white_or_black(false), || {
|
||||
cb.copy_string_to_buffer(self.response_edit.clone());
|
||||
cb.copy_string_to_buffer(self.response_edit.clone().unwrap());
|
||||
self.finalize_edit = "".to_string();
|
||||
if tx.can_finalize {
|
||||
self.show_finalization = true;
|
||||
@@ -499,7 +506,7 @@ impl WalletTransactionModal {
|
||||
Colors::white_or_black(false), || {
|
||||
if let Some((s, _)) = wallet.read_slate_by_tx(tx) {
|
||||
let name = format!("{}.{}.slatepack", s.id, s.state);
|
||||
let data = self.response_edit.as_bytes().to_vec();
|
||||
let data = self.response_edit.as_ref().unwrap().as_bytes().to_vec();
|
||||
cb.share_data(name, data).unwrap_or_default();
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user