extract loadColor gradient function into Theme service

This commit is contained in:
Damocles 2026-04-23 23:22:55 +02:00
parent 1db16b435c
commit 7d9800374f
5 changed files with 16 additions and 39 deletions

View file

@ -17,14 +17,6 @@ Column {
return bytes + "B";
}
function _barColor(pct) {
const t = Math.max(0, Math.min(100, pct)) / 100;
const a = t < 0.5 ? S.Theme.base0B : S.Theme.base0A;
const b = t < 0.5 ? S.Theme.base0A : S.Theme.base08;
const u = t < 0.5 ? t * 2 : (t - 0.5) * 2;
return Qt.rgba(a.r + (b.r - a.r) * u, a.g + (b.g - a.g) * u, a.b + (b.b - a.b) * u, 1);
}
Repeater {
model: root.mounts
@ -64,7 +56,7 @@ Column {
Rectangle {
width: parent.width * (modelData.pct / 100)
height: parent.height
color: root._barColor(modelData.pct)
color: S.Theme.loadColor(modelData.pct)
radius: 2
Behavior on width {
NumberAnimation {