refactor: lock weather into new file

This commit is contained in:
2 * r + 2 * t 2026-06-01 22:37:12 +10:00
parent 9665613ef1
commit 18af8ab4ac
2 changed files with 61 additions and 53 deletions

View file

@ -1,7 +1,5 @@
pragma ComponentBehavior: Bound
import "weather"
import QtQuick
import QtQuick.Layouts
import Caelestia.Config
import qs.components
import qs.services
@ -23,58 +21,9 @@ StyledRect {
onTriggered: Weather.reload()
}
ColumnLayout {
BriefInfo {
id: layout
anchors.centerIn: parent
spacing: Tokens.spacing.extraSmall
StyledText {
Layout.alignment: Qt.AlignHCenter
animate: true
text: Weather.description
color: Colours.palette.m3onSurfaceVariant
font: Tokens.font.body.large
}
RowLayout {
Layout.alignment: Qt.AlignHCenter
spacing: Tokens.spacing.medium
StyledText {
id: temp
animate: true
text: Weather.temp
color: Colours.palette.m3primary
font: Tokens.font.headline.builders.large.scale(1.5).weight(Font.DemiBold).width(80).build()
}
MaterialIcon {
animate: true
text: Weather.icon
color: Colours.palette.m3tertiary
fontStyle: Tokens.font.headline.builders.large.scale(1.5).build()
}
}
StyledText {
Layout.alignment: Qt.AlignHCenter
animate: true
text: qsTr("Feels like %1").arg(Weather.temp)
color: Colours.palette.m3onSurfaceVariant
font: Tokens.font.body.large
}
StyledText {
Layout.alignment: Qt.AlignHCenter
animate: true
text: {
const today = Weather.forecast[0];
return qsTr("High %1 • Low %2").arg(Weather.formatTemp(today?.maxTempC)).arg(Weather.formatTemp(today?.minTempC));
}
color: Colours.palette.m3onSurfaceVariant
font: Tokens.font.body.medium
}
}
}

View file

@ -0,0 +1,59 @@
import QtQuick
import QtQuick.Layouts
import Caelestia.Config
import qs.components
import qs.services
ColumnLayout {
id: root
spacing: Tokens.spacing.extraSmall
StyledText {
Layout.alignment: Qt.AlignHCenter
animate: true
text: Weather.description
color: Colours.palette.m3onSurfaceVariant
font: Tokens.font.body.large
}
RowLayout {
Layout.alignment: Qt.AlignHCenter
spacing: Tokens.spacing.medium
StyledText {
id: temp
animate: true
text: Weather.temp
color: Colours.palette.m3primary
font: Tokens.font.headline.builders.large.scale(1.5).weight(Font.DemiBold).width(80).build()
}
MaterialIcon {
animate: true
text: Weather.icon
color: Colours.palette.m3secondary
fontStyle: Tokens.font.headline.builders.large.scale(1.5).build()
}
}
StyledText {
Layout.alignment: Qt.AlignHCenter
animate: true
text: qsTr("Feels like %1").arg(Weather.temp)
color: Colours.palette.m3onSurfaceVariant
font: Tokens.font.body.large
}
StyledText {
Layout.alignment: Qt.AlignHCenter
animate: true
text: {
const today = Weather.forecast[0];
return qsTr("High %1 • Low %2").arg(Weather.formatTemp(today?.maxTempC)).arg(Weather.formatTemp(today?.minTempC));
}
color: Colours.palette.m3onSurfaceVariant
font: Tokens.font.body.medium
}
}