extract loadColor gradient function into Theme service
This commit is contained in:
parent
1db16b435c
commit
7d9800374f
5 changed files with 16 additions and 39 deletions
|
|
@ -21,14 +21,6 @@ Column {
|
|||
}
|
||||
}
|
||||
|
||||
function _tempColor(celsius) {
|
||||
const t = Math.max(0, Math.min(100, celsius)) / 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);
|
||||
}
|
||||
|
||||
// Header - current temp
|
||||
Item {
|
||||
width: root.width
|
||||
|
|
@ -250,7 +242,7 @@ Column {
|
|||
anchors.rightMargin: 12
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
text: modelData.celsius + "\u00B0C"
|
||||
color: root._tempColor(modelData.celsius)
|
||||
color: S.Theme.loadColor(modelData.celsius)
|
||||
font.pixelSize: S.Theme.fontSize - 2
|
||||
font.family: S.Theme.fontFamily
|
||||
font.bold: _isActive
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue