Skip to content

Commit

Permalink
fix duration
Browse files Browse the repository at this point in the history
  • Loading branch information
qxb3 committed Jan 9, 2025
1 parent 45781ba commit 7f6e114
Showing 1 changed file with 41 additions and 8 deletions.
49 changes: 41 additions & 8 deletions src/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,10 +203,9 @@ impl<'a> Ui<'a> {
}
};

let [current_pos_area, _, length_area] = Layout::horizontal([
Constraint::Length(4),
Constraint::Min(0),
Constraint::Length(4),
let [current_pos_area, length_area] = Layout::horizontal([
Constraint::Percentage(50),
Constraint::Percentage(50)
]).areas(progress_text_area);

if !self.config.hidden.contains(&"progress-bar".to_string()) {
Expand All @@ -225,13 +224,47 @@ impl<'a> Ui<'a> {

if !self.config.hidden.contains(&"progress-text".to_string()) {
frame.render_widget(
Text::from(format!("{}:{:02}", current_progress.as_secs() / 60, current_progress.as_secs() % 60)).left_aligned(),
current_pos_area
Text::from(format!(
"{}",
if current_progress.as_secs() >= 3600 {
format!(
"{}:{:02}:{:02}",
current_progress.as_secs() / 3600,
(current_progress.as_secs() % 3600) / 60,
current_progress.as_secs() % 60
)
} else {
format!(
"{}:{:02}",
current_progress.as_secs() / 60,
current_progress.as_secs() % 60
)
}
))
.left_aligned(),
current_pos_area,
);

frame.render_widget(
Text::from(format!("{}:{:02}", meta.length.as_secs() / 60, meta.length.as_secs() % 60)).right_aligned(),
length_area
Text::from(format!(
"{}",
if meta.length.as_secs() >= 3600 {
format!(
"{}:{:02}:{:02}",
meta.length.as_secs() / 3600,
(meta.length.as_secs() % 3600) / 60,
meta.length.as_secs() % 60
)
} else {
format!(
"{}:{:02}",
meta.length.as_secs() / 60,
meta.length.as_secs() % 60
)
}
))
.right_aligned(),
length_area,
);
}
}
Expand Down

0 comments on commit 7f6e114

Please sign in to comment.