From b4dfef1d6de0245029ad725ac6a5af7fa5fb75f3 Mon Sep 17 00:00:00 2001 From: Schrottkatze Date: Wed, 11 Sep 2024 02:09:08 +0200 Subject: [PATCH] traveldings stuff! --- .../eww/configDir/bottomBar/bottomBar.yuck | 3 +- .../eww/configDir/bottomBar/traveldings.yuck | 50 +++++++++++++++++++ .../home/panels/eww/configDir/eww.css | 17 +++++++ .../src/commands/current_journey.rs | 2 + programs/traveldings/src/traewelling/model.rs | 25 +++++++--- 5 files changed, 89 insertions(+), 8 deletions(-) create mode 100644 modules/desktop-environment/home/panels/eww/configDir/bottomBar/traveldings.yuck diff --git a/modules/desktop-environment/home/panels/eww/configDir/bottomBar/bottomBar.yuck b/modules/desktop-environment/home/panels/eww/configDir/bottomBar/bottomBar.yuck index f3bbb94..2034740 100644 --- a/modules/desktop-environment/home/panels/eww/configDir/bottomBar/bottomBar.yuck +++ b/modules/desktop-environment/home/panels/eww/configDir/bottomBar/bottomBar.yuck @@ -1,4 +1,5 @@ (include "bottomBar/workspaces.yuck") +(include "bottomBar/traveldings.yuck") (defwindow bottomBar :monitor 0 @@ -21,7 +22,7 @@ ) (box :halign "center" - (label :text "mid") + (traveldings) ) (box :halign "end" diff --git a/modules/desktop-environment/home/panels/eww/configDir/bottomBar/traveldings.yuck b/modules/desktop-environment/home/panels/eww/configDir/bottomBar/traveldings.yuck new file mode 100644 index 0000000..0e13b28 --- /dev/null +++ b/modules/desktop-environment/home/panels/eww/configDir/bottomBar/traveldings.yuck @@ -0,0 +1,50 @@ +(defwidget traveldings [] + (revealer + :class "traveldings" + :transition "crossfade" + :reveal { traveldings_data != "null" } + (traveldingsBarWidget) + ) +) + +(defwidget traveldingsBarWidget [] + (overlay + (box + :width 640 + (label + :halign "start" + :text "${traveldings_data.line} -> ${strlength(traveldings_data.arrival_station) > 24 ? "${substring(traveldings_data.arrival_station, 0, 24)}…" : traveldings_data.arrival_station}${traveldings_data.arrival_platform_data_available ? " (Gl. ${traveldings_data.arrival_platform_real})" : ""}" + ) + (label + :halign "end" + :text { traveldings_data.time_left >= 3600 ? formattime(traveldings_data.time_left, "noch %-Hh %-Mmin", "Etc/UTC") : formattime(traveldings_data.time_left, "noch %-Mmin", "Etc/UTC") } + ) + ) + (box + (progress + :value {traveldings_data.progress * 100} + :orientation "horizontal" + ) + ) + ) +) + +(defwindow traveldingsWindow + :monitor 0 + :stacking "overlay" + :exclusive "false" + :geometry (geometry + :x "0%" + :y "6.6%" + :width "30%" + :height "20%" + :anchor "bottom center") + (box + :class "traveldingsWindow" + (label :text "TODO")) +) + +(deflisten traveldings_data + :initial "null" + "traveldings current" +) diff --git a/modules/desktop-environment/home/panels/eww/configDir/eww.css b/modules/desktop-environment/home/panels/eww/configDir/eww.css index 848f77a..f512917 100644 --- a/modules/desktop-environment/home/panels/eww/configDir/eww.css +++ b/modules/desktop-environment/home/panels/eww/configDir/eww.css @@ -13,4 +13,21 @@ label { .workspaces button.focused { background-color: #504935; +} + +.traveldings progressbar trough { + border: none; + background-color: #3c3836; + border-bottom-right-radius: 0; + border-bottom-left-radius: 0; +} + +.traveldings progressbar progress { + background-color: #79740e; + border-bottom-left-radius: 0; +} + + +.traveldingsWindow { + border-radius: 15px; } \ No newline at end of file diff --git a/programs/traveldings/src/commands/current_journey.rs b/programs/traveldings/src/commands/current_journey.rs index c7a8792..b0864bf 100644 --- a/programs/traveldings/src/commands/current_journey.rs +++ b/programs/traveldings/src/commands/current_journey.rs @@ -68,6 +68,7 @@ struct CurrentJourneyOutput { progress: Option, time_left: Option, icon: String, + line: String, // Invalid data received? departure_err: bool, @@ -148,6 +149,7 @@ impl CurrentJourneyOutput { progress, time_left, icon, + line: checkin.train.line_name.clone(), departure_err, departure_planned, departure_real, diff --git a/programs/traveldings/src/traewelling/model.rs b/programs/traveldings/src/traewelling/model.rs index 4b54c7b..090d36f 100644 --- a/programs/traveldings/src/traewelling/model.rs +++ b/programs/traveldings/src/traewelling/model.rs @@ -36,6 +36,8 @@ pub struct StopOverResource { pub platform: Option, pub departure_platform_planned: Option, pub departure_platform_real: Option, + pub arrival_platform_planned: Option, + pub arrival_platform_real: Option, } // ???? @@ -57,9 +59,19 @@ pub enum StopJourneyPart { } impl StopOverResource { pub fn get_time_data(&self, journey_part: StopJourneyPart) -> JsonableData { - let (time_planned, time_real) = match journey_part { - StopJourneyPart::Origin => (self.departure_planned, self.departure_real), - StopJourneyPart::Destination => (self.arrival_planned, self.arrival_real), + let (time_planned, time_real, platform_planned, platform_real) = match journey_part { + StopJourneyPart::Origin => ( + self.departure_planned, + self.departure_real, + self.departure_platform_planned.clone(), + self.departure_platform_real.clone(), + ), + StopJourneyPart::Destination => ( + self.arrival_planned, + self.arrival_real, + self.arrival_platform_planned.clone(), + self.arrival_platform_real.clone(), + ), }; let time_err = time_planned == None; @@ -70,10 +82,9 @@ impl StopOverResource { time_real: time_real.map(|ts| ts.timestamp()), station: self.name.clone(), ril100: self.ril_identifier.clone(), - platform_data_available: self.departure_platform_planned.is_none() - || self.departure_platform_real.is_none(), - platform_planned: self.departure_platform_planned.clone(), - platform_real: self.departure_platform_real.clone(), + platform_data_available: platform_planned.is_some() || platform_real.is_some(), + platform_planned, + platform_real, } } }