Compare commits
2 Commits
4f08088ee1
...
5a964fe11a
Author | SHA1 | Date | |
---|---|---|---|
|
5a964fe11a | ||
|
7a0f4111d3 |
10
src/app.rs
10
src/app.rs
@ -13,11 +13,11 @@ use crate::ui::{
|
|||||||
};
|
};
|
||||||
#[cfg(feature = "tracing")]
|
#[cfg(feature = "tracing")]
|
||||||
use crate::tracepoints;
|
use crate::tracepoints;
|
||||||
use chrono::{Datelike, NaiveDate, Months, Utc, Days};
|
use chrono::{NaiveDate, Months, Utc, Days};
|
||||||
use std::path;
|
use std::path;
|
||||||
use iced::{
|
use iced::{
|
||||||
Alignment,
|
Alignment,
|
||||||
Command,
|
Task,
|
||||||
Element,
|
Element,
|
||||||
Length,
|
Length,
|
||||||
widget::{
|
widget::{
|
||||||
@ -72,7 +72,7 @@ impl CalendarApp {
|
|||||||
app
|
app
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn update(&mut self, message: Message) -> Command<Message> {
|
pub fn update(&mut self, message: Message) -> Task<Message> {
|
||||||
match message {
|
match message {
|
||||||
Message::PrevWeek => {
|
Message::PrevWeek => {
|
||||||
self.view_date = self.view_date - Days::new(7);
|
self.view_date = self.view_date - Days::new(7);
|
||||||
@ -96,7 +96,7 @@ impl CalendarApp {
|
|||||||
self.controls.mode = Some(mode);
|
self.controls.mode = Some(mode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Command::none()
|
Task::none()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn view(&self) -> Element<Message> {
|
pub fn view(&self) -> Element<Message> {
|
||||||
@ -104,7 +104,7 @@ impl CalendarApp {
|
|||||||
tracepoints::calendar::view_entry();
|
tracepoints::calendar::view_entry();
|
||||||
let content = Column::new()
|
let content = Column::new()
|
||||||
.align_items(Alignment::Center)
|
.align_items(Alignment::Center)
|
||||||
.push(self.controls.view(self.view_date, self.view_date.year()))
|
.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))
|
||||||
;
|
;
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@ use crate::{
|
|||||||
ui::calendar::CalendarViewMode as ViewMode
|
ui::calendar::CalendarViewMode as ViewMode
|
||||||
};
|
};
|
||||||
use chrono::{
|
use chrono::{
|
||||||
|
Datelike,
|
||||||
NaiveDate,
|
NaiveDate,
|
||||||
Locale,
|
Locale,
|
||||||
};
|
};
|
||||||
@ -24,7 +25,7 @@ impl Default for Controls {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Controls {
|
impl Controls {
|
||||||
pub fn view<'a>(&'a self, view_date: NaiveDate, year: i32) -> Element<Message> {
|
pub fn view<'a>(&'a self, view_date: NaiveDate) -> Element<Message> {
|
||||||
let description = match self.mode {
|
let description = match self.mode {
|
||||||
Some(ViewMode::Month) => view_date.format_localized("%B", self.locale).to_string(),
|
Some(ViewMode::Month) => view_date.format_localized("%B", self.locale).to_string(),
|
||||||
Some(ViewMode::Week) => view_date.format_localized("%B", self.locale).to_string(),
|
Some(ViewMode::Week) => view_date.format_localized("%B", self.locale).to_string(),
|
||||||
@ -51,7 +52,7 @@ impl Controls {
|
|||||||
.size(24),
|
.size(24),
|
||||||
)
|
)
|
||||||
.push(
|
.push(
|
||||||
Text::new(year.to_string())
|
Text::new(view_date.year().to_string())
|
||||||
.width(Length::Fill)
|
.width(Length::Fill)
|
||||||
.horizontal_alignment(alignment::Horizontal::Right)
|
.horizontal_alignment(alignment::Horizontal::Right)
|
||||||
.size(40),
|
.size(40),
|
||||||
|
Loading…
Reference in New Issue
Block a user