Skip to content

Commit

Permalink
style: Re-order columns
Browse files Browse the repository at this point in the history
  • Loading branch information
LeoniePhiline committed Sep 12, 2022
1 parent 9b351cf commit 57e7f63
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 15 deletions.
4 changes: 2 additions & 2 deletions src/ui/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,19 @@ pub fn video_raw_progress_table_layout() -> [Constraint; 4] {
[
Constraint::Percentage(10),
Constraint::Percentage(10),
Constraint::Percentage(40), // 4-column span
Constraint::Percentage(40),
Constraint::Percentage(40), // 4-column span
]
}

pub fn video_progress_detail_table_layout() -> [Constraint; 7] {
[
Constraint::Percentage(10),
Constraint::Percentage(10),
Constraint::Percentage(40),
Constraint::Percentage(10),
Constraint::Percentage(10),
Constraint::Percentage(10),
Constraint::Percentage(10),
Constraint::Percentage(40),
]
}
20 changes: 7 additions & 13 deletions src/ui/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,11 +218,11 @@ impl Ui {
Row::new([
"Stage",
"Progress",
"Destination",
"Size",
"Speed",
"ETA",
"Fragments",
"Destination",
])
.style(style::table_header_style())
.bottom_margin(1),
Expand Down Expand Up @@ -294,6 +294,12 @@ impl Ui {
// as a fresh value can not in all cases be parsed from the current line.
row.push(Span::raw(format!("{:.1} %", display_percent)));

// Column "Destination"
row.push(Span::raw(match video.output_file().as_ref() {
Some(output_file) => output_file.as_str(),
None => "",
}));

match progress {
ProgressDetail::Raw(line) => {
// Single column, spanning across "Size", "Speed", "ETA" and "Fragments"
Expand All @@ -306,12 +312,6 @@ impl Ui {
_ => *line,
}));

// Column "Destination"
row.push(Span::raw(match video.output_file().as_ref() {
Some(output_file) => output_file.as_str(),
None => "",
}));

f.render_widget(
Table::new([Row::new(row)])
.widths(&layout::video_raw_progress_table_layout())
Expand All @@ -333,12 +333,6 @@ impl Ui {
.collect::<Vec<Span>>(),
);

// Column "Destination"
row.push(Span::raw(match video.output_file().as_ref() {
Some(output_file) => output_file.as_str(),
None => "",
}));

f.render_widget(
Table::new([Row::new(row)])
.widths(&layout::video_progress_detail_table_layout())
Expand Down

0 comments on commit 57e7f63

Please sign in to comment.