From 7c624ff6ca800eb52ee2f8d4a9b3a95341ce492a Mon Sep 17 00:00:00 2001 From: Fabrizio Iannetti Date: Sun, 17 Mar 2024 17:04:23 +0100 Subject: [PATCH] fix warnings Signed-off-by: Fabrizio Iannetti --- src/main.rs | 1 - src/ui/calendar.rs | 10 +++------- src/ui/row.rs | 11 ++--------- 3 files changed, 5 insertions(+), 17 deletions(-) diff --git a/src/main.rs b/src/main.rs index 0a003df..097ce6e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -32,7 +32,6 @@ use iced::{ Text, pick_list, }, - theme, }; #[cfg(feature = "tracing")] diff --git a/src/ui/calendar.rs b/src/ui/calendar.rs index ae413dc..f6b8827 100644 --- a/src/ui/calendar.rs +++ b/src/ui/calendar.rs @@ -47,8 +47,6 @@ const MONTH_NAMES: [&str; 12] = [ "gen", "feb", "mar", "apr", "mag", "giu", "lug", "ago", "set", "ott", "nov", "dic", ]; -const DAY_NAMES: [&str; 7] = ["LUN", "MAR", "MER", "GIO", "VEN", "SAB", "DOM"]; - // 5 weeks plus two extra days is enough to accomodate the longest months of 31 days const YEAR_VIEW_DAYS_PER_ROW: u32 = 5 * 7 + 2; @@ -310,7 +308,6 @@ pub struct CalendarView<'a> { params: CalendarParams, mode: CalendarViewMode, events: &'a EventsCollection, - week_column_width: f32, row_name_font_size: f32, margin: f32, } @@ -327,7 +324,6 @@ impl<'a> CalendarView<'a> { params: params.clone(), mode, events, - week_column_width: 30.0, row_name_font_size: 24.0, margin: 10.0, } @@ -351,8 +347,8 @@ impl<'a> CalendarView<'a> { fn get_calendar_row(&self, day: NaiveDate, row: u32) -> CalendarRow { match self.mode { - CalendarViewMode::Week => CalendarRow::for_week(day + Duration::weeks(row.into())), - CalendarViewMode::Month => CalendarRow::for_week(day + Duration::weeks(row.into())), + CalendarViewMode::Week => CalendarRow::for_week(day + Duration::try_weeks(row.into()).unwrap()), + CalendarViewMode::Month => CalendarRow::for_week(day + Duration::try_weeks(row.into()).unwrap()), CalendarViewMode::Year => CalendarRow::for_month(day + Months::new(row)), } } @@ -560,7 +556,7 @@ impl<'a> CalendarView<'a> { let diff = cell.x - row_bounds.x; row_bounds.x = cell.x; row_bounds.width -= diff; - } else if current_day + Duration::days(1) == cal_row.end { + } else if current_day + Duration::try_days(1).unwrap() == cal_row.end { row_bounds.width = cell.x - row_bounds.x + cell.width; } diff --git a/src/ui/row.rs b/src/ui/row.rs index 329b1e3..9787ef3 100644 --- a/src/ui/row.rs +++ b/src/ui/row.rs @@ -19,13 +19,6 @@ impl RowDay { RowDay::NotInRange(day) } } - - pub fn day(self) -> NaiveDate { - match self { - Self::InRange(day) => day, - Self::NotInRange(day) => day, - } - } } /// A row in the calendar. @@ -47,7 +40,7 @@ impl CalendarRow { let begin = day.week(Weekday::Mon).first_day(); CalendarRow { begin, - end: begin + Duration::weeks(1), + end: begin + Duration::try_weeks(1).unwrap(), } } @@ -55,7 +48,7 @@ impl CalendarRow { pub fn date_for_col(self: &Self, col: i64) -> RowDay { RowDay::new( self, - self.begin.week(Weekday::Mon).first_day() + Duration::days(col), + self.begin.week(Weekday::Mon).first_day() + Duration::try_days(col).unwrap(), ) }