feat(time): implement date selection
This commit is contained in:
parent
3e80dcdca8
commit
32b7012b79
1 changed files with 17 additions and 9 deletions
|
|
@ -119,6 +119,8 @@ impl cosmic::Application for Window {
|
||||||
if let Some(p) = self.popup.take() {
|
if let Some(p) = self.popup.take() {
|
||||||
destroy_popup(p)
|
destroy_popup(p)
|
||||||
} else {
|
} else {
|
||||||
|
self.date_selected = NaiveDate::from(self.now.naive_local());
|
||||||
|
|
||||||
let new_id = window::Id::unique();
|
let new_id = window::Id::unique();
|
||||||
self.popup.replace(new_id);
|
self.popup.replace(new_id);
|
||||||
|
|
||||||
|
|
@ -166,21 +168,27 @@ impl cosmic::Application for Window {
|
||||||
Command::none()
|
Command::none()
|
||||||
}
|
}
|
||||||
Message::SelectDay(_day) => {
|
Message::SelectDay(_day) => {
|
||||||
// TODO
|
if let Some(date) = self.date_selected.with_day(_day) {
|
||||||
|
self.date_selected = date;
|
||||||
|
} else {
|
||||||
|
tracing::error!("invalid naivedate");
|
||||||
|
}
|
||||||
Command::none()
|
Command::none()
|
||||||
}
|
}
|
||||||
Message::PreviousMonth => {
|
Message::PreviousMonth => {
|
||||||
self.date_selected = self
|
if let Some(date) = self.date_selected.checked_sub_months(Months::new(1)) {
|
||||||
.date_selected
|
self.date_selected = date;
|
||||||
.checked_sub_months(Months::new(1))
|
} else {
|
||||||
.expect("valid naivedate");
|
tracing::error!("invalid naivedate");
|
||||||
|
}
|
||||||
Command::none()
|
Command::none()
|
||||||
}
|
}
|
||||||
Message::NextMonth => {
|
Message::NextMonth => {
|
||||||
self.date_selected = self
|
if let Some(date) = self.date_selected.checked_add_months(Months::new(1)) {
|
||||||
.date_selected
|
self.date_selected = date;
|
||||||
.checked_add_months(Months::new(1))
|
} else {
|
||||||
.expect("valid naivedate");
|
tracing::error!("invalid naivedate");
|
||||||
|
}
|
||||||
Command::none()
|
Command::none()
|
||||||
}
|
}
|
||||||
Message::OpenDateTimeSettings => {
|
Message::OpenDateTimeSettings => {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue