@@ -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,43 @@ 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
+ } ,
551
+ Line :: from( self . device. address. clone( ) ) . centered( ) ,
647
552
Line :: from( station_state) . centered( ) ,
648
553
Line :: from( station_is_scanning) . centered( ) ,
649
554
Line :: from( station_frequency) . centered( ) ,
650
555
Line :: from( station_security) . centered( ) ,
651
- ] ;
652
-
653
- let row = Row :: new ( row) ;
556
+ ] ) ;
654
557
655
558
let widths = [
559
+ Constraint :: Length ( 15 ) ,
560
+ Constraint :: Length ( 8 ) ,
561
+ Constraint :: Length ( 10 ) ,
562
+ Constraint :: Length ( 17 ) ,
656
563
Constraint :: Length ( 12 ) ,
657
564
Constraint :: Length ( 10 ) ,
658
565
Constraint :: Length ( 10 ) ,
659
566
Constraint :: Length ( 15 ) ,
660
567
] ;
661
568
662
- let station_table = Table :: new ( vec ! [ row] , widths)
569
+ let device_table = Table :: new ( vec ! [ row] , widths)
663
570
. header ( {
664
- if focused_block == FocusedBlock :: Station {
571
+ if focused_block == FocusedBlock :: Device {
665
572
Row :: new ( vec ! [
573
+ Line :: from( "Name" ) . yellow( ) . centered( ) ,
574
+ Line :: from( "Mode" ) . yellow( ) . centered( ) ,
575
+ Line :: from( "Powered" ) . yellow( ) . centered( ) ,
576
+ Line :: from( "Address" ) . yellow( ) . centered( ) ,
666
577
Line :: from( "State" ) . yellow( ) . centered( ) ,
667
578
Line :: from( "Scanning" ) . yellow( ) . centered( ) ,
668
579
Line :: from( "Frequency" ) . yellow( ) . centered( ) ,
@@ -672,25 +583,25 @@ impl Adapter {
672
583
. bottom_margin ( 1 )
673
584
} else {
674
585
Row :: new ( vec ! [
675
- Line :: from( "State " )
586
+ Line :: from( "Name " )
676
587
. style( match color_mode {
677
588
ColorMode :: Dark => Style :: default ( ) . fg( Color :: White ) ,
678
589
ColorMode :: Light => Style :: default ( ) . fg( Color :: Black ) ,
679
590
} )
680
591
. centered( ) ,
681
- Line :: from( "Scanning " )
592
+ Line :: from( "Mode " )
682
593
. style( match color_mode {
683
594
ColorMode :: Dark => Style :: default ( ) . fg( Color :: White ) ,
684
595
ColorMode :: Light => Style :: default ( ) . fg( Color :: Black ) ,
685
596
} )
686
597
. centered( ) ,
687
- Line :: from( "Frequency " )
598
+ Line :: from( "Powered " )
688
599
. style( match color_mode {
689
600
ColorMode :: Dark => Style :: default ( ) . fg( Color :: White ) ,
690
601
ColorMode :: Light => Style :: default ( ) . fg( Color :: Black ) ,
691
602
} )
692
603
. centered( ) ,
693
- Line :: from( "Security " )
604
+ Line :: from( "Address " )
694
605
. style( match color_mode {
695
606
ColorMode :: Dark => Style :: default ( ) . fg( Color :: White ) ,
696
607
ColorMode :: Light => Style :: default ( ) . fg( Color :: Black ) ,
@@ -703,24 +614,24 @@ impl Adapter {
703
614
} )
704
615
. block (
705
616
Block :: default ( )
706
- . title ( " Station " )
617
+ . title ( " Device " )
707
618
. title_style ( {
708
- if focused_block == FocusedBlock :: Station {
619
+ if focused_block == FocusedBlock :: Device {
709
620
Style :: default ( ) . bold ( )
710
621
} else {
711
622
Style :: default ( )
712
623
}
713
624
} )
714
625
. borders ( Borders :: ALL )
715
626
. border_style ( {
716
- if focused_block == FocusedBlock :: Station {
627
+ if focused_block == FocusedBlock :: Device {
717
628
Style :: default ( ) . fg ( Color :: Green )
718
629
} else {
719
630
Style :: default ( )
720
631
}
721
632
} )
722
633
. border_type ( {
723
- if focused_block == FocusedBlock :: Station {
634
+ if focused_block == FocusedBlock :: Device {
724
635
BorderType :: Thick
725
636
} else {
726
637
BorderType :: default ( )
@@ -734,14 +645,14 @@ impl Adapter {
734
645
ColorMode :: Dark => Style :: default ( ) . fg ( Color :: White ) ,
735
646
ColorMode :: Light => Style :: default ( ) . fg ( Color :: Black ) ,
736
647
} )
737
- . row_highlight_style ( if focused_block == FocusedBlock :: Station {
648
+ . row_highlight_style ( if focused_block == FocusedBlock :: Device {
738
649
Style :: default ( ) . bg ( Color :: DarkGray ) . fg ( Color :: White )
739
650
} else {
740
651
Style :: default ( )
741
652
} ) ;
742
653
743
- let mut station_state = TableState :: default ( ) . with_selected ( 0 ) ;
744
- frame. render_stateful_widget ( station_table , station_block , & mut station_state ) ;
654
+ let mut device_state = TableState :: default ( ) . with_selected ( 0 ) ;
655
+ frame. render_stateful_widget ( device_table , device_block , & mut device_state ) ;
745
656
746
657
// Known networks
747
658
let known_networks = if let Some ( station) = self . device . station . as_ref ( ) {
@@ -1052,16 +963,6 @@ impl Adapter {
1052
963
Span :: from( "β" ) . bold( ) ,
1053
964
Span :: from( " Nav" ) ,
1054
965
] ) ,
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
966
FocusedBlock :: KnownNetworks => Line :: from ( vec ! [
1066
967
Span :: from( "k,ο’" ) . bold( ) ,
1067
968
Span :: from( " Up" ) ,
@@ -1090,6 +991,9 @@ impl Adapter {
1090
991
. bold( ) ,
1091
992
Span :: from( " Toggle Autoconnect" ) ,
1092
993
Span :: from( " | " ) ,
994
+ Span :: from( self . config. station. start_scanning. to_string( ) ) . bold( ) ,
995
+ Span :: from( " Scan" ) ,
996
+ Span :: from( " | " ) ,
1093
997
Span :: from( "σ±· " ) . bold( ) ,
1094
998
Span :: from( " Discard" ) ,
1095
999
Span :: from( " | " ) ,
@@ -1109,6 +1013,9 @@ impl Adapter {
1109
1013
Span :: from( "σ± " ) . bold( ) ,
1110
1014
Span :: from( " Connect" ) ,
1111
1015
Span :: from( " | " ) ,
1016
+ Span :: from( self . config. station. start_scanning. to_string( ) ) . bold( ) ,
1017
+ Span :: from( " Scan" ) ,
1018
+ Span :: from( " | " ) ,
1112
1019
Span :: from( "σ±· " ) . bold( ) ,
1113
1020
Span :: from( " Discard" ) ,
1114
1021
Span :: from( " | " ) ,
0 commit comments