forked from Shinonome/dots-hyprland
wifi: more proper handling of password visibility
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
import App from 'resource:///com/github/Aylur/ags/app.js';
|
import App from 'resource:///com/github/Aylur/ags/app.js';
|
||||||
import Widget from 'resource:///com/github/Aylur/ags/widget.js';
|
|
||||||
import Network from "resource:///com/github/Aylur/ags/service/network.js";
|
import Network from "resource:///com/github/Aylur/ags/service/network.js";
|
||||||
|
import Variable from 'resource:///com/github/Aylur/ags/variable.js';
|
||||||
|
import Widget from 'resource:///com/github/Aylur/ags/widget.js';
|
||||||
import * as Utils from 'resource:///com/github/Aylur/ags/utils.js';
|
import * as Utils from 'resource:///com/github/Aylur/ags/utils.js';
|
||||||
const { Box, Button, Entry, Icon, Label, Revealer, Scrollable, Slider, Stack, Overlay } = Widget;
|
const { Box, Button, Entry, Icon, Label, Revealer, Scrollable, Slider, Stack, Overlay } = Widget;
|
||||||
const { execAsync, exec } = Utils;
|
const { execAsync, exec } = Utils;
|
||||||
@@ -98,7 +99,7 @@ const NetResource = (icon, command) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const CurrentNetwork = () => {
|
const CurrentNetwork = () => {
|
||||||
let passwordVisible = false;
|
const passwordVisible = Variable(false);
|
||||||
let authLock = false;
|
let authLock = false;
|
||||||
let timeoutId = null;
|
let timeoutId = null;
|
||||||
|
|
||||||
@@ -155,8 +156,7 @@ const CurrentNetwork = () => {
|
|||||||
label: getString('Cancel'),
|
label: getString('Cancel'),
|
||||||
hpack: 'end',
|
hpack: 'end',
|
||||||
onClicked: () => {
|
onClicked: () => {
|
||||||
passwordVisible = false;
|
passwordVisible.value = false;
|
||||||
authEntry.visibility = false;
|
|
||||||
networkAuth.revealChild = false;
|
networkAuth.revealChild = false;
|
||||||
authFailed.revealChild = false;
|
authFailed.revealChild = false;
|
||||||
networkAuthSSID.label = '';
|
networkAuthSSID.label = '';
|
||||||
@@ -179,11 +179,14 @@ const CurrentNetwork = () => {
|
|||||||
child: MaterialIcon('visibility', 'large'),
|
child: MaterialIcon('visibility', 'large'),
|
||||||
className: 'txt sidebar-wifinetworks-auth-visible',
|
className: 'txt sidebar-wifinetworks-auth-visible',
|
||||||
onClicked: (self) => {
|
onClicked: (self) => {
|
||||||
passwordVisible = !passwordVisible;
|
passwordVisible.value = !passwordVisible.value;
|
||||||
authEntry.visibility = passwordVisible;
|
},
|
||||||
self.child.label = passwordVisible ? 'visibility_off' : 'visibility';
|
setup: (self) => {
|
||||||
|
setupCursorHover(self)
|
||||||
|
self.hook(passwordVisible, (self) => {
|
||||||
|
self.child.label = passwordVisible.value ? 'visibility_off' : 'visibility';
|
||||||
|
})
|
||||||
},
|
},
|
||||||
setup: setupCursorHover,
|
|
||||||
});
|
});
|
||||||
const authFailed = Revealer({
|
const authFailed = Revealer({
|
||||||
revealChild: false,
|
revealChild: false,
|
||||||
@@ -208,8 +211,7 @@ const CurrentNetwork = () => {
|
|||||||
networkAuth.revealChild = false; // Hide input if successful
|
networkAuth.revealChild = false; // Hide input if successful
|
||||||
authFailed.revealChild = false; // Hide failed message if successful
|
authFailed.revealChild = false; // Hide failed message if successful
|
||||||
self.text = ''; // Empty input for retry
|
self.text = ''; // Empty input for retry
|
||||||
passwordVisible = false;
|
passwordVisible.value = false;
|
||||||
authEntry.visibility = false;
|
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
// Connection failed, show password input again
|
// Connection failed, show password input again
|
||||||
@@ -217,6 +219,9 @@ const CurrentNetwork = () => {
|
|||||||
authFailed.revealChild = true;
|
authFailed.revealChild = true;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
setup: (self) => self.hook(passwordVisible, (self) => {
|
||||||
|
self.visibility = passwordVisible.value
|
||||||
|
}),
|
||||||
placeholderText: getString('Enter network password'),
|
placeholderText: getString('Enter network password'),
|
||||||
});
|
});
|
||||||
const authBox = Box({
|
const authBox = Box({
|
||||||
@@ -312,8 +317,7 @@ const CurrentNetwork = () => {
|
|||||||
}
|
}
|
||||||
timeoutId = setTimeout(() => {
|
timeoutId = setTimeout(() => {
|
||||||
authLock = false;
|
authLock = false;
|
||||||
passwordVisible = false;
|
passwordVisible.value = false;
|
||||||
authEntry.visibility = false;
|
|
||||||
self.revealChild = false;
|
self.revealChild = false;
|
||||||
authFailed.revealChild = false;
|
authFailed.revealChild = false;
|
||||||
Network.wifi.state = 'activated';
|
Network.wifi.state = 'activated';
|
||||||
|
|||||||
Reference in New Issue
Block a user