@@ -4,11 +4,12 @@ use ratatui::{
44 style:: { Color , Style , Stylize } ,
55 widgets:: { Block , BorderType , Borders , Clear , Padding , Paragraph } ,
66} ;
7+ use tui_input:: Input ;
78
89pub struct Auth ;
910
1011impl Auth {
11- pub fn render ( & self , frame : & mut Frame , passkey : & str ) {
12+ pub fn render ( & self , frame : & mut Frame , input : & Input , show_password : bool ) {
1213 let popup_layout = Layout :: default ( )
1314 . direction ( Direction :: Vertical )
1415 . constraints ( [
@@ -66,10 +67,16 @@ impl Auth {
6667 . style ( Style :: default ( ) . fg ( Color :: White ) )
6768 . block ( Block :: new ( ) . padding ( Padding :: uniform ( 1 ) ) ) ;
6869
69- let passkey = Paragraph :: new ( passkey)
70- . alignment ( Alignment :: Center )
71- . style ( Style :: default ( ) . fg ( Color :: White ) )
72- . block ( Block :: new ( ) . style ( Style :: default ( ) . bg ( Color :: DarkGray ) ) ) ;
70+ let passkey = Paragraph :: new ( {
71+ if show_password {
72+ input. value ( ) . to_string ( )
73+ } else {
74+ "*" . repeat ( input. value ( ) . len ( ) )
75+ }
76+ } )
77+ . alignment ( Alignment :: Center )
78+ . style ( Style :: default ( ) . fg ( Color :: White ) )
79+ . block ( Block :: new ( ) . style ( Style :: default ( ) . bg ( Color :: DarkGray ) ) ) ;
7380
7481 frame. render_widget ( Clear , area) ;
7582
0 commit comments