qr: export to gif and png

This commit is contained in:
ardocrat
2024-05-27 16:53:18 +03:00
parent d1d968f165
commit 00fd12cd2a
14 changed files with 614 additions and 166 deletions
+2
View File
@@ -403,6 +403,8 @@ impl WalletContent {
});
});
ui.add_space(6.0);
View::horizontal_line(ui, Colors::ITEM_STROKE);
ui.add_space(6.0);
} else if let Some(result) = self.camera_content.qr_scan_result() {
cb.stop_camera();
self.camera_content.clear_state();
+5 -13
View File
@@ -224,7 +224,7 @@ impl WalletMessages {
}
QR_SLATEPACK_MESSAGE_MODAL => {
Modal::ui(ui.ctx(), |ui, modal| {
self.qr_message_modal_ui(ui, modal);
self.qr_message_modal_ui(ui, modal, cb);
});
}
_ => {}
@@ -483,11 +483,7 @@ impl WalletMessages {
if text.is_empty() {
self.request_qr = false;
}
self.request_qr_content.ui(ui, text.clone());
ui.add_space(6.0);
// Show QR code text.
View::ellipsize_text(ui, text, 16.0, Colors::INACTIVE_TEXT);
self.request_qr_content.ui(ui, text.clone(), cb);
ui.add_space(6.0);
// Show button to close modal.
@@ -853,7 +849,7 @@ impl WalletMessages {
}
/// Draw QR code Slatepack message image [`Modal`] content.
fn qr_message_modal_ui(&mut self, ui: &mut egui::Ui, modal: &Modal) {
fn qr_message_modal_ui(&mut self, ui: &mut egui::Ui, m: &Modal, cb: &dyn PlatformCallbacks) {
ui.add_space(6.0);
// Setup title for Slatepack message.
@@ -871,11 +867,7 @@ impl WalletMessages {
// Draw QR code content.
let text = self.qr_message_text.clone().unwrap();
self.qr_message_content.ui(ui, text.clone());
ui.add_space(6.0);
// Show message text.
View::ellipsize_text(ui, text, 16.0, Colors::INACTIVE_TEXT);
self.qr_message_content.ui(ui, text.clone(), cb);
ui.add_space(6.0);
ui.vertical_centered_justified(|ui| {
@@ -884,7 +876,7 @@ impl WalletMessages {
self.qr_message_content.clear_state();
self.response_edit.clear();
self.message_slate = None;
modal.close();
m.close();
});
});
ui.add_space(6.0);
+5 -9
View File
@@ -187,7 +187,7 @@ impl WalletTransport {
}
QR_ADDRESS_MODAL => {
Modal::ui(ui.ctx(), |ui, modal| {
self.qr_address_modal_ui(ui, modal);
self.qr_address_modal_ui(ui, modal, cb);
});
}
_ => {}
@@ -584,22 +584,18 @@ impl WalletTransport {
}
/// Draw QR code image address [`Modal`] content.
fn qr_address_modal_ui(&mut self, ui: &mut egui::Ui, modal: &Modal) {
fn qr_address_modal_ui(&mut self, ui: &mut egui::Ui, m: &Modal, cb: &dyn PlatformCallbacks) {
ui.add_space(6.0);
// Draw QR code content.
let text = self.qr_address_content.text.clone();
self.qr_address_content.ui(ui, text.clone());
ui.add_space(6.0);
// Show address.
View::ellipsize_text(ui, text, 16.0, Colors::GRAY);
ui.add_space(6.0);
self.qr_address_content.ui(ui, text.clone(), cb);
ui.add_space(10.0);
ui.vertical_centered_justified(|ui| {
View::button(ui, t!("close"), Colors::WHITE, || {
self.qr_address_content.clear_state();
modal.close();
m.close();
});
ui.add_space(6.0);
});
+6 -12
View File
@@ -122,7 +122,7 @@ impl WalletTab for WalletTransactions {
.show_inside(ui, |ui| {
ui.vertical_centered(|ui| {
let data = wallet.get_data().unwrap();
self.txs_ui(ui, wallet, &data, cb);
self.txs_ui(ui, wallet, &data);
});
});
}
@@ -142,8 +142,7 @@ impl WalletTransactions {
fn txs_ui(&mut self,
ui: &mut egui::Ui,
wallet: &mut Wallet,
data: &WalletData,
cb: &dyn PlatformCallbacks) {
data: &WalletData) {
let amount_conf = data.info.amount_awaiting_confirmation;
let amount_fin = data.info.amount_awaiting_finalization;
let amount_locked = data.info.amount_locked;
@@ -224,7 +223,7 @@ impl WalletTransactions {
// Show transaction item.
let tx = data.txs.get(index).unwrap();
let rounding = View::item_rounding(index, data.txs.len(), false);
self.tx_item_ui(ui, tx, rounding, padding, true, &data, wallet, cb);
self.tx_item_ui(ui, tx, rounding, padding, true, &data, wallet);
}
});
})
@@ -291,8 +290,7 @@ impl WalletTransactions {
extra_padding: bool,
can_show_info: bool,
data: &WalletData,
wallet: &mut Wallet,
cb: &dyn PlatformCallbacks) {
wallet: &mut Wallet) {
// Setup layout size.
let mut rect = ui.available_rect_before_wrap();
if extra_padding {
@@ -541,7 +539,7 @@ impl WalletTransactions {
// Show transaction amount status and time.
let rounding = View::item_rounding(0, 2, false);
self.tx_item_ui(ui, tx, rounding, false, false, &data, wallet, cb);
self.tx_item_ui(ui, tx, rounding, false, false, &data, wallet);
// Show transaction ID info.
if let Some(id) = tx.data.tx_slate_id {
@@ -773,11 +771,7 @@ impl WalletTransactions {
self.tx_info_show_qr = false;
} else {
// Draw QR code content.
self.tx_info_qr_code_content.ui(ui, text.clone());
ui.add_space(6.0);
// Show QR code text.
View::ellipsize_text(ui, text, 16.0, Colors::INACTIVE_TEXT);
self.tx_info_qr_code_content.ui(ui, text.clone(), cb);
return;
}
}