import Quickshell
import QtQuick
import QtQuick.Layouts
import "../shared" as Shared

BarPill {
    id: root
    groupName: "weather"

    // Color follows condition severity: calm = info cyan, warning conditions
    // = amber, severe (thunder/blizzard/torrential) = danger red. error/stale
    // override to muted/amber respectively.
    readonly property color severityColor: Shared.Weather.status === "error" ? Shared.Theme.overlay0
        : Shared.Weather.status === "stale" ? Shared.Theme.warning
        : Shared.Weather.severity === "danger" ? Shared.Theme.danger
        : Shared.Weather.severity === "warning" ? Shared.Theme.warning
        : Shared.Theme.sky

    accentColor: root.severityColor

    content: [
        Text {
            Layout.alignment: Qt.AlignHCenter
            text: Shared.Weather.status === "error" ? "\u{f0599}" : Shared.Weather.icon
            color: root.severityColor
            font.pixelSize: Shared.Theme.fontLarge
            font.family: Shared.Theme.iconFont
        },
        Text {
            Layout.alignment: Qt.AlignHCenter
            text: Shared.Weather.status === "error" ? "N/A"
                : Shared.Weather.status === "loading" ? "…"
                : Shared.Weather.temp
            color: root.severityColor
            font.pixelSize: Shared.Theme.fontSmall
            font.family: Shared.Theme.fontFamily
            font.bold: true
        }
    ]
}
