1786899520
This commit is contained in:
@@ -5,22 +5,22 @@ use tokio::{sync::mpsc::UnboundedSender, time::sleep};
|
|||||||
|
|
||||||
use crate::{error::AppError, messages::EventMessage};
|
use crate::{error::AppError, messages::EventMessage};
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug)]
|
// #[derive(Copy, Clone, Debug)]
|
||||||
pub struct BatteryData {
|
// pub struct BatteryData {
|
||||||
state_of_health: Ratio,
|
// state_of_health: Ratio,
|
||||||
state_of_charge: Ratio,
|
// state_of_charge: Ratio,
|
||||||
energy: Energy,
|
// energy: Energy,
|
||||||
energy_full: Energy,
|
// energy_full: Energy,
|
||||||
energy_full_design: Energy,
|
// energy_full_design: Energy,
|
||||||
energy_rate: Power,
|
// energy_rate: Power,
|
||||||
state: State,
|
// state: State,
|
||||||
voltage: ElectricPotential,
|
// voltage: ElectricPotential,
|
||||||
temperature: Option<ThermodynamicTemperature>,
|
// temperature: Option<ThermodynamicTemperature>,
|
||||||
technology: Technology,
|
// technology: Technology,
|
||||||
cycle_count: Option<u32>,
|
// cycle_count: Option<u32>,
|
||||||
time_to_full: Option<Time>,
|
// time_to_full: Option<Time>,
|
||||||
time_to_empty: Option<Time>,
|
// time_to_empty: Option<Time>,
|
||||||
}
|
// }
|
||||||
|
|
||||||
impl From<&Battery> for BatteryData {
|
impl From<&Battery> for BatteryData {
|
||||||
fn from(value: &Battery) -> Self {
|
fn from(value: &Battery) -> Self {
|
||||||
|
|||||||
@@ -49,6 +49,11 @@ export struct DateTimeData {
|
|||||||
time: string,
|
time: string,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export struct BatteryData {
|
||||||
|
state: string,
|
||||||
|
percent: string,
|
||||||
|
}
|
||||||
|
|
||||||
component Clock {
|
component Clock {
|
||||||
in property <DateTimeData> date-time;
|
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 {
|
component Thermometer inherits Rectangle {
|
||||||
in property <ThermometerData> thermometer;
|
in property <ThermometerData> thermometer;
|
||||||
border-radius: 16px + 19px;
|
border-radius: 16px + 19px;
|
||||||
@@ -135,6 +165,7 @@ export component AppWindow inherits Window {
|
|||||||
|
|
||||||
in-out property <ColorScheme> color-scheme <=> Palette.color-scheme;
|
in-out property <ColorScheme> color-scheme <=> Palette.color-scheme;
|
||||||
|
|
||||||
|
in property <BatteryData> battery;
|
||||||
in property <DateTimeData> date-time;
|
in property <DateTimeData> date-time;
|
||||||
in property <[ThermostatData]> thermostats;
|
in property <[ThermostatData]> thermostats;
|
||||||
in property <WeatherData> weather;
|
in property <WeatherData> weather;
|
||||||
@@ -163,6 +194,10 @@ export component AppWindow inherits Window {
|
|||||||
spacing: 15px;
|
spacing: 15px;
|
||||||
padding: StyleMetrics.layout-padding / 2;
|
padding: StyleMetrics.layout-padding / 2;
|
||||||
|
|
||||||
|
Battery {
|
||||||
|
battery: battery;
|
||||||
|
}
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
preferred-width: parent.width;
|
preferred-width: parent.width;
|
||||||
height: parent.height;
|
height: parent.height;
|
||||||
|
|||||||
Reference in New Issue
Block a user