1786306057
This commit is contained in:
@@ -102,7 +102,22 @@ pub fn apply_calendars(app: &Weak<AppWindow>, entities: Vec<CalendarEvent>) {
|
|||||||
let mut entities = entities.clone();
|
let mut entities = entities.clone();
|
||||||
entities.sort_by_key(|a| a.sort_epoch);
|
entities.sort_by_key(|a| a.sort_epoch);
|
||||||
|
|
||||||
let entities = entities.iter().map(Into::into).collect::<Vec<_>>();
|
let entities: Vec<CalendarEventData> = entities.iter().map(Into::into).collect::<Vec<_>>();
|
||||||
|
|
||||||
|
if let Some(event) = &entities.first() {
|
||||||
|
app.set_next_event_date(slint::format!(
|
||||||
|
"NEXT / {} / {}",
|
||||||
|
event.date.to_uppercase(),
|
||||||
|
event.calendar.to_uppercase()
|
||||||
|
));
|
||||||
|
app.set_next_event_time(event.time.clone());
|
||||||
|
app.set_next_event_summary(event.summary.clone());
|
||||||
|
} else {
|
||||||
|
app.set_next_event_date("NEXT EVENT".into());
|
||||||
|
app.set_next_event_time("".into());
|
||||||
|
app.set_next_event_summary("NO UPCOMING EVENTS".into());
|
||||||
|
}
|
||||||
|
|
||||||
app.set_calendar_events(ModelRc::new(VecModel::<CalendarEventData>::from(entities)));
|
app.set_calendar_events(ModelRc::new(VecModel::<CalendarEventData>::from(entities)));
|
||||||
}) {
|
}) {
|
||||||
eprintln!("Failed to upgrade in event loop.\n\t{:?}", err);
|
eprintln!("Failed to upgrade in event loop.\n\t{:?}", err);
|
||||||
|
|||||||
@@ -27,12 +27,23 @@ export component Calendar inherits Rectangle {
|
|||||||
text: event.date;
|
text: event.date;
|
||||||
supporting-text: event.summary;
|
supporting-text: event.summary;
|
||||||
height: 72px;
|
height: 72px;
|
||||||
|
VerticalLayout {
|
||||||
|
alignment: center;
|
||||||
|
horizontal_stretch: 1;
|
||||||
|
MaterialText {
|
||||||
|
text: event.time;
|
||||||
|
horizontal-alignment: right;
|
||||||
|
color: MaterialPalette.on_surface;
|
||||||
|
overflow: elide;
|
||||||
|
style: MaterialTypography.title_medium;
|
||||||
|
}
|
||||||
|
|
||||||
MaterialText {
|
MaterialText {
|
||||||
text: event.time;
|
text: "";
|
||||||
color: MaterialPalette.on_surface;
|
horizontal-alignment: right;
|
||||||
overflow: elide;
|
overflow: elide;
|
||||||
style: MaterialTypography.title_medium;
|
style: MaterialTypography.body_medium;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,9 @@ import {
|
|||||||
SegmentedButton,
|
SegmentedButton,
|
||||||
MaterialPalette,
|
MaterialPalette,
|
||||||
FilledButton,
|
FilledButton,
|
||||||
|
MaterialText,
|
||||||
|
MaterialTypography,
|
||||||
|
MaterialStyleMetrics,
|
||||||
} from "material/material.slint";
|
} from "material/material.slint";
|
||||||
|
|
||||||
export struct WeatherData {
|
export struct WeatherData {
|
||||||
@@ -33,6 +36,10 @@ export component Climate inherits Rectangle {
|
|||||||
in property <[ThermostatData]> thermostats;
|
in property <[ThermostatData]> thermostats;
|
||||||
in property <bool> is-night;
|
in property <bool> is-night;
|
||||||
|
|
||||||
|
in property <string> next-event-date;
|
||||||
|
in property <string> next-event-time;
|
||||||
|
in property <string> next-event-summary;
|
||||||
|
|
||||||
property <int> icon-index: weather.icon-index == 1 && is-night ? 2 : weather.icon-index;
|
property <int> icon-index: weather.icon-index == 1 && is-night ? 2 : weather.icon-index;
|
||||||
|
|
||||||
callback set_temperature(string, float);
|
callback set_temperature(string, float);
|
||||||
@@ -53,7 +60,34 @@ export component Climate inherits Rectangle {
|
|||||||
|
|
||||||
VerticalLayout {
|
VerticalLayout {
|
||||||
HorizontalLayout {
|
HorizontalLayout {
|
||||||
Rectangle { }
|
Vertical {
|
||||||
|
ListTile {
|
||||||
|
avatar_icon: Icons.event_upcoming;
|
||||||
|
avatar_foreground: Palette.foreground;
|
||||||
|
text: next-event-date;
|
||||||
|
supporting-text: next-event-summary;
|
||||||
|
height: 72px;
|
||||||
|
enabled: false;
|
||||||
|
VerticalLayout {
|
||||||
|
alignment: center;
|
||||||
|
horizontal_stretch: 1;
|
||||||
|
MaterialText {
|
||||||
|
text: next-event-time;
|
||||||
|
color: MaterialPalette.on_surface;
|
||||||
|
overflow: elide;
|
||||||
|
horizontal-alignment: right;
|
||||||
|
style: MaterialTypography.title_medium;
|
||||||
|
}
|
||||||
|
|
||||||
|
MaterialText {
|
||||||
|
text: "";
|
||||||
|
overflow: elide;
|
||||||
|
horizontal-alignment: right;
|
||||||
|
style: MaterialTypography.body_medium;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Vertical {
|
Vertical {
|
||||||
Text {
|
Text {
|
||||||
|
|||||||
@@ -131,10 +131,14 @@ export component AppWindow inherits Window {
|
|||||||
in property <[ThermostatData]> thermostats;
|
in property <[ThermostatData]> thermostats;
|
||||||
in property <WeatherData> weather;
|
in property <WeatherData> weather;
|
||||||
in property <bool> is-night;
|
in property <bool> is-night;
|
||||||
|
|
||||||
callback set_temperature(string, float);
|
callback set_temperature(string, float);
|
||||||
callback toggle_thermostat(string);
|
callback toggle_thermostat(string);
|
||||||
|
|
||||||
in property <[CalendarEventData]> calendar-events;
|
in property <[CalendarEventData]> calendar-events;
|
||||||
|
in property <string> next-event-date;
|
||||||
|
in property <string> next-event-time;
|
||||||
|
in property <string> next-event-summary;
|
||||||
|
|
||||||
in property <[ThermometerData]> thermometers;
|
in property <[ThermometerData]> thermometers;
|
||||||
|
|
||||||
@@ -175,6 +179,10 @@ export component AppWindow inherits Window {
|
|||||||
width: (root.width / 4) * 3;
|
width: (root.width / 4) * 3;
|
||||||
VerticalLayout {
|
VerticalLayout {
|
||||||
if tab-bar.current-index == 0: Climate {
|
if tab-bar.current-index == 0: Climate {
|
||||||
|
next-event-date: next-event-date;
|
||||||
|
next-event-time: next-event-time;
|
||||||
|
next-event-summary: next-event-summary;
|
||||||
|
|
||||||
thermostats: thermostats;
|
thermostats: thermostats;
|
||||||
is-night: is-night;
|
is-night: is-night;
|
||||||
weather: weather;
|
weather: weather;
|
||||||
|
|||||||
Reference in New Issue
Block a user