Skip to content

Commit bd8efd9

Browse files
committed
[feat](ui): Add line numbers
1 parent 01c43b4 commit bd8efd9

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

src/ui/home/block/transactions.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ pub fn render<B: Backend>(
2424
let selected_style = Style::default().add_modifier(Modifier::BOLD);
2525
let normal_style = Style::default().fg(Color::White);
2626
let header_cells = [
27+
"",
2728
"Hash",
2829
"Method",
2930
"Type",
@@ -42,8 +43,10 @@ pub fn render<B: Backend>(
4243
let items = block
4344
.transactions
4445
.iter()
45-
.map(|tx| {
46+
.enumerate()
47+
.map(|(i, tx)| {
4648
vec![
49+
Cell::from(format!(" {} ", i + 1)).fg(Color::White),
4750
Cell::from(format!("{}", tx.hash)).fg(Color::White),
4851
if tx.to.is_some() {
4952
if tx.input.len() >= 4 {
@@ -99,7 +102,8 @@ pub fn render<B: Backend>(
99102
}
100103
})),
101104
Cell::from(format_ether(tx.value).to_string()).fg(Color::White),
102-
Cell::from((if let Some(transaction_receipts) = transaction_receipts {
105+
Cell::from(
106+
(if let Some(transaction_receipts) = transaction_receipts {
103107
if let Some(transaction_receipt) = transaction_receipts
104108
.iter()
105109
.find(|receipt| receipt.transaction_hash == tx.hash)
@@ -114,7 +118,9 @@ pub fn render<B: Backend>(
114118
}
115119
} else {
116120
Spinner::default().to_string()
117-
}).to_string())
121+
})
122+
.to_string(),
123+
)
118124
.fg(Color::White),
119125
Cell::from(
120126
format_units(tx.gas_price.unwrap(), "gwei")
@@ -150,6 +156,7 @@ pub fn render<B: Backend>(
150156
)
151157
.highlight_style(selected_style)
152158
.widths(&[
159+
Constraint::Max(4),
153160
Constraint::Max(12), //Hash
154161
Constraint::Max(18), //Method
155162
Constraint::Max(10), //Type

src/ui/home/block/withdrawals.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ pub fn render<B: Backend>(
1717

1818
let selected_style = Style::default().add_modifier(Modifier::BOLD);
1919
let normal_style = Style::default().fg(Color::White);
20-
let header_cells = ["Index", "Validator Index", "Address", "Amount"]
20+
let header_cells = ["", "Index", "Validator Index", "Address", "Amount"]
2121
.iter()
2222
.map(|h| Cell::from(*h).style(Style::default().add_modifier(Modifier::BOLD)));
2323
let header = Row::new(header_cells)
@@ -27,8 +27,10 @@ pub fn render<B: Backend>(
2727
let items = block.withdrawals.as_ref().map_or(vec![], |withdrawals| {
2828
withdrawals
2929
.iter()
30-
.map(|withdrawal| {
30+
.enumerate()
31+
.map(|(i, withdrawal)| {
3132
vec![
33+
Cell::from(format!("{}", i + 1)).fg(Color::White),
3234
Cell::from(format!("{}", withdrawal.index)).fg(Color::White),
3335
Cell::from(format!("{}", withdrawal.validator_index)).fg(Color::White),
3436
Cell::from(format!("{}", withdrawal.address)).fg(Color::White),
@@ -62,6 +64,7 @@ pub fn render<B: Backend>(
6264
)
6365
.highlight_style(selected_style)
6466
.widths(&[
67+
Constraint::Max(3),
6568
Constraint::Max(12), //Index
6669
Constraint::Max(16), //Validator Index
6770
Constraint::Max(12), //Address

0 commit comments

Comments
 (0)