mirror of
https://code.gri.mw/GUI/grim.git
synced 2026-07-04 05:57:29 +00:00
ui: make qr codes background lighter for better scanning
This commit is contained in:
+2
-2
@@ -44,7 +44,6 @@ const BLUE_DARK: Color32 =
|
||||
const FILL: Color32 = Color32::from_gray(244);
|
||||
const FILL_DARK: Color32 = Color32::from_gray(26);
|
||||
|
||||
const FILL_DEEP: Color32 = Color32::from_gray(238);
|
||||
const FILL_DEEP_DARK: Color32 = Color32::from_gray(32);
|
||||
|
||||
const FILL_LITE: Color32 = Color32::from_gray(249);
|
||||
@@ -85,6 +84,7 @@ fn use_dark() -> bool {
|
||||
}
|
||||
|
||||
impl Colors {
|
||||
pub const FILL_DEEP: Color32 = Color32::from_gray(238);
|
||||
pub const TRANSPARENT: Color32 = Color32::from_rgba_premultiplied(0, 0, 0, 0);
|
||||
pub const STROKE: Color32 = Color32::from_gray(200);
|
||||
|
||||
@@ -172,7 +172,7 @@ impl Colors {
|
||||
if use_dark() {
|
||||
FILL_DEEP_DARK
|
||||
} else {
|
||||
FILL_DEEP
|
||||
Self::FILL_DEEP
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+11
-2
@@ -14,7 +14,7 @@
|
||||
|
||||
use egui::epaint::{RectShape, Shadow};
|
||||
use egui::os::OperatingSystem;
|
||||
use egui::{Align2, CornerRadius, RichText, Stroke, StrokeKind, UiBuilder, Vec2};
|
||||
use egui::{Align2, Color32, CornerRadius, RichText, Stroke, StrokeKind, UiBuilder, Vec2};
|
||||
use lazy_static::lazy_static;
|
||||
use parking_lot::RwLock;
|
||||
use std::sync::atomic::{AtomicBool, Ordering};
|
||||
@@ -43,6 +43,8 @@ pub struct Modal {
|
||||
title: Option<String>,
|
||||
/// Flag to check first content render.
|
||||
first_draw: Arc<AtomicBool>,
|
||||
/// Background color.
|
||||
fill: Color32,
|
||||
}
|
||||
|
||||
impl Modal {
|
||||
@@ -61,6 +63,7 @@ impl Modal {
|
||||
closeable: Arc::new(AtomicBool::new(true)),
|
||||
title: None,
|
||||
first_draw: Arc::new(AtomicBool::new(true)),
|
||||
fill: Colors::fill(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -295,6 +298,12 @@ impl Modal {
|
||||
(align, offset)
|
||||
}
|
||||
|
||||
/// Set custom background color.
|
||||
pub fn set_background_color(&self, color: Color32) {
|
||||
let mut w_state = MODAL_STATE.write();
|
||||
w_state.modal.as_mut().unwrap().fill = color;
|
||||
}
|
||||
|
||||
/// Draw provided content.
|
||||
fn content_ui(&self,
|
||||
ui: &mut egui::Ui,
|
||||
@@ -312,7 +321,7 @@ impl Modal {
|
||||
sw: 8.0 as u8,
|
||||
se: 8.0 as u8,
|
||||
}
|
||||
}, Colors::fill(), Stroke::NONE, StrokeKind::Outside);
|
||||
}, self.fill, Stroke::NONE, StrokeKind::Outside);
|
||||
let bg_idx = ui.painter().add(bg_shape.clone());
|
||||
|
||||
rect.min += egui::emath::vec2(6.0, 0.0);
|
||||
|
||||
@@ -311,14 +311,14 @@ impl WalletAccountContent {
|
||||
match result {
|
||||
QrScanResult::Address(a) => {
|
||||
if let Some(data) = wallet.get_data() {
|
||||
//if data.info.amount_currently_spendable > 0 {
|
||||
if data.info.amount_currently_spendable > 0 {
|
||||
let address = Some(a.to_string());
|
||||
self.send_content = Some(SendRequestContent::new(address));
|
||||
Modal::new(SEND_MODAL_ID)
|
||||
.position(ModalPosition::CenterTop)
|
||||
.title(t!("wallets.send"))
|
||||
.show();
|
||||
//}
|
||||
}
|
||||
}
|
||||
}
|
||||
QrScanResult::Slatepack(m) => {
|
||||
|
||||
@@ -208,7 +208,11 @@ impl WalletContentContainer for WalletContent {
|
||||
bottom: 1.0 as i8,
|
||||
},
|
||||
fill: if top_panel_expanded {
|
||||
Colors::fill_lite()
|
||||
if self.transport_content.qr_address_content.is_some() {
|
||||
Colors::FILL_DEEP
|
||||
} else {
|
||||
Colors::fill_lite()
|
||||
}
|
||||
} else {
|
||||
Colors::TRANSPARENT
|
||||
},
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
use egui::{Align, CornerRadius, Layout, RichText, StrokeKind};
|
||||
|
||||
use crate::AppConfig;
|
||||
use crate::gui::icons::{CIRCLE_HALF, DOTS_THREE_CIRCLE, PLUGS, PLUGS_CONNECTED, POWER, QR_CODE, SHIELD_CHECKERED, SHIELD_SLASH, WARNING_CIRCLE, WRENCH};
|
||||
use crate::gui::platform::PlatformCallbacks;
|
||||
use crate::gui::views::wallets::wallet::transport::settings::WalletTransportSettingsContent;
|
||||
@@ -40,6 +41,10 @@ impl WalletContentContainer for WalletTransportContent {
|
||||
|
||||
fn container_ui(&mut self, ui: &mut egui::Ui, wallet: &Wallet, cb: &dyn PlatformCallbacks) {
|
||||
if let Some(content) = self.qr_address_content.as_mut() {
|
||||
let dark_theme = AppConfig::dark_theme().unwrap_or(false);
|
||||
// Set light theme for better scanning.
|
||||
AppConfig::set_dark_theme(false);
|
||||
crate::setup_visuals(ui.ctx());
|
||||
// Draw QR code content.
|
||||
ui.add_space(6.0);
|
||||
content.ui(ui, cb);
|
||||
@@ -49,6 +54,9 @@ impl WalletContentContainer for WalletTransportContent {
|
||||
});
|
||||
});
|
||||
ui.add_space(6.0);
|
||||
// Set color theme back.
|
||||
AppConfig::set_dark_theme(dark_theme);
|
||||
crate::setup_visuals(ui.ctx());
|
||||
} else if let Some(content) = self.settings_content.as_mut() {
|
||||
let mut closed = false;
|
||||
content.ui(ui, wallet, cb, || {
|
||||
|
||||
@@ -52,7 +52,7 @@ impl WalletContentContainer for WalletTransactionsContent {
|
||||
match m.id {
|
||||
TX_INFO_MODAL => {
|
||||
if let Some(content) = self.tx_info_content.as_mut() {
|
||||
content.ui(ui, w, cb);
|
||||
content.ui(ui, m, w, cb);
|
||||
}
|
||||
}
|
||||
CANCEL_TX_CONFIRMATION_MODAL => {
|
||||
|
||||
@@ -19,6 +19,7 @@ use grin_util::ToHex;
|
||||
use grin_wallet_libwallet::TxLogEntryType;
|
||||
use std::fs;
|
||||
|
||||
use crate::AppConfig;
|
||||
use crate::gui::icons::{CIRCLE_HALF, COPY, CUBE, FILE_ARCHIVE, FILE_TEXT, HASH_STRAIGHT, PROHIBIT, QR_CODE, SEAL_CHECK};
|
||||
use crate::gui::platform::PlatformCallbacks;
|
||||
use crate::gui::views::wallets::wallet::proof::PaymentProofContent;
|
||||
@@ -54,7 +55,11 @@ impl WalletTransactionContent {
|
||||
}
|
||||
|
||||
/// Draw [`Modal`] content.
|
||||
pub fn ui(&mut self, ui: &mut egui::Ui, wallet: &Wallet, cb: &dyn PlatformCallbacks) {
|
||||
pub fn ui(&mut self,
|
||||
ui: &mut egui::Ui,
|
||||
modal: &Modal,
|
||||
wallet: &Wallet,
|
||||
cb: &dyn PlatformCallbacks) {
|
||||
// Check values and setup transaction data.
|
||||
let wallet_data = wallet.get_data();
|
||||
if wallet_data.is_none() {
|
||||
@@ -73,6 +78,12 @@ impl WalletTransactionContent {
|
||||
let tx = txs.get(0).unwrap();
|
||||
|
||||
if let Some(content) = self.qr_code_content.as_mut() {
|
||||
let dark_theme = AppConfig::dark_theme().unwrap_or(false);
|
||||
// Set light theme for better scanning.
|
||||
AppConfig::set_dark_theme(false);
|
||||
crate::setup_visuals(ui.ctx());
|
||||
modal.set_background_color(Colors::FILL_DEEP);
|
||||
|
||||
ui.add_space(6.0);
|
||||
content.ui(ui, cb);
|
||||
|
||||
@@ -93,7 +104,11 @@ impl WalletTransactionContent {
|
||||
});
|
||||
});
|
||||
});
|
||||
// Set color theme back.
|
||||
AppConfig::set_dark_theme(dark_theme);
|
||||
crate::setup_visuals(ui.ctx());
|
||||
} else {
|
||||
modal.set_background_color(Colors::fill());
|
||||
// Show transaction information.
|
||||
self.info_ui(ui, tx, wallet, cb);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user