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();
|
||||
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)));
|
||||
}) {
|
||||
eprintln!("Failed to upgrade in event loop.\n\t{:?}", err);
|
||||
|
||||
@@ -27,12 +27,23 @@ export component Calendar inherits Rectangle {
|
||||
text: event.date;
|
||||
supporting-text: event.summary;
|
||||
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 {
|
||||
text: event.time;
|
||||
color: MaterialPalette.on_surface;
|
||||
overflow: elide;
|
||||
style: MaterialTypography.title_medium;
|
||||
MaterialText {
|
||||
text: "";
|
||||
horizontal-alignment: right;
|
||||
overflow: elide;
|
||||
style: MaterialTypography.body_medium;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,9 @@ import {
|
||||
SegmentedButton,
|
||||
MaterialPalette,
|
||||
FilledButton,
|
||||
MaterialText,
|
||||
MaterialTypography,
|
||||
MaterialStyleMetrics,
|
||||
} from "material/material.slint";
|
||||
|
||||
export struct WeatherData {
|
||||
@@ -33,6 +36,10 @@ export component Climate inherits Rectangle {
|
||||
in property <[ThermostatData]> thermostats;
|
||||
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;
|
||||
|
||||
callback set_temperature(string, float);
|
||||
@@ -53,7 +60,34 @@ export component Climate inherits Rectangle {
|
||||
|
||||
VerticalLayout {
|
||||
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 {
|
||||
Text {
|
||||
|
||||
@@ -131,10 +131,14 @@ export component AppWindow inherits Window {
|
||||
in property <[ThermostatData]> thermostats;
|
||||
in property <WeatherData> weather;
|
||||
in property <bool> is-night;
|
||||
|
||||
callback set_temperature(string, float);
|
||||
callback toggle_thermostat(string);
|
||||
|
||||
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;
|
||||
|
||||
@@ -175,6 +179,10 @@ export component AppWindow inherits Window {
|
||||
width: (root.width / 4) * 3;
|
||||
VerticalLayout {
|
||||
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;
|
||||
is-night: is-night;
|
||||
weather: weather;
|
||||
|
||||
Reference in New Issue
Block a user