Skip to content

Commit 2a73540

Browse files
committed
Node GUI visual improvements
1 parent 5e8c20a commit 2a73540

File tree

7 files changed

+83
-42
lines changed

7 files changed

+83
-42
lines changed

Cargo.lock

Lines changed: 8 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,9 @@ hex = "0.4"
174174
hex-literal = "0.4"
175175
hmac = "0.12"
176176
iced = "0.13"
177-
iced_aw = "0.11"
177+
# Note: we need this fix - https://github.com/iced-rs/iced_aw/pull/329
178+
# TODO: switch back to a released version of iced_aw once the fix is released (need version > 0.12)
179+
iced_aw = { git = "https://github.com/iced-rs/iced_aw", branch = "main" }
178180
iced_fonts = "0.1"
179181
indoc = "2.0"
180182
itertools = "0.14"

common/src/chain/config/builder.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ use super::{
5555

5656
// The fork at which we:
5757
// * enable tokens v1;
58-
// * upgrade consensus to PoSConsensusVersion::V1 to dis-incentivize large pools.
58+
// * upgrade consensus to PoSConsensusVersion::V1 to dis-incentivize large pools;
59+
// * change the maturity block count to 7200.
5960
const TESTNET_FORK_HEIGHT_1_TOKENS_V1: BlockHeight = BlockHeight::new(78_440);
6061

6162
// The fork at which we:

common/src/chain/config/checkpoints.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,16 @@ impl Checkpoints {
8383
.checkpoints
8484
.range(..=height)
8585
.next_back()
86-
.expect("Genesis must be there, at least.");
86+
.expect("Genesis must be there, at least");
8787
(*cp.0, *cp.1)
8888
}
8989

90+
pub fn last_checkpoint(&self) -> (BlockHeight, Id<GenBlock>) {
91+
let (height, cp) =
92+
self.checkpoints.last_key_value().expect("Genesis must be there, at least");
93+
(*height, *cp)
94+
}
95+
9096
#[cfg(test)]
9197
pub fn checkpoints_map(&self) -> &BTreeMap<BlockHeight, Id<GenBlock>> {
9298
&self.checkpoints

node-gui/src/main_window/main_widget/tabs/wallet/delegation.rs

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
use std::collections::BTreeMap;
1717

1818
use iced::{
19-
widget::{button, column, row, text_input, tooltip, tooltip::Position, Text},
19+
widget::{button, column, row, text_input, tooltip, tooltip::Position, Space, Text},
2020
Element, Length,
2121
};
2222
use iced_aw::{Grid, GridRow};
@@ -61,9 +61,15 @@ pub fn view_delegation(
6161
delegate_staking_amounts: &BTreeMap<DelegationId, String>,
6262
still_syncing: Option<WalletMessage>,
6363
) -> Element<'static, WalletMessage> {
64-
let field = |text: String| iced::widget::container(Text::new(text)).padding(5);
65-
6664
let delegation_balance_grid = {
65+
let field_padding = 5;
66+
// Default horizontal padding used by Button.
67+
let button_horizontal_padding = 10;
68+
let field = |text: String| iced::widget::container(Text::new(text)).padding(field_padding);
69+
70+
// Note: due to how the items are arranged in each row (and due to their lack of borders),
71+
// the visual spacing between columns will be `field_padding + button_horizontal_padding`.
72+
6773
// We print the table only if there are delegations
6874
if account.delegations_balance.is_empty() {
6975
Grid::new().push(
@@ -106,7 +112,7 @@ pub fn view_delegation(
106112
}
107113
)
108114
)
109-
.padding(5),
115+
.padding(field_padding),
110116
Text::new(delegation_address.to_string()),
111117
Position::Bottom,
112118
)
@@ -134,7 +140,7 @@ pub fn view_delegation(
134140
}
135141
)
136142
)
137-
.padding(5),
143+
.padding(field_padding),
138144
Text::new(pool_address.to_string()),
139145
Position::Bottom,
140146
)
@@ -149,6 +155,10 @@ pub fn view_delegation(
149155
.on_press(WalletMessage::CopyToClipboard(pool_address.to_string())),
150156
])
151157
.push(field(print_coin_amount(chain_config, balance)))
158+
.push(Space::new(
159+
Length::Fixed(button_horizontal_padding as f32),
160+
Length::Shrink,
161+
))
152162
.push(
153163
text_input("Amount", &delegate_staking_amount)
154164
.on_input(move |value| {
@@ -158,9 +168,13 @@ pub fn view_delegation(
158168
WalletMessage::NoOp
159169
}
160170
})
161-
.padding(5)
171+
.padding(field_padding)
162172
.width(Length::Fixed(100.)),
163173
)
174+
.push(Space::new(
175+
Length::Fixed((field_padding + button_horizontal_padding) as f32),
176+
Length::Shrink,
177+
))
164178
.push(
165179
button(Text::new("Delegate")).on_press(
166180
still_syncing
@@ -174,7 +188,16 @@ pub fn view_delegation(
174188
}
175189
};
176190

177-
let maturity_period = chain_config.staking_pool_spend_maturity_block_count(1.into()).to_int();
191+
let maturity_period = chain_config
192+
.staking_pool_spend_maturity_block_count(
193+
// Assume that at the last checkpoint we already had the latest value for the maturity
194+
// period.
195+
// Note: this value has only been upgraded once on testnet (where we initially had a
196+
// 2000 block maturity period).
197+
// TODO: it's probably better to pass the actual tip height here anyway.
198+
chain_config.height_checkpoints().last_checkpoint().0,
199+
)
200+
.to_int();
178201
let maturity_period_text = format!(
179202
"Maturity period: {maturity_period} blocks (a block takes on average {} seconds)",
180203
chain_config.target_block_spacing().as_secs()

node-gui/src/main_window/main_widget/tabs/wallet/left_panel.rs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,10 @@ pub fn view_left_panel(
9191
WalletMessage::SelectAccount(item.account_id)
9292
});
9393

94+
let panel_button_row_padding = 8;
95+
// The pick-list row looks a bit nicer when these values are equal.
96+
let pick_list_row_spacing = panel_button_row_padding;
97+
9498
let panel_button = |label, panel, selected_panel, tooltip_text| {
9599
let label = row![
96100
text(label).size(16).width(Length::Fill),
@@ -101,7 +105,7 @@ pub fn view_left_panel(
101105
tooltip::Position::Bottom
102106
)
103107
.gap(10)
104-
.style(iced::widget::container::bordered_box),
108+
.style(iced::widget::container::bordered_box)
105109
];
106110

107111
button(label)
@@ -112,7 +116,7 @@ pub fn view_left_panel(
112116
})
113117
.width(Length::Fill)
114118
.on_press(WalletMessage::SelectPanel(panel))
115-
.padding(8)
119+
.padding(panel_button_row_padding)
116120
};
117121

118122
// `next_height` is used to prevent flickering when a new block is found
@@ -159,7 +163,7 @@ pub fn view_left_panel(
159163
column![
160164
text(file_name).size(25),
161165
row![
162-
pick_list,
166+
pick_list.width(Length::Fill),
163167
button(Text::new("+"))
164168
.style(iced::widget::button::success)
165169
.on_press(WalletMessage::NewAccount),
@@ -170,14 +174,17 @@ pub fn view_left_panel(
170174
tooltip::Position::Bottom
171175
)
172176
.gap(10)
173-
.style(iced::widget::container::bordered_box),
177+
.style(iced::widget::container::bordered_box)
174178
]
175179
.align_y(Alignment::Center)
176-
.spacing(10)
180+
.spacing(pick_list_row_spacing)
177181
.width(Length::Fill)
178182
]
179183
.spacing(10)
180-
.padding(10),
184+
// Note: this specifies both vertical and horizontal padding; so if this value is different
185+
// from the one used in `panel_button`, the tooltip's question mark will be misaligned with
186+
// `panel_button's question marks.
187+
.padding(panel_button_row_padding),
181188
match wallet_info.wallet_type {
182189
#[cfg(feature = "trezor")]
183190
WalletType::Trezor => {

node-gui/src/main_window/main_widget/tabs/wallet/transactions.rs

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,26 @@ pub fn view_transactions(
3434
let mut transactions = Column::new();
3535

3636
let current_transaction_list = &account.transaction_list;
37-
let mut transaction_list = Grid::new().width(Length::Fill).push(
38-
GridRow::new()
39-
.push(field("#".into()))
40-
.push(field("Transaction Id".into()))
41-
.push(field("Timestamp (UTC)".into()))
42-
.push(field("Type".into()))
43-
.push(field("Amount".into()))
44-
.push(field("State".into())),
45-
);
37+
let mut transaction_list = Grid::new()
38+
.width(Length::Fill)
39+
.push(
40+
GridRow::new()
41+
.push(field("#".into()))
42+
.push(field("Transaction Id".into()))
43+
.push(field("Timestamp (UTC)".into()))
44+
.push(field("Type".into()))
45+
.push(field("Amount".into()))
46+
.push(field("State".into())),
47+
)
48+
.column_widths(&[
49+
// Make the number column stretch just a little bit, compared to the other ones.
50+
Length::FillPortion(1),
51+
Length::FillPortion(5),
52+
Length::FillPortion(5),
53+
Length::FillPortion(5),
54+
Length::FillPortion(5),
55+
Length::FillPortion(5),
56+
]);
4657
for (index, tx) in current_transaction_list.txs.iter().enumerate() {
4758
let amount_str = tx
4859
.tx_type

0 commit comments

Comments
 (0)