From 1eaa7746fff026c849815626e3b4d389e3f22988 Mon Sep 17 00:00:00 2001 From: Savanni D'Gerinel Date: Wed, 9 Aug 2023 14:02:20 -0400 Subject: [PATCH] Add equinox/solstice information --- dashboard/src/app_window.rs | 18 ++++++++++++++++-- dashboard/src/main.rs | 6 ++++-- dashboard/src/types.rs | 3 ++- 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/dashboard/src/app_window.rs b/dashboard/src/app_window.rs index dbe9979..66c5dc1 100644 --- a/dashboard/src/app_window.rs +++ b/dashboard/src/app_window.rs @@ -8,14 +8,13 @@ use gtk::prelude::*; pub struct ApplicationWindow { pub window: gtk::ApplicationWindow, pub date_label: Date, + pub next_event: gtk::Label, pub transit_clock: TransitClock, } impl ApplicationWindow { pub fn new(app: >k::Application) -> Self { let window = gtk::ApplicationWindow::new(app); - let date_label = Date::new(); - let transit_clock = TransitClock::new(); let layout = gtk::Box::builder() .orientation(gtk::Orientation::Vertical) @@ -23,7 +22,20 @@ impl ApplicationWindow { .vexpand(true) .build(); + let date_label = Date::new(); layout.append(&date_label); + + let next_event = gtk::Label::builder() + .margin_bottom(8) + .margin_top(8) + .margin_start(8) + .margin_end(8) + .build(); + next_event.add_css_class("card"); + next_event.add_css_class("activatable"); + layout.append(&next_event); + + let transit_clock = TransitClock::new(); layout.append(&transit_clock); window.set_child(Some(&layout)); @@ -31,12 +43,14 @@ impl ApplicationWindow { Self { window, date_label, + next_event, transit_clock, } } pub fn update_state(&self, state: State) { self.date_label.update_date(state.date); + self.next_event.set_text(&format!("{:?}", state.next_event)); if let Some(transit) = state.transit { self.transit_clock.update_transit(transit); } diff --git a/dashboard/src/main.rs b/dashboard/src/main.rs index 7b5ebd6..c2724e8 100644 --- a/dashboard/src/main.rs +++ b/dashboard/src/main.rs @@ -1,4 +1,4 @@ -use chrono::{Datelike, Local}; +use chrono::{Datelike, Local, Utc}; use geo_types::{Latitude, Longitude}; use glib::Sender; use gtk::{prelude::*, subclass::prelude::*, Orientation}; @@ -99,8 +99,10 @@ pub fn main() { .request(latitude, longitude, Local::now()) .await; + let now = Local::now(); let state = State { - date: IFC::from(Local::now().date_naive().with_year(12023).unwrap()), + date: IFC::from(now.date_naive().with_year(12023).unwrap()), + next_event: EVENTS.next_event(now.with_timezone(&Utc)).unwrap(), transit: Some(transit), }; loop { diff --git a/dashboard/src/types.rs b/dashboard/src/types.rs index d82f9e6..045d448 100644 --- a/dashboard/src/types.rs +++ b/dashboard/src/types.rs @@ -1,8 +1,9 @@ -use crate::soluna_client::SunMoon; +use crate::{solstices::Event, soluna_client::SunMoon}; use ifc::IFC; #[derive(Clone, Debug)] pub struct State { pub date: IFC, + pub next_event: Event, pub transit: Option, }