🏡 index : ~doyle/shalom.git

author Jordan Doyle <jordan@doyle.la> 2023-11-02 2:48:55.0 +00:00:00
committer Jordan Doyle <jordan@doyle.la> 2023-11-02 2:48:55.0 +00:00:00
commit
735d2ec4b8fc2ed4013933490a14fca7f009bb96 [patch]
tree
d6efaf01a96da2878b9205bbbd098745114a4929
parent
721146d45475861794d0d8171cdbaf514a26a83a
download
735d2ec4b8fc2ed4013933490a14fca7f009bb96.tar.gz

Use correct greetings



Diff

 shalom/src/pages/omni.rs            | 10 +++++++++-
 shalom/src/widgets/cards/weather.rs | 13 +++++++++----
 2 files changed, 18 insertions(+), 5 deletions(-)

diff --git a/shalom/src/pages/omni.rs b/shalom/src/pages/omni.rs
index ecd0641..24e9308 100644
--- a/shalom/src/pages/omni.rs
+++ b/shalom/src/pages/omni.rs
@@ -9,6 +9,7 @@ use iced::{
    Font, Renderer, Subscription,
};
use itertools::Itertools;
use time::OffsetDateTime;

use crate::{
    oracle::{Oracle, Weather},
@@ -48,7 +49,14 @@ impl Omni {
    }

    pub fn view(&self) -> Element<'_, Message, Renderer> {
        let greeting = text("Good Evening").size(60).font(Font {
        let greeting = match OffsetDateTime::now_utc().hour() {
            5..=11 => "Good morning!",
            12..=16 => "Good afternoon!",
            17..=23 | 0..=4 => "Good evening!",
            _ => "Hello!",
        };

        let greeting = text(greeting).size(60).font(Font {
            weight: Weight::Bold,
            stretch: Stretch::Condensed,
            ..Font::with_name("Helvetica Neue")
diff --git a/shalom/src/widgets/cards/weather.rs b/shalom/src/widgets/cards/weather.rs
index 8700f9b..6788754 100644
--- a/shalom/src/widgets/cards/weather.rs
+++ b/shalom/src/widgets/cards/weather.rs
@@ -14,6 +14,7 @@ use iced::{
    Alignment, Background, Color, Degrees, Element, Font, Gradient, Length, Rectangle, Renderer,
    Size, Theme,
};
use time::OffsetDateTime;

use crate::oracle::Weather;

@@ -21,7 +22,6 @@ use crate::oracle::Weather;
pub struct WeatherCard<M> {
    pub on_click: Option<M>,
    pub current_weather: Weather,
    pub day_time: bool,
}

impl<M> WeatherCard<M> {
@@ -29,7 +29,6 @@ impl<M> WeatherCard<M> {
        Self {
            current_weather,
            on_click: None,
            day_time: true,
        }
    }

@@ -111,7 +110,13 @@ impl<M: Clone> Widget<M, Renderer> for WeatherCard<M> {
        _cursor: Cursor,
        _viewport: &Rectangle,
    ) {
        let gradient = if self.day_time {
        // TODO: get sunrise/sunset from somewhere reasonable
        let day_time = match OffsetDateTime::now_utc().hour() {
            5..=19 => true,
            _ => false,
        };

        let gradient = if day_time {
            Linear::new(Degrees(90.))
                .add_stop(0.0, Color::from_rgba8(104, 146, 190, 1.0))
                .add_stop(1.0, Color::from_rgba8(10, 54, 120, 1.0))
@@ -149,7 +154,7 @@ impl<M: Clone> Widget<M, Renderer> for WeatherCard<M> {
        });

        let icon_bounds = children.next().unwrap().bounds();
        if let Some(icon) = self.current_weather.condition.icon(self.day_time) {
        if let Some(icon) = self.current_weather.condition.icon(day_time) {
            renderer.draw(icon.handle(), None, icon_bounds);
        }