adapt to latest iced (555ee3e9c66010c9a90c3ef55d61fbffd48e669d)

This commit is contained in:
Fabrizio Iannetti 2024-07-26 20:34:23 +02:00
parent cd9d710d14
commit e2fd0c4d08
3 changed files with 18 additions and 8 deletions

View File

@ -89,7 +89,7 @@ impl CalendarApp {
#[cfg(feature = "tracing")] #[cfg(feature = "tracing")]
tracepoints::calendar::view_entry(); tracepoints::calendar::view_entry();
let content = Column::new() let content = Column::new()
.align_items(Alignment::Center) .align_x(Alignment::Center)
.push(self.controls.view(self.view_date)) .push(self.controls.view(self.view_date))
.push(CalendarView::new(self.controls.mode.unwrap_or(ViewMode::Year), &CalendarParams::new(), self.view_date, &self.events)) .push(CalendarView::new(self.controls.mode.unwrap_or(ViewMode::Year), &CalendarParams::new(), self.view_date, &self.events))
; ;

View File

@ -3,7 +3,7 @@ mod app;
mod ui; mod ui;
mod model; mod model;
use app::{CalendarApp, Message}; use app::CalendarApp;
use iced::Task; use iced::Task;
use std::path; use std::path;
use clap::Parser; use clap::Parser;

View File

@ -7,7 +7,17 @@ use chrono::{
NaiveDate, NaiveDate,
Locale, Locale,
}; };
use iced::{Alignment, Background, Border, Element, Length, Theme, alignment, theme::palette, widget::{Button, Row, Text, button::{Status, Style, secondary}, row, text}}; use iced::{
Alignment,
Background,
Element,
Length,
Theme,
alignment,
theme::palette,
border,
widget::{Button, Row, Text, button::{Status, Style, secondary}, row, text}
};
//#[derive(Default)] //#[derive(Default)]
pub struct Controls { pub struct Controls {
@ -32,7 +42,7 @@ impl Controls {
_ => "".to_string() _ => "".to_string()
}; };
Row::new() Row::new()
.align_items(Alignment::Center) .align_y(Alignment::Center)
.padding(5) .padding(5)
.spacing(10) .spacing(10)
.push(row![ .push(row![
@ -48,13 +58,13 @@ impl Controls {
.push( .push(
Text::new(description) Text::new(description)
.width(Length::Fill) .width(Length::Fill)
.horizontal_alignment(alignment::Horizontal::Left) .align_x(alignment::Horizontal::Left)
.size(24), .size(24),
) )
.push( .push(
Text::new(view_date.year().to_string()) Text::new(view_date.year().to_string())
.width(Length::Fill) .width(Length::Fill)
.horizontal_alignment(alignment::Horizontal::Right) .align_x(alignment::Horizontal::Right)
.size(40), .size(40),
) )
.into() .into()
@ -77,7 +87,7 @@ impl Controls {
None => todo!(), None => todo!(),
} }
} }
fn get_mode_style(&self, view_mode: ViewMode) -> impl Fn(&Theme, Status) -> Style { fn get_mode_style(&self, view_mode: ViewMode) -> impl Fn(&Theme, Status) -> Style {
if let Some(current_view_mode) = self.mode { if let Some(current_view_mode) = self.mode {
if current_view_mode == view_mode { if current_view_mode == view_mode {
@ -96,7 +106,7 @@ fn styled(pair: palette::Pair) -> Style {
Style { Style {
background: Some(Background::Color(pair.color)), background: Some(Background::Color(pair.color)),
text_color: pair.text, text_color: pair.text,
border: Border::rounded(2), border: border::rounded(2),
..Style::default() ..Style::default()
} }
} }