Skip to content

Commit aaebf15

Browse files
committed
show icon for hide/show password
1 parent b499a03 commit aaebf15

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

src/app.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ impl App {
115115
let current_mode = adapter.device.mode.clone();
116116

117117
let (passkey_sender, passkey_receiver) = async_channel::unbounded();
118-
let show_password = false;
118+
let show_password = true;
119119
let (cancel_signal_sender, cancel_signal_receiver) = async_channel::unbounded();
120120

121121
let authentication_required = Arc::new(AtomicBool::new(false));

src/mode/station/auth.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use ratatui::{
22
Frame,
33
layout::{Alignment, Constraint, Direction, Layout},
44
style::{Color, Style, Stylize},
5+
text::Text,
56
widgets::{Block, BorderType, Borders, Clear, Padding, Paragraph},
67
};
78
use tui_input::Input;
@@ -30,7 +31,7 @@ impl Auth {
3031
.flex(ratatui::layout::Flex::SpaceBetween)
3132
.split(popup_layout[1])[1];
3233

33-
let (text_area, passkey_area) = {
34+
let (text_area, passkey_area, show_password_area) = {
3435
let chunks = Layout::default()
3536
.direction(Direction::Vertical)
3637
.constraints([
@@ -55,11 +56,12 @@ impl Auth {
5556
.constraints([
5657
Constraint::Percentage(20),
5758
Constraint::Fill(1),
59+
Constraint::Length(5),
5860
Constraint::Percentage(20),
5961
])
6062
.split(chunks[2]);
6163

62-
(area1[1], area2[1])
64+
(area1[1], area2[1], area2[2])
6365
};
6466

6567
let text = Paragraph::new("Enter the password")
@@ -78,6 +80,12 @@ impl Auth {
7880
.style(Style::default().fg(Color::White))
7981
.block(Block::new().style(Style::default().bg(Color::DarkGray)));
8082

83+
let show_password_icon = if show_password {
84+
Text::from(" ").centered()
85+
} else {
86+
Text::from(" ").centered()
87+
};
88+
8189
frame.render_widget(Clear, area);
8290

8391
frame.render_widget(
@@ -90,5 +98,6 @@ impl Auth {
9098
);
9199
frame.render_widget(text, text_area);
92100
frame.render_widget(passkey, passkey_area);
101+
frame.render_widget(show_password_icon, show_password_area);
93102
}
94103
}

0 commit comments

Comments
 (0)