Skip to content

Commit ae501ef

Browse files
committed
password visibilitty toggle
1 parent a6d3562 commit ae501ef

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

src/components/menus/network/wifi/APStaging/PasswordInput.tsx

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export const PasswordInput = ({
1010
staging,
1111
isConnectingWithPassword,
1212
}: PasswordInputProps): JSX.Element => {
13-
const showPassword = true;
13+
const showPassword = Variable(false);
1414

1515
return (
1616
<box className="network-password-input-container" halign={Gtk.Align.FILL} hexpand vertical>
@@ -19,7 +19,7 @@ export const PasswordInput = ({
1919
className="network-password-input"
2020
hexpand
2121
halign={Gtk.Align.START}
22-
visibility={!showPassword}
22+
visibility={bind(showPassword)}
2323
placeholderText="Enter Password"
2424
onKeyPressEvent={(self, event) => {
2525
handlePasswordInput(self, event, staging, isConnectingWithPassword);
@@ -28,6 +28,23 @@ export const PasswordInput = ({
2828
setTimeout(() => self.grab_focus(), 100);
2929
}}
3030
/>
31+
<button
32+
className="toggle-password-visibility-button"
33+
halign={Gtk.Align.END}
34+
onClick={(_, event) => {
35+
if (isPrimaryClick(event)) {
36+
showPassword.set(!showPassword.get());
37+
}
38+
}}
39+
tooltipText={bind(showPassword).as((show) => (show ? 'Hide password' : 'Show password'))}
40+
>
41+
<icon
42+
className="toggle-password-visibility-icon"
43+
icon={bind(showPassword).as((show) =>
44+
show ? 'view-conceal-symbolic' : 'view-reveal-symbolic',
45+
)}
46+
/>
47+
</button>
3148
<button
3249
className="close-network-password-input-button"
3350
halign={Gtk.Align.END}

0 commit comments

Comments
 (0)