Skip to content

Commit

Permalink
fix: sumbit and cancel should close layershell
Browse files Browse the repository at this point in the history
  • Loading branch information
Decodetalkers committed Nov 24, 2024
1 parent a197a1d commit 428d1ae
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 15 deletions.
4 changes: 2 additions & 2 deletions lala_bar/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ pub enum Message {
#[allow(unused)]
LinkClicked(markdown::Url),
ToggleCalendar,
Cancel,
Submit(Date),
CancelDate,
SubmitDate(Date),
ToggleTime,
CancelTime,
SubmitTime(Time),
Expand Down
29 changes: 16 additions & 13 deletions lala_bar/src/music_bar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ pub struct LalaMusicBar {
quite_mode: bool,
datetime: DateTime<Local>,
calendar_id: Option<iced::window::Id>,
show_picker: bool,
date: Date,
is_calendar_open: bool,
time: Time,
Expand Down Expand Up @@ -510,7 +509,6 @@ impl MultiApplication for LalaMusicBar {
quite_mode: false,
datetime: Local::now(),
calendar_id: None,
show_picker: false,
date: Date::today(),
is_calendar_open: false,
is_time_picker_open: false,
Expand Down Expand Up @@ -610,9 +608,9 @@ impl MultiApplication for LalaMusicBar {
Message::ToggleCalendar => {
if self.is_calendar_open && self.calendar_id.is_some() {
self.is_calendar_open = false;
return iced_runtime::task::Task::batch([iced_runtime::task::effect(
Action::Window(WindowAction::Close(self.calendar_id.unwrap())),
)]);
return iced_runtime::task::effect(Action::Window(WindowAction::Close(
self.calendar_id.unwrap(),
)));
} else if self.is_calendar_open
&& self.is_time_picker_open
&& self.calendar_id.is_some()
Expand Down Expand Up @@ -729,12 +727,17 @@ impl MultiApplication for LalaMusicBar {
}
}
// NOTE: it is meaningless to pick the date now
Message::Submit(_date) => {
//self.date = date;
self.show_picker = false;
Message::SubmitDate(_) | Message::CancelDate => {
if let Some(id) = self.calendar_id {
self.is_calendar_open = false;
return iced_runtime::task::effect(Action::Window(WindowAction::Close(id)));
}
}
Message::Cancel => {
self.show_picker = false;
Message::SubmitTime(_) | Message::CancelTime => {
if let Some(id) = self.time_picker_id {
self.is_time_picker_open = false;
return iced_runtime::task::effect(Action::Window(WindowAction::Close(id)));
}
}
Message::RequestPlay => {
if let Some(ref data) = self.service_data {
Expand Down Expand Up @@ -1147,7 +1150,7 @@ impl MultiApplication for LalaMusicBar {
Message::LinkClicked(_link) => {
// I do not care
}
_ => {}
_ => unreachable!(),
}
Command::none()
}
Expand All @@ -1165,8 +1168,8 @@ impl MultiApplication for LalaMusicBar {
true,
self.date,
button(text("Pick date")),
Message::Cancel,
Message::Submit,
Message::CancelDate,
Message::SubmitDate,
))
.center_y(Length::Fill)
.center_x(Length::Fill)
Expand Down

0 comments on commit 428d1ae

Please sign in to comment.