@@ -89,21 +89,21 @@ impl Adapter {
89
89
None => false ,
90
90
} ;
91
91
92
- let ( device_block , access_point_block, connected_devices_block, help_block) = {
92
+ let ( access_point_block, connected_devices_block, device_block , help_block) = {
93
93
let chunks = Layout :: default ( )
94
94
. direction ( Direction :: Vertical )
95
95
. constraints ( if any_connected_devices {
96
96
& [
97
- Constraint :: Percentage ( 33 ) ,
98
- Constraint :: Percentage ( 33 ) ,
99
- Constraint :: Percentage ( 33 ) ,
97
+ Constraint :: Length ( 5 ) ,
98
+ Constraint :: Fill ( 1 ) ,
99
+ Constraint :: Length ( 5 ) ,
100
100
Constraint :: Length ( 1 ) ,
101
101
]
102
102
} else {
103
103
& [
104
- Constraint :: Percentage ( 50 ) ,
105
- Constraint :: Percentage ( 50 ) ,
106
104
Constraint :: Fill ( 1 ) ,
105
+ Constraint :: Length ( 0 ) ,
106
+ Constraint :: Length ( 5 ) ,
107
107
Constraint :: Length ( 1 ) ,
108
108
]
109
109
} )
@@ -480,127 +480,21 @@ impl Adapter {
480
480
color_mode : ColorMode ,
481
481
focused_block : FocusedBlock ,
482
482
) {
483
- let ( device_block , station_block , known_networks_block, new_networks_block, help_block) = {
483
+ let ( known_networks_block, new_networks_block, device_block , help_block) = {
484
484
let chunks = Layout :: default ( )
485
485
. direction ( Direction :: Vertical )
486
486
. constraints ( [
487
- Constraint :: Length ( 5 ) ,
488
- Constraint :: Length ( 5 ) ,
489
487
Constraint :: Min ( 5 ) ,
490
488
Constraint :: Min ( 5 ) ,
489
+ Constraint :: Length ( 5 ) ,
491
490
Constraint :: Length ( 1 ) ,
492
491
] )
493
492
. margin ( 1 )
494
493
. split ( frame. area ( ) ) ;
495
- ( chunks[ 0 ] , chunks[ 1 ] , chunks[ 2 ] , chunks[ 3 ] , chunks [ 4 ] )
494
+ ( chunks[ 0 ] , chunks[ 1 ] , chunks[ 2 ] , chunks[ 3 ] )
496
495
} ;
497
496
498
497
// Device
499
- let row = Row :: new ( vec ! [
500
- Line :: from( self . device. name. clone( ) ) . centered( ) ,
501
- Line :: from( "station" ) . centered( ) ,
502
- {
503
- if self . device. is_powered {
504
- Line :: from( "On" ) . centered( )
505
- } else {
506
- Line :: from( "Off" ) . centered( )
507
- }
508
- } ,
509
- Line :: from( self . device. address. clone( ) ) . centered( ) ,
510
- ] ) ;
511
-
512
- let widths = [
513
- Constraint :: Length ( 15 ) ,
514
- Constraint :: Length ( 8 ) ,
515
- Constraint :: Length ( 10 ) ,
516
- Constraint :: Length ( 17 ) ,
517
- ] ;
518
-
519
- let device_table = Table :: new ( vec ! [ row] , widths)
520
- . header ( {
521
- if focused_block == FocusedBlock :: Device {
522
- Row :: new ( vec ! [
523
- Line :: from( "Name" ) . yellow( ) . centered( ) ,
524
- Line :: from( "Mode" ) . yellow( ) . centered( ) ,
525
- Line :: from( "Powered" ) . yellow( ) . centered( ) ,
526
- Line :: from( "Address" ) . yellow( ) . centered( ) ,
527
- ] )
528
- . style ( Style :: new ( ) . bold ( ) )
529
- . bottom_margin ( 1 )
530
- } else {
531
- Row :: new ( vec ! [
532
- Line :: from( "Name" )
533
- . style( match color_mode {
534
- ColorMode :: Dark => Style :: default ( ) . fg( Color :: White ) ,
535
- ColorMode :: Light => Style :: default ( ) . fg( Color :: Black ) ,
536
- } )
537
- . centered( ) ,
538
- Line :: from( "Mode" )
539
- . style( match color_mode {
540
- ColorMode :: Dark => Style :: default ( ) . fg( Color :: White ) ,
541
- ColorMode :: Light => Style :: default ( ) . fg( Color :: Black ) ,
542
- } )
543
- . centered( ) ,
544
- Line :: from( "Powered" )
545
- . style( match color_mode {
546
- ColorMode :: Dark => Style :: default ( ) . fg( Color :: White ) ,
547
- ColorMode :: Light => Style :: default ( ) . fg( Color :: Black ) ,
548
- } )
549
- . centered( ) ,
550
- Line :: from( "Address" )
551
- . style( match color_mode {
552
- ColorMode :: Dark => Style :: default ( ) . fg( Color :: White ) ,
553
- ColorMode :: Light => Style :: default ( ) . fg( Color :: Black ) ,
554
- } )
555
- . centered( ) ,
556
- ] )
557
- . style ( Style :: new ( ) . bold ( ) )
558
- . bottom_margin ( 1 )
559
- }
560
- } )
561
- . block (
562
- Block :: default ( )
563
- . title ( " Device " )
564
- . title_style ( {
565
- if focused_block == FocusedBlock :: Device {
566
- Style :: default ( ) . bold ( )
567
- } else {
568
- Style :: default ( )
569
- }
570
- } )
571
- . borders ( Borders :: ALL )
572
- . border_style ( {
573
- if focused_block == FocusedBlock :: Device {
574
- Style :: default ( ) . fg ( Color :: Green )
575
- } else {
576
- Style :: default ( )
577
- }
578
- } )
579
- . border_type ( {
580
- if focused_block == FocusedBlock :: Device {
581
- BorderType :: Thick
582
- } else {
583
- BorderType :: default ( )
584
- }
585
- } )
586
- . padding ( Padding :: horizontal ( 1 ) ) ,
587
- )
588
- . column_spacing ( 2 )
589
- . flex ( Flex :: SpaceBetween )
590
- . style ( match color_mode {
591
- ColorMode :: Dark => Style :: default ( ) . fg ( Color :: White ) ,
592
- ColorMode :: Light => Style :: default ( ) . fg ( Color :: Black ) ,
593
- } )
594
- . row_highlight_style ( if focused_block == FocusedBlock :: Device {
595
- Style :: default ( ) . bg ( Color :: DarkGray ) . fg ( Color :: White )
596
- } else {
597
- Style :: default ( )
598
- } ) ;
599
-
600
- let mut device_state = TableState :: default ( ) . with_selected ( 0 ) ;
601
- frame. render_stateful_widget ( device_table, device_block, & mut device_state) ;
602
-
603
- // Station
604
498
605
499
let station_frequency = {
606
500
match self . device . station . as_ref ( ) {
@@ -643,26 +537,40 @@ impl Adapter {
643
537
station_state = station. state . clone ( ) ;
644
538
station_is_scanning = station. is_scanning . clone ( ) . to_string ( ) ;
645
539
}
646
- let row = vec ! [
540
+
541
+ let row = Row :: new ( vec ! [
542
+ Line :: from( self . device. name. clone( ) ) . centered( ) ,
543
+ Line :: from( "station" ) . centered( ) ,
544
+ {
545
+ if self . device. is_powered {
546
+ Line :: from( "On" ) . centered( )
547
+ } else {
548
+ Line :: from( "Off" ) . centered( )
549
+ }
550
+ } ,
647
551
Line :: from( station_state) . centered( ) ,
648
552
Line :: from( station_is_scanning) . centered( ) ,
649
553
Line :: from( station_frequency) . centered( ) ,
650
554
Line :: from( station_security) . centered( ) ,
651
- ] ;
652
-
653
- let row = Row :: new ( row) ;
555
+ ] ) ;
654
556
655
557
let widths = [
558
+ Constraint :: Length ( 10 ) ,
559
+ Constraint :: Length ( 8 ) ,
560
+ Constraint :: Length ( 10 ) ,
656
561
Constraint :: Length ( 12 ) ,
657
562
Constraint :: Length ( 10 ) ,
658
563
Constraint :: Length ( 10 ) ,
659
564
Constraint :: Length ( 15 ) ,
660
565
] ;
661
566
662
- let station_table = Table :: new ( vec ! [ row] , widths)
567
+ let device_table = Table :: new ( vec ! [ row] , widths)
663
568
. header ( {
664
- if focused_block == FocusedBlock :: Station {
569
+ if focused_block == FocusedBlock :: Device {
665
570
Row :: new ( vec ! [
571
+ Line :: from( "Name" ) . yellow( ) . centered( ) ,
572
+ Line :: from( "Mode" ) . yellow( ) . centered( ) ,
573
+ Line :: from( "Powered" ) . yellow( ) . centered( ) ,
666
574
Line :: from( "State" ) . yellow( ) . centered( ) ,
667
575
Line :: from( "Scanning" ) . yellow( ) . centered( ) ,
668
576
Line :: from( "Frequency" ) . yellow( ) . centered( ) ,
@@ -672,6 +580,24 @@ impl Adapter {
672
580
. bottom_margin ( 1 )
673
581
} else {
674
582
Row :: new ( vec ! [
583
+ Line :: from( "Name" )
584
+ . style( match color_mode {
585
+ ColorMode :: Dark => Style :: default ( ) . fg( Color :: White ) ,
586
+ ColorMode :: Light => Style :: default ( ) . fg( Color :: Black ) ,
587
+ } )
588
+ . centered( ) ,
589
+ Line :: from( "Mode" )
590
+ . style( match color_mode {
591
+ ColorMode :: Dark => Style :: default ( ) . fg( Color :: White ) ,
592
+ ColorMode :: Light => Style :: default ( ) . fg( Color :: Black ) ,
593
+ } )
594
+ . centered( ) ,
595
+ Line :: from( "Powered" )
596
+ . style( match color_mode {
597
+ ColorMode :: Dark => Style :: default ( ) . fg( Color :: White ) ,
598
+ ColorMode :: Light => Style :: default ( ) . fg( Color :: Black ) ,
599
+ } )
600
+ . centered( ) ,
675
601
Line :: from( "State" )
676
602
. style( match color_mode {
677
603
ColorMode :: Dark => Style :: default ( ) . fg( Color :: White ) ,
@@ -703,45 +629,45 @@ impl Adapter {
703
629
} )
704
630
. block (
705
631
Block :: default ( )
706
- . title ( " Station " )
632
+ . title ( " Device " )
707
633
. title_style ( {
708
- if focused_block == FocusedBlock :: Station {
634
+ if focused_block == FocusedBlock :: Device {
709
635
Style :: default ( ) . bold ( )
710
636
} else {
711
637
Style :: default ( )
712
638
}
713
639
} )
714
640
. borders ( Borders :: ALL )
715
641
. border_style ( {
716
- if focused_block == FocusedBlock :: Station {
642
+ if focused_block == FocusedBlock :: Device {
717
643
Style :: default ( ) . fg ( Color :: Green )
718
644
} else {
719
645
Style :: default ( )
720
646
}
721
647
} )
722
648
. border_type ( {
723
- if focused_block == FocusedBlock :: Station {
649
+ if focused_block == FocusedBlock :: Device {
724
650
BorderType :: Thick
725
651
} else {
726
652
BorderType :: default ( )
727
653
}
728
654
} )
729
655
. padding ( Padding :: horizontal ( 1 ) ) ,
730
656
)
731
- . column_spacing ( 2 )
657
+ . column_spacing ( 1 )
732
658
. flex ( Flex :: SpaceBetween )
733
659
. style ( match color_mode {
734
660
ColorMode :: Dark => Style :: default ( ) . fg ( Color :: White ) ,
735
661
ColorMode :: Light => Style :: default ( ) . fg ( Color :: Black ) ,
736
662
} )
737
- . row_highlight_style ( if focused_block == FocusedBlock :: Station {
663
+ . row_highlight_style ( if focused_block == FocusedBlock :: Device {
738
664
Style :: default ( ) . bg ( Color :: DarkGray ) . fg ( Color :: White )
739
665
} else {
740
666
Style :: default ( )
741
667
} ) ;
742
668
743
- let mut station_state = TableState :: default ( ) . with_selected ( 0 ) ;
744
- frame. render_stateful_widget ( station_table , station_block , & mut station_state ) ;
669
+ let mut device_state = TableState :: default ( ) . with_selected ( 0 ) ;
670
+ frame. render_stateful_widget ( device_table , device_block , & mut device_state ) ;
745
671
746
672
// Known networks
747
673
let known_networks = if let Some ( station) = self . device . station . as_ref ( ) {
@@ -1052,16 +978,6 @@ impl Adapter {
1052
978
Span :: from( "⇄" ) . bold( ) ,
1053
979
Span :: from( " Nav" ) ,
1054
980
] ) ,
1055
- FocusedBlock :: Station => Line :: from ( vec ! [
1056
- Span :: from( self . config. station. start_scanning. to_string( ) ) . bold( ) ,
1057
- Span :: from( " Scan" ) ,
1058
- Span :: from( " | " ) ,
1059
- Span :: from( "ctrl+r" ) . bold( ) ,
1060
- Span :: from( " Switch Mode" ) ,
1061
- Span :: from( " | " ) ,
1062
- Span :: from( "⇄" ) . bold( ) ,
1063
- Span :: from( " Nav" ) ,
1064
- ] ) ,
1065
981
FocusedBlock :: KnownNetworks => Line :: from ( vec ! [
1066
982
Span :: from( "k," ) . bold( ) ,
1067
983
Span :: from( " Up" ) ,
@@ -1075,7 +991,7 @@ impl Adapter {
1075
991
self . config. station. toggle_connect. to_string( )
1076
992
} )
1077
993
. bold( ) ,
1078
- Span :: from( " Connect/Disconnect " ) ,
994
+ Span :: from( " Dis/connect " ) ,
1079
995
Span :: from( " | " ) ,
1080
996
Span :: from( self . config. station. known_network. remove. to_string( ) ) . bold( ) ,
1081
997
Span :: from( " Remove" ) ,
@@ -1088,7 +1004,10 @@ impl Adapter {
1088
1004
. to_string( ) ,
1089
1005
)
1090
1006
. bold( ) ,
1091
- Span :: from( " Toggle Autoconnect" ) ,
1007
+ Span :: from( " Autoconnect" ) ,
1008
+ Span :: from( " | " ) ,
1009
+ Span :: from( self . config. station. start_scanning. to_string( ) ) . bold( ) ,
1010
+ Span :: from( " Scan" ) ,
1092
1011
Span :: from( " | " ) ,
1093
1012
Span :: from( " " ) . bold( ) ,
1094
1013
Span :: from( " Discard" ) ,
@@ -1109,6 +1028,9 @@ impl Adapter {
1109
1028
Span :: from( " " ) . bold( ) ,
1110
1029
Span :: from( " Connect" ) ,
1111
1030
Span :: from( " | " ) ,
1031
+ Span :: from( self . config. station. start_scanning. to_string( ) ) . bold( ) ,
1032
+ Span :: from( " Scan" ) ,
1033
+ Span :: from( " | " ) ,
1112
1034
Span :: from( " " ) . bold( ) ,
1113
1035
Span :: from( " Discard" ) ,
1114
1036
Span :: from( " | " ) ,
@@ -1135,7 +1057,7 @@ impl Adapter {
1135
1057
. constraints ( [
1136
1058
Constraint :: Fill ( 1 ) ,
1137
1059
Constraint :: Length ( 9 ) ,
1138
- Constraint :: Fill ( 5 ) ,
1060
+ Constraint :: Fill ( 1 ) ,
1139
1061
] )
1140
1062
. flex ( Flex :: Start )
1141
1063
. split ( frame. area ( ) ) ;
0 commit comments