1786193359
This commit is contained in:
@@ -97,19 +97,17 @@ supported_features: int
|
|||||||
*/
|
*/
|
||||||
impl From<&HassEntity> for WeatherData {
|
impl From<&HassEntity> for WeatherData {
|
||||||
fn from(value: &HassEntity) -> Self {
|
fn from(value: &HassEntity) -> Self {
|
||||||
let kind = match value.state.as_str() {
|
let icon_index = match value.state.as_str() {
|
||||||
"sunny" => "sun",
|
"sunny" => 0,
|
||||||
"clear-night" => "moon",
|
"partlycloudy" => 1,
|
||||||
// "partlycloudy" if is_night => "cloud-moon",
|
"clear-night" => 9,
|
||||||
"partlycloudy" => "cloud-sun",
|
"rainy" => 4,
|
||||||
"rainy" => "cloud-rain",
|
"pouring" | "windy" | "windy-variant" => 5,
|
||||||
"pouring" | "windy" | "windy-variant" => "cloud-rain-wind",
|
"lightning" | "lightning-rainy" => 6,
|
||||||
"lightning" | "lightning-rainy" => "cloud-lightning",
|
"snowy" | "snowy-rainy" | "hail" => 7,
|
||||||
"snowy" | "snowy-rainy" | "hail" => "snowflake",
|
"fog" => 8,
|
||||||
"fog" => "cloud-fog",
|
_ => 3,
|
||||||
_ => "cloud",
|
};
|
||||||
}
|
|
||||||
.to_shared_string();
|
|
||||||
|
|
||||||
let label = pretty_label(&value.state).to_shared_string();
|
let label = pretty_label(&value.state).to_shared_string();
|
||||||
|
|
||||||
@@ -217,7 +215,7 @@ impl From<&HassEntity> for WeatherData {
|
|||||||
.to_shared_string();
|
.to_shared_string();
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
kind,
|
icon_index,
|
||||||
label,
|
label,
|
||||||
attribution,
|
attribution,
|
||||||
cloud_coverage,
|
cloud_coverage,
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ in property <string> : "cloud";
|
|||||||
|
|
||||||
import { Palette, HorizontalBox, VerticalBox } from "std-widgets.slint";
|
import { Palette, HorizontalBox, VerticalBox } from "std-widgets.slint";
|
||||||
export struct WeatherData {
|
export struct WeatherData {
|
||||||
kind: string,
|
icon-index: int,
|
||||||
label: string,
|
label: string,
|
||||||
temperature: float,
|
temperature: float,
|
||||||
dew_point: float,
|
dew_point: float,
|
||||||
@@ -31,10 +31,19 @@ export component Climate inherits Rectangle {
|
|||||||
in property <WeatherData> weather;
|
in property <WeatherData> weather;
|
||||||
in property <bool> is-night;
|
in property <bool> is-night;
|
||||||
|
|
||||||
|
property <int> icon-index: weather.icon-index == 1 && is-night ? 2 : weather.icon-index;
|
||||||
|
|
||||||
property <[image]> icons: [
|
property <[image]> icons: [
|
||||||
@image-url("icons/sun.svg"),
|
@image-url("icons/sun.svg"),
|
||||||
@image-url("icons/cloud-sun.svg"),
|
@image-url("icons/cloud-sun.svg"),
|
||||||
@image-url("icons/cloud-moon.svg")
|
@image-url("icons/cloud-moon.svg"),
|
||||||
|
@image-url("icons/cloud.svg"),
|
||||||
|
@image-url("icons/cloud-rain.svg"),
|
||||||
|
@image-url("icons/cloud-rain-wind.svg"),
|
||||||
|
@image-url("icons/cloud-lightning.svg"),
|
||||||
|
@image-url("icons/snowflake.svg"),
|
||||||
|
@image-url("icons/cloud-fog.svg"),
|
||||||
|
@image-url("icons/moon.svg"),
|
||||||
];
|
];
|
||||||
|
|
||||||
VerticalLayout {
|
VerticalLayout {
|
||||||
@@ -63,20 +72,11 @@ export component Climate inherits Rectangle {
|
|||||||
colorize: Palette.foreground;
|
colorize: Palette.foreground;
|
||||||
width: 120px;
|
width: 120px;
|
||||||
height: 105px;
|
height: 105px;
|
||||||
source: icons[0];
|
source: icons[icon-index];
|
||||||
image-fit: contain;
|
image-fit: contain;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Rectangle { }
|
Rectangle { }
|
||||||
}
|
}
|
||||||
|
|
||||||
// Text {
|
|
||||||
// width: 150px;
|
|
||||||
// height: 32px;
|
|
||||||
// text: weather.outside-high;
|
|
||||||
// font-size: 20px;
|
|
||||||
// font-weight: 700;
|
|
||||||
// vertical-alignment: center;
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user