@@ -416,13 +416,7 @@ impl App {
416416 . iter ( )
417417 . map ( |d| {
418418 Row :: new ( vec ! [
419- {
420- if let Some ( icon) = & d. icon {
421- format!( "{} {}" , icon, & d. alias)
422- } else {
423- d. alias. to_owned( )
424- }
425- } ,
419+ format!( "{} {}" , & d. icon, & d. alias) ,
426420 d. is_trusted. to_string( ) ,
427421 d. is_connected. to_string( ) ,
428422 {
@@ -586,43 +580,36 @@ impl App {
586580
587581 //New devices
588582
589- let mut max_name_width = 20 ;
590583 if render_new_devices {
591584 let rows: Vec < Row > = selected_controller
592585 . new_devices
593586 . iter ( )
594587 . map ( |d| {
595- Row :: new ( vec ! [ d. addr. to_string( ) , {
596- if let Some ( icon) = & d. icon {
597- format!( "{} {}" , icon, & d. alias)
598- } else {
599- if d. alias. len( ) > max_name_width {
600- max_name_width = d. alias. len( ) ;
601- }
602- d. alias. to_owned( )
603- }
604- } ] )
588+ Row :: new ( vec ! [
589+ d. addr. to_string( ) ,
590+ format!( "{} {}" , & d. icon, & d. alias) ,
591+ ] )
605592 } )
606593 . collect ( ) ;
607594 let rows_len = rows. len ( ) ;
608595
609- let widths = [
610- Constraint :: Length ( 20 ) ,
611- Constraint :: Length ( max_name_width. try_into ( ) . unwrap ( ) ) ,
612- ] ;
596+ let widths = [ Constraint :: Length ( 20 ) , Constraint :: Length ( 20 ) ] ;
613597
614598 let new_devices_table = Table :: new ( rows, widths)
615599 . header ( {
616600 if self . focused_block == FocusedBlock :: NewDevices {
617601 Row :: new ( vec ! [
618- Cell :: from( "Address" ) . style ( Style :: default ( ) . fg( Color :: Yellow ) ) ,
619- Cell :: from( "Name" ) . style ( Style :: default ( ) . fg( Color :: Yellow ) ) ,
602+ Cell :: from( Line :: from ( "Address" ) . fg( Color :: Yellow ) . centered ( ) ) ,
603+ Cell :: from( Line :: from ( "Name" ) . fg( Color :: Yellow ) . centered ( ) ) ,
620604 ] )
621605 . style ( Style :: new ( ) . bold ( ) )
622606 . bottom_margin ( 1 )
623607 } else {
624- Row :: new ( vec ! [ Cell :: from( "Address" ) , Cell :: from( "Name" ) ] )
625- . bottom_margin ( 1 )
608+ Row :: new ( vec ! [
609+ Cell :: from( Line :: from( "Address" ) . centered( ) ) ,
610+ Cell :: from( Line :: from( "Name" ) . centered( ) ) ,
611+ ] )
612+ . bottom_margin ( 1 )
626613 }
627614 } )
628615 . block (
0 commit comments