Skip to content

Commit

Permalink
Fix time picker use 24 h and show seconds options. fixes #199
Browse files Browse the repository at this point in the history
  • Loading branch information
genusistimelord committed Dec 27, 2023
1 parent 22f43ef commit 43c38cb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 3 additions & 1 deletion src/native/overlay/time_picker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1659,8 +1659,10 @@ pub struct State {
impl State {
/// Creates a new State with the given time.
#[must_use]
pub fn new(time: Time) -> Self {
pub fn new(time: Time, use_24h: bool, show_seconds: bool) -> Self {
Self {
use_24h,
show_seconds,
time: time.into(),
..Self::default()
}
Expand Down
8 changes: 3 additions & 5 deletions src/native/time_picker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,18 +153,16 @@ impl State {

/// Creates a new [`State`] with the given time.
#[must_use]
pub fn new(time: Time) -> Self {
pub fn new(time: Time, use_24h: bool, show_seconds: bool) -> Self {
Self {
overlay_state: time_picker::State::new(time),
overlay_state: time_picker::State::new(time, use_24h, show_seconds),
}
}

/// Resets the time of the state to the current time.
pub fn reset(&mut self) {
self.overlay_state.clock_cache.clear();
self.overlay_state.time = Local::now().naive_local().time();
self.overlay_state.use_24h = false;
self.overlay_state.show_seconds = false;
}
}

Expand All @@ -178,7 +176,7 @@ where
}

fn state(&self) -> tree::State {
tree::State::new(State::new(self.time))
tree::State::new(State::new(self.time, self.use_24h, self.show_seconds))
}

fn children(&self) -> Vec<Tree> {
Expand Down

0 comments on commit 43c38cb

Please sign in to comment.