mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-05-03 02:52:07 -04:00
optimize some animations
This commit is contained in:
@@ -36,36 +36,36 @@ Item {
|
||||
|
||||
function normalizePinList(value) {
|
||||
if (Array.isArray(value))
|
||||
return value.filter(v => v)
|
||||
return value.filter(v => v);
|
||||
if (typeof value === "string" && value.length > 0)
|
||||
return [value]
|
||||
return []
|
||||
return [value];
|
||||
return [];
|
||||
}
|
||||
|
||||
function getPinnedWifiNetworks() {
|
||||
const pins = SettingsData.wifiNetworkPins || {}
|
||||
return normalizePinList(pins["preferredWifi"])
|
||||
const pins = SettingsData.wifiNetworkPins || {};
|
||||
return normalizePinList(pins["preferredWifi"]);
|
||||
}
|
||||
|
||||
function toggleWifiPin(ssid) {
|
||||
const pins = JSON.parse(JSON.stringify(SettingsData.wifiNetworkPins || {}))
|
||||
let pinnedList = normalizePinList(pins["preferredWifi"])
|
||||
const pinIndex = pinnedList.indexOf(ssid)
|
||||
const pins = JSON.parse(JSON.stringify(SettingsData.wifiNetworkPins || {}));
|
||||
let pinnedList = normalizePinList(pins["preferredWifi"]);
|
||||
const pinIndex = pinnedList.indexOf(ssid);
|
||||
|
||||
if (pinIndex !== -1) {
|
||||
pinnedList.splice(pinIndex, 1)
|
||||
pinnedList.splice(pinIndex, 1);
|
||||
} else {
|
||||
pinnedList.unshift(ssid)
|
||||
pinnedList.unshift(ssid);
|
||||
if (pinnedList.length > maxPinnedWifiNetworks)
|
||||
pinnedList = pinnedList.slice(0, maxPinnedWifiNetworks)
|
||||
pinnedList = pinnedList.slice(0, maxPinnedWifiNetworks);
|
||||
}
|
||||
|
||||
if (pinnedList.length > 0)
|
||||
pins["preferredWifi"] = pinnedList
|
||||
pins["preferredWifi"] = pinnedList;
|
||||
else
|
||||
delete pins["preferredWifi"]
|
||||
delete pins["preferredWifi"];
|
||||
|
||||
SettingsData.set("wifiNetworkPins", pins)
|
||||
SettingsData.set("wifiNetworkPins", pins);
|
||||
}
|
||||
|
||||
LazyLoader {
|
||||
@@ -340,9 +340,7 @@ Item {
|
||||
if (devices.length === 0)
|
||||
return I18n.tr("No adapters");
|
||||
if (connected === 0)
|
||||
return devices.length === 1
|
||||
? I18n.tr("%1 adapter, none connected").arg(devices.length)
|
||||
: I18n.tr("%1 adapters, none connected").arg(devices.length);
|
||||
return devices.length === 1 ? I18n.tr("%1 adapter, none connected").arg(devices.length) : I18n.tr("%1 adapters, none connected").arg(devices.length);
|
||||
return I18n.tr("%1 connected").arg(connected);
|
||||
}
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
@@ -658,16 +656,14 @@ Item {
|
||||
SequentialAnimation {
|
||||
running: NetworkService.networkWiredInfoLoading
|
||||
loops: Animation.Infinite
|
||||
NumberAnimation {
|
||||
OpacityAnimator {
|
||||
target: wiredLoadIcon
|
||||
property: "opacity"
|
||||
to: 0.3
|
||||
duration: 400
|
||||
easing.type: Easing.InOutQuad
|
||||
}
|
||||
NumberAnimation {
|
||||
OpacityAnimator {
|
||||
target: wiredLoadIcon
|
||||
property: "opacity"
|
||||
to: 1.0
|
||||
duration: 400
|
||||
easing.type: Easing.InOutQuad
|
||||
@@ -1046,16 +1042,14 @@ Item {
|
||||
SequentialAnimation {
|
||||
running: NetworkService.isScanning
|
||||
loops: Animation.Infinite
|
||||
NumberAnimation {
|
||||
OpacityAnimator {
|
||||
target: scanningIcon
|
||||
property: "opacity"
|
||||
to: 0.3
|
||||
duration: 400
|
||||
easing.type: Easing.InOutQuad
|
||||
}
|
||||
NumberAnimation {
|
||||
OpacityAnimator {
|
||||
target: scanningIcon
|
||||
property: "opacity"
|
||||
to: 1.0
|
||||
duration: 400
|
||||
easing.type: Easing.InOutQuad
|
||||
@@ -1087,14 +1081,14 @@ Item {
|
||||
|
||||
let sorted = [...networks];
|
||||
sorted.sort((a, b) => {
|
||||
const aPinnedIndex = pinnedList.indexOf(a.ssid)
|
||||
const bPinnedIndex = pinnedList.indexOf(b.ssid)
|
||||
const aPinnedIndex = pinnedList.indexOf(a.ssid);
|
||||
const bPinnedIndex = pinnedList.indexOf(b.ssid);
|
||||
if (aPinnedIndex !== -1 || bPinnedIndex !== -1) {
|
||||
if (aPinnedIndex === -1)
|
||||
return 1
|
||||
return 1;
|
||||
if (bPinnedIndex === -1)
|
||||
return -1
|
||||
return aPinnedIndex - bPinnedIndex
|
||||
return -1;
|
||||
return aPinnedIndex - bPinnedIndex;
|
||||
}
|
||||
if (a.ssid === ssid)
|
||||
return -1;
|
||||
@@ -1297,7 +1291,7 @@ Item {
|
||||
buttonSize: 28
|
||||
iconColor: isPinned ? Theme.primary : Theme.surfaceVariantText
|
||||
onClicked: {
|
||||
networkTab.toggleWifiPin(modelData.ssid)
|
||||
networkTab.toggleWifiPin(modelData.ssid);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1375,16 +1369,14 @@ Item {
|
||||
SequentialAnimation {
|
||||
running: NetworkService.networkInfoLoading
|
||||
loops: Animation.Infinite
|
||||
NumberAnimation {
|
||||
OpacityAnimator {
|
||||
target: wifiInfoLoadIcon
|
||||
property: "opacity"
|
||||
to: 0.3
|
||||
duration: 400
|
||||
easing.type: Easing.InOutQuad
|
||||
}
|
||||
NumberAnimation {
|
||||
OpacityAnimator {
|
||||
target: wifiInfoLoadIcon
|
||||
property: "opacity"
|
||||
to: 1.0
|
||||
duration: 400
|
||||
easing.type: Easing.InOutQuad
|
||||
@@ -1866,16 +1858,14 @@ Item {
|
||||
SequentialAnimation {
|
||||
running: VPNService.configLoading
|
||||
loops: Animation.Infinite
|
||||
NumberAnimation {
|
||||
OpacityAnimator {
|
||||
target: vpnLoadIcon
|
||||
property: "opacity"
|
||||
to: 0.3
|
||||
duration: 400
|
||||
easing.type: Easing.InOutQuad
|
||||
}
|
||||
NumberAnimation {
|
||||
OpacityAnimator {
|
||||
target: vpnLoadIcon
|
||||
property: "opacity"
|
||||
to: 1.0
|
||||
duration: 400
|
||||
easing.type: Easing.InOutQuad
|
||||
@@ -1984,7 +1974,9 @@ Item {
|
||||
checked: configData ? (configData.autoconnect || false) : false
|
||||
visible: !VPNService.configLoading && configData !== null
|
||||
onToggled: checked => {
|
||||
VPNService.updateConfig(modelData.uuid, {autoconnect: checked});
|
||||
VPNService.updateConfig(modelData.uuid, {
|
||||
autoconnect: checked
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user