fix warnings

Signed-off-by: Fabrizio Iannetti <fabrizio.iannetti@gmail.com>
This commit is contained in:
Fabrizio Iannetti 2024-03-17 17:04:23 +01:00
parent 3f3425563c
commit 7c624ff6ca
3 changed files with 5 additions and 17 deletions

View File

@ -32,7 +32,6 @@ use iced::{
Text, Text,
pick_list, pick_list,
}, },
theme,
}; };
#[cfg(feature = "tracing")] #[cfg(feature = "tracing")]

View File

@ -47,8 +47,6 @@ const MONTH_NAMES: [&str; 12] = [
"gen", "feb", "mar", "apr", "mag", "giu", "lug", "ago", "set", "ott", "nov", "dic", "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 // 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; const YEAR_VIEW_DAYS_PER_ROW: u32 = 5 * 7 + 2;
@ -310,7 +308,6 @@ pub struct CalendarView<'a> {
params: CalendarParams, params: CalendarParams,
mode: CalendarViewMode, mode: CalendarViewMode,
events: &'a EventsCollection, events: &'a EventsCollection,
week_column_width: f32,
row_name_font_size: f32, row_name_font_size: f32,
margin: f32, margin: f32,
} }
@ -327,7 +324,6 @@ impl<'a> CalendarView<'a> {
params: params.clone(), params: params.clone(),
mode, mode,
events, events,
week_column_width: 30.0,
row_name_font_size: 24.0, row_name_font_size: 24.0,
margin: 10.0, margin: 10.0,
} }
@ -351,8 +347,8 @@ impl<'a> CalendarView<'a> {
fn get_calendar_row(&self, day: NaiveDate, row: u32) -> CalendarRow { fn get_calendar_row(&self, day: NaiveDate, row: u32) -> CalendarRow {
match self.mode { match self.mode {
CalendarViewMode::Week => 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::weeks(row.into())), CalendarViewMode::Month => CalendarRow::for_week(day + Duration::try_weeks(row.into()).unwrap()),
CalendarViewMode::Year => CalendarRow::for_month(day + Months::new(row)), CalendarViewMode::Year => CalendarRow::for_month(day + Months::new(row)),
} }
} }
@ -560,7 +556,7 @@ impl<'a> CalendarView<'a> {
let diff = cell.x - row_bounds.x; let diff = cell.x - row_bounds.x;
row_bounds.x = cell.x; row_bounds.x = cell.x;
row_bounds.width -= diff; 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; row_bounds.width = cell.x - row_bounds.x + cell.width;
} }

View File

@ -19,13 +19,6 @@ impl RowDay {
RowDay::NotInRange(day) RowDay::NotInRange(day)
} }
} }
pub fn day(self) -> NaiveDate {
match self {
Self::InRange(day) => day,
Self::NotInRange(day) => day,
}
}
} }
/// A row in the calendar. /// A row in the calendar.
@ -47,7 +40,7 @@ impl CalendarRow {
let begin = day.week(Weekday::Mon).first_day(); let begin = day.week(Weekday::Mon).first_day();
CalendarRow { CalendarRow {
begin, 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 { pub fn date_for_col(self: &Self, col: i64) -> RowDay {
RowDay::new( RowDay::new(
self, self,
self.begin.week(Weekday::Mon).first_day() + Duration::days(col), self.begin.week(Weekday::Mon).first_day() + Duration::try_days(col).unwrap(),
) )
} }