Skip to content

Commit

Permalink
Segments
Browse files Browse the repository at this point in the history
  • Loading branch information
dantleech committed Nov 27, 2024
1 parent b108334 commit 814e908
Showing 1 changed file with 9 additions and 16 deletions.
25 changes: 9 additions & 16 deletions src/component/segments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,35 +22,28 @@ pub fn draw(app: &mut App, f: &mut Buffer, area: tui::layout::Rect) {
constraints.push(Constraint::Max(0));

let mut rows = vec![];
let sport_type = match activity.sport_type.as_str() {
"Ride" => SportType::Ride,
_ => SportType::Run,
};
let speed_header = match sport_type {
SportType::Ride => "󰓅 Speed",
SportType::Run => "👣 Pace",
};
let header = vec!["#", speed_header, "🏅"];
let header = vec!["Name", ""];

for effort in efforts {
match app.segments.get(&effort.segment_id) {
Some(segment) => {
rows.push(Row::new([
Cell::from(format!("{}", segment.name)).set_style(Style::default()),
match sport_type {
_ => Cell::from(app.unit_formatter.pace(effort.moving_time, 1000.0)),
},
Cell::from(format!("{:?}", effort.pr_rank.unwrap_or(0))),
Cell::from(format!("{}", match effort.pr_rank {
Some(1) => "🥇",
Some(2) => "🥈",
Some(3) => "🥉",
_ => ""
})),
]));
Some(())
}
None => None,
};
}
Table::new(rows, &[
Constraint::Percentage(50),
Constraint::Percentage(45),
Constraint::Percentage(5),
Constraint::Min(5),
Constraint::Length(2),
])
.header(
Row::new(header)
Expand Down

0 comments on commit 814e908

Please sign in to comment.