diff --git a/src/ui/calendar.rs b/src/ui/calendar.rs index d6f94d5..5ede437 100644 --- a/src/ui/calendar.rs +++ b/src/ui/calendar.rs @@ -14,7 +14,7 @@ use iced_native::{Color, Element, Length, Point, Rectangle, Widget}; use iced_native::text; use iced_native::alignment; use iced_native::widget::Tree; -use chrono::{NaiveDate, Datelike, Duration, Weekday, Local}; +use chrono::{NaiveDate, Datelike, Duration, Local}; use super::basics::CellGrid; const MONTH_NAMES: [&str;12] = [ @@ -41,8 +41,8 @@ pub struct CalendarParams { show_weeks: bool, header_fg: Color, header_bg: Color, - day_text: Color, - day_text_other_month: Color, + day_fg: Color, + day_other_month_fg: Color, day_weekend_bg: Color, day_today_bg: Color, day_text_margin: f32, @@ -55,8 +55,8 @@ impl CalendarParams { header_fg: Color::BLACK, header_bg: Color::TRANSPARENT, day_today_bg: Color::from_rgb8(214, 242, 252), - day_text: Color::BLACK, - day_text_other_month: Color::from_rgb8(220, 220, 220), + day_fg: Color::BLACK, + day_other_month_fg: Color::from_rgb8(220, 220, 220), day_weekend_bg: Color::from_rgb8(245, 245, 245), day_text_margin: 5.0, } @@ -69,7 +69,6 @@ pub struct CalendarMonthView { first_day: NaiveDate, first_day_in_view: NaiveDate, params: CalendarParams, - weekday_on_first: Weekday, week_column_width: f32, week_column_font_size: f32, } @@ -93,7 +92,6 @@ impl CalendarMonthView { first_day, first_day_in_view, params: params.clone(), - weekday_on_first, week_column_width: 30.0, week_column_font_size: 18.0, } @@ -114,7 +112,6 @@ impl CalendarMonthView { let first_day_in_view = first_day - Duration::days(weekday_on_first.num_days_from_monday() as i64); self.first_day = first_day; - self.weekday_on_first = weekday_on_first; self.first_day_in_view = first_day_in_view; } @@ -202,7 +199,7 @@ impl CalendarMonthView { y: day_bounds.y, ..day_bounds }, - color: self.params.day_text, + color: self.params.day_fg, font: Default::default(), horizontal_alignment: alignment::Horizontal::Center, vertical_alignment: alignment::Vertical::Top, @@ -235,9 +232,9 @@ impl CalendarMonthView { // color of text let fg = if current_day.month() == self.first_day.month() { - self.params.day_text + self.params.day_fg } else { - self.params.day_text_other_month + self.params.day_other_month_fg }; // background color of the day cell @@ -257,7 +254,7 @@ impl CalendarMonthView { bounds: Rectangle {width: day_bounds.width + 0.5, height: day_bounds.height + 0.5, ..day_bounds}, border_radius: 0.0.into(), border_width: 1.0, - border_color: self.params.day_text_other_month, + border_color: self.params.day_other_month_fg, }, bg_color); @@ -357,7 +354,6 @@ pub struct CalendarYearView { first_day: NaiveDate, first_day_in_view: NaiveDate, params: CalendarParams, - weekday_on_first: Weekday, month_column_font_size: f32, margin: f32, } @@ -377,7 +373,6 @@ impl CalendarYearView { first_day, first_day_in_view, params: params.clone(), - weekday_on_first, month_column_font_size: 24.0, margin: 10.0 } @@ -388,10 +383,10 @@ impl CalendarYearView { self.first_day = NaiveDate::from_ymd(day.year(), 1, 1); // weekday on first day of the year - self.weekday_on_first = self.first_day.weekday(); + let weekday_on_first = self.first_day.weekday(); // first visible day in the view - self.first_day_in_view = self.first_day - Duration::days(self.weekday_on_first.num_days_from_monday() as i64); + self.first_day_in_view = self.first_day - Duration::days(weekday_on_first.num_days_from_monday() as i64); } fn draw_header( @@ -495,7 +490,7 @@ impl CalendarYearView { y: month_name_bounds.center_y(), ..month_name_bounds }, - color: self.params.day_text, + color: self.params.day_fg, font: Default::default(), horizontal_alignment: alignment::Horizontal::Left, vertical_alignment: alignment::Vertical::Center, @@ -535,7 +530,7 @@ impl CalendarYearView { let content = t.as_str(); // color of text - let fg = self.params.day_text; + let fg = self.params.day_fg; // background color of the day cell let bg_color = if current_day == Local::today().naive_local() { @@ -554,7 +549,7 @@ impl CalendarYearView { bounds: day_bounds, border_radius: 0.0.into(), border_width: 1.0, - border_color: self.params.day_text_other_month, + border_color: self.params.day_other_month_fg, }, bg_color);