1786899520

This commit is contained in:
2026-08-16 18:58:40 +02:00
parent 72ecdc932e
commit 9f8eb12051
2 changed files with 51 additions and 16 deletions

View File

@@ -5,22 +5,22 @@ use tokio::{sync::mpsc::UnboundedSender, time::sleep};
use crate::{error::AppError, messages::EventMessage};
#[derive(Copy, Clone, Debug)]
pub struct BatteryData {
state_of_health: Ratio,
state_of_charge: Ratio,
energy: Energy,
energy_full: Energy,
energy_full_design: Energy,
energy_rate: Power,
state: State,
voltage: ElectricPotential,
temperature: Option<ThermodynamicTemperature>,
technology: Technology,
cycle_count: Option<u32>,
time_to_full: Option<Time>,
time_to_empty: Option<Time>,
}
// #[derive(Copy, Clone, Debug)]
// pub struct BatteryData {
// state_of_health: Ratio,
// state_of_charge: Ratio,
// energy: Energy,
// energy_full: Energy,
// energy_full_design: Energy,
// energy_rate: Power,
// state: State,
// voltage: ElectricPotential,
// temperature: Option<ThermodynamicTemperature>,
// technology: Technology,
// cycle_count: Option<u32>,
// time_to_full: Option<Time>,
// time_to_empty: Option<Time>,
// }
impl From<&Battery> for BatteryData {
fn from(value: &Battery) -> Self {

View File

@@ -49,6 +49,11 @@ export struct DateTimeData {
time: string,
}
export struct BatteryData {
state: string,
percent: string,
}
component Clock {
in property <DateTimeData> date-time;
@@ -74,6 +79,31 @@ component Clock {
}
}
component Battery {
in property <BatteryData> battery;
VerticalLayout {
alignment: center;
padding-left: 5px;
padding-right: StyleMetrics.layout-padding;
Text {
text: battery.state;
height: 16px;
font-weight: 100;
horizontal-alignment: left;
}
Text {
text: battery.percent;
font-size: 19px;
height: 19px;
font-weight: 500;
horizontal-alignment: left;
}
}
}
component Thermometer inherits Rectangle {
in property <ThermometerData> thermometer;
border-radius: 16px + 19px;
@@ -135,6 +165,7 @@ export component AppWindow inherits Window {
in-out property <ColorScheme> color-scheme <=> Palette.color-scheme;
in property <BatteryData> battery;
in property <DateTimeData> date-time;
in property <[ThermostatData]> thermostats;
in property <WeatherData> weather;
@@ -163,6 +194,10 @@ export component AppWindow inherits Window {
spacing: 15px;
padding: StyleMetrics.layout-padding / 2;
Battery {
battery: battery;
}
Rectangle {
preferred-width: parent.width;
height: parent.height;