Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions src/components/event_card.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
use hex_color::HexColor;
use iced::{
Background, Border, Color, Element, Length, Theme,
widget::{column, container, text},
};
use std::str::FromStr;

use crate::theme::AshellTheme;

pub fn event_card<'a, Message: 'a>(
theme: &'a AshellTheme,
title: impl Into<String>,
time_range: impl Into<String>,
color: Option<String>,
opacity: f32,
past: bool,
) -> Element<'a, Message> {
let background = color
.as_deref()
.and_then(|color| HexColor::from_str(color).ok())
.map(|color| Color::from_rgb8(color.r, color.g, color.b))
.unwrap_or_else(|| theme.iced_theme.extended_palette().background.weak.color);
let card_opacity = if past { opacity * 0.35 } else { opacity };

container(
column!(
text(title.into()).size(theme.font_size.sm),
text(time_range.into()).size(theme.font_size.xs),
)
.spacing(theme.space.xxs),
)
.padding(theme.space.sm)
.width(Length::Fill)
.style(move |_theme: &Theme| iced::widget::container::Style {
background: Background::Color(background.scale_alpha(card_opacity)).into(),
border: Border::default().rounded(theme.radius.sm),
..Default::default()
})
.into()
}
2 changes: 2 additions & 0 deletions src/components/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
pub mod button;
mod centerbox;
mod event_card;
mod format_indicator;
pub mod icons;
pub mod menu;
Expand All @@ -14,6 +15,7 @@ mod sub_menu_wrapper;

pub use button::*;
pub use centerbox::*;
pub use event_card::*;
pub use format_indicator::*;
pub use menu::MenuSize;
pub use menu_wrapper::*;
Expand Down
30 changes: 30 additions & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -450,11 +450,39 @@ pub struct TempoModuleConfig {
pub timezones: Vec<String>,
#[serde(default)]
pub weather_location: Option<WeatherLocation>,
#[serde(default)]
pub calendar_type: TempoCalendarType,
#[serde(default)]
pub calendars: Vec<TempoCalendarSource>,
pub weather_indicator: WeatherIndicator,
#[serde(deserialize_with = "deserialize_locale")]
pub locale: Locale,
}

#[derive(Deserialize, Default, Clone, Debug, PartialEq, Eq)]
pub enum TempoCalendarType {
#[default]
Calendar,
Events,
}

#[derive(Deserialize, Clone, Debug, PartialEq, Eq, Hash)]
#[serde(untagged)]
pub enum TempoCalendarSource {
Url {
#[serde(rename = "Url")]
url: String,
#[serde(rename = "Color")]
color: String,
},
Path {
#[serde(rename = "Path")]
path: String,
#[serde(rename = "Color")]
color: String,
},
}

#[derive(Deserialize, Default, Clone, Debug, PartialEq, Eq)]
pub enum WeatherIndicator {
#[default]
Expand Down Expand Up @@ -492,6 +520,8 @@ impl Default for TempoModuleConfig {
formats: vec![],
timezones: vec![],
weather_location: None,
calendar_type: TempoCalendarType::Calendar,
calendars: vec![],
weather_indicator: WeatherIndicator::IconAndTemperature,
locale: Locale::en_US,
}
Expand Down
Loading
Loading