Use correct greetings
Diff
shalom/src/pages/omni.rs | 10 ++++++++++
shalom/src/widgets/cards/weather.rs | 13 +++++++++++--
2 files changed, 18 insertions(+), 5 deletions(-)
@@ -9,6 +9,7 @@
Font, Renderer, Subscription,
};
use itertools::Itertools;
use time::OffsetDateTime;
use crate::{
oracle::{Oracle, Weather},
@@ -48,7 +49,14 @@
}
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")
@@ -14,6 +14,7 @@
Alignment, Background, Color, Degrees, Element, Font, Gradient, Length, Rectangle, Renderer,
Size, Theme,
};
use time::OffsetDateTime;
use crate::oracle::Weather;
@@ -21,7 +22,6 @@
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 @@
Self {
current_weather,
on_click: None,
day_time: true,
}
}
@@ -111,7 +110,13 @@
_cursor: Cursor,
_viewport: &Rectangle,
) {
let gradient = if self.day_time {
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 @@
});
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);
}