ui: stratum wallet selection button, fix de i18n, modal padding, rename connection

This commit is contained in:
ardocrat
2024-07-10 20:58:05 +03:00
parent f142ae110a
commit 383d733c2a
12 changed files with 93 additions and 21 deletions
+3 -8
View File
@@ -319,24 +319,19 @@ impl Modal {
// Draw title content.
let title_resp = ui.allocate_ui_at_rect(rect, |ui| {
ui.vertical_centered_justified(|ui| {
ui.add_space(Self::DEFAULT_MARGIN + if !View::is_desktop() {
1.0
} else {
0.0
});
ui.add_space(Self::DEFAULT_MARGIN + 1.0);
ui.label(RichText::new(self.title.as_ref().unwrap())
.size(19.0)
.color(Colors::title(true))
);
ui.add_space(Self::DEFAULT_MARGIN);
// Draw line below title.
View::horizontal_line(ui, Colors::item_stroke());
});
}).response;
// Setup background shape to be painted behind title content.
bg_shape.rect = title_resp.rect;
ui.painter().set(bg_idx, bg_shape);
// Draw line below title.
View::horizontal_line(ui, Colors::stroke());
}
}
+12 -4
View File
@@ -24,17 +24,27 @@ use crate::gui::views::{NetworkContent, Content, View};
use crate::gui::views::network::setup::StratumSetup;
use crate::gui::views::network::types::{NetworkTab, NetworkTabType};
use crate::node::{Node, NodeConfig};
use crate::wallet::WalletConfig;
/// Mining tab content.
pub struct NetworkMining {
/// Stratum server setup content.
stratum_server_setup: StratumSetup,
/// Wallet name for rewards.
wallet_name: String,
}
impl Default for NetworkMining {
fn default() -> Self {
let wallet_name = if let Some(id) = NodeConfig::get_stratum_wallet_id() {
WalletConfig::name_by_id(id).unwrap_or("-".to_string())
} else {
"-".to_string()
};
Self {
stratum_server_setup: StratumSetup::default()
stratum_server_setup: StratumSetup::default(),
wallet_name,
}
}
}
@@ -103,10 +113,8 @@ impl NetworkTab for NetworkMining {
[true, false, true, false]);
});
columns[1].vertical_centered(|ui| {
//TODO: Stratum mining wallet listening address. Replace with local wallet name.
let wallet_addr = NodeConfig::get_stratum_wallet_addr().replace("http://", "");
View::rounded_box(ui,
wallet_addr,
self.wallet_name.clone(),
t!("network_mining.rewards_wallet"),
[false, true, false, true]);
});
+30 -1
View File
@@ -21,6 +21,7 @@ use crate::gui::views::{Modal, View};
use crate::gui::views::network::settings::NetworkSettings;
use crate::gui::views::types::{ModalContainer, ModalPosition, TextEditOptions};
use crate::node::{Node, NodeConfig};
use crate::wallet::WalletConfig;
/// Stratum server setup section content.
pub struct StratumSetup {
@@ -35,6 +36,9 @@ pub struct StratumSetup {
/// Flag to check if stratum port from saved config value is available.
is_port_available: bool,
/// Wallet name to receive rewards.
wallet_name: Option<String>,
/// Attempt time value in seconds to mine on a particular header.
attempt_time_edit: String,
@@ -56,11 +60,17 @@ impl Default for StratumSetup {
fn default() -> Self {
let (ip, port) = NodeConfig::get_stratum_address();
let is_port_available = NodeConfig::is_stratum_port_available(&ip, &port);
let wallet_name = if let Some(id) = NodeConfig::get_stratum_wallet_id() {
WalletConfig::name_by_id(id)
} else {
None
};
Self {
available_ips: NodeConfig::get_ip_addrs(),
stratum_port_edit: port,
stratum_port_available_edit: is_port_available,
is_port_available,
wallet_name,
attempt_time_edit: NodeConfig::get_stratum_attempt_time(),
min_share_diff_edit: NodeConfig::get_stratum_min_share_diff(),
modal_ids: vec![
@@ -101,7 +111,7 @@ impl StratumSetup {
ui.vertical_centered(|ui| {
// Show loading indicator or controls to start/stop stratum server if port is available.
if self.is_port_available {
if self.is_port_available && self.wallet_name.is_some() {
if Node::is_stratum_starting() || Node::is_stratum_stopping() {
ui.vertical_centered(|ui| {
ui.add_space(8.0);
@@ -145,6 +155,25 @@ impl StratumSetup {
View::horizontal_line(ui, Colors::item_stroke());
ui.add_space(6.0);
// Show wallet name.
ui.add_space(2.0);
ui.label(RichText::new(t!("wallets.wallet"))
.size(16.0)
.color(Colors::gray()));
ui.add_space(2.0);
ui.label(RichText::new(self.wallet_name.as_ref().unwrap_or(&"-".to_string()))
.size(16.0)
.color(Colors::white_or_black(true)));
ui.add_space(8.0);
View::button(ui, t!("network_settings.choose_wallet"), Colors::button(), || {
//TODO: select wallet
});
ui.add_space(12.0);
View::horizontal_line(ui, Colors::item_stroke());
ui.add_space(6.0);
// Show message when IP addresses are not available on the system.
if self.available_ips.is_empty() {
NetworkSettings::no_ip_address_ui(ui);
@@ -30,6 +30,7 @@ pub struct WalletConnectionModal {
/// Flag to show connection creation.
show_conn_creation: bool,
/// External connection creation content.
add_ext_conn_content: ExternalConnectionModal
}
@@ -72,7 +73,7 @@ impl WalletConnectionModal {
})
.id_source("integrated_node")
.scroll_bar_visibility(ScrollBarVisibility::AlwaysHidden)
.auto_shrink([false; 2])
.auto_shrink([true; 2])
.show(ui, |ui| {
ui.add_space(2.0);
+2 -2
View File
@@ -12,5 +12,5 @@
// See the License for the specific language governing permissions and
// limitations under the License.
mod connection;
pub use connection::*;
mod conn;
pub use conn::*;