1616use std:: collections:: BTreeMap ;
1717
1818use 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} ;
2222use 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( )
0 commit comments