aboutsummaryrefslogtreecommitdiffstats
path: root/src/ui.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui.rs')
-rw-r--r--src/ui.rs29
1 files changed, 14 insertions, 15 deletions
diff --git a/src/ui.rs b/src/ui.rs
index 9411157..65b1ad0 100644
--- a/src/ui.rs
+++ b/src/ui.rs
@@ -1,10 +1,4 @@
-use crate::{
- app::App,
- unit_of_measurement::{
- pressure::{self, Pressure},
- UnitOfMeasurement,
- },
-};
+use crate::{app::App, input::InputParam, unit_of_measurement::UnitOfMeasurement};
use std::ptr;
use tui::{
layout::Constraint,
@@ -15,10 +9,15 @@ use tui::{
pub fn input_table(app: &App) -> impl Widget {
let rows = app.rows().iter().map(|row| {
let cells = row.iter().map(|item| {
+ let item_str = match item {
+ InputParam::Rpm(rpm) => rpm.to_string(),
+ InputParam::Ve(ve) => ve.to_string(),
+ InputParam::Map(p) => p.as_unit(app.pressure_unit).to_string(),
+ };
if ptr::eq(item, app.selected_input_param()) {
- Cell::from(item.string()).style(Style::default().fg(Color::Yellow))
+ Cell::from(item_str).style(Style::default().fg(Color::Yellow))
} else {
- Cell::from(item.string())
+ Cell::from(item_str)
}
});
widgets::Row::new(cells)
@@ -35,10 +34,10 @@ pub fn input_table(app: &App) -> impl Widget {
}
pub fn output_table(app: &App) -> impl Widget {
- let map = match app.rows()[0].map.string().parse::<i32>() {
- Ok(p) => Pressure::from_unit(pressure::Unit::KiloPascal, p),
- Err(_) => Pressure::default(),
- };
- Paragraph::new(map.as_unit(pressure::Unit::KiloPascal).to_string())
- .block(Block::default().title("map").borders(Borders::ALL))
+ if let InputParam::Map(p) = &app.rows()[0].map {
+ Paragraph::new(p.as_unit(app.pressure_unit).to_string())
+ .block(Block::default().title("map").borders(Borders::ALL))
+ } else {
+ Paragraph::new("err").block(Block::default().title("map").borders(Borders::ALL))
+ }
}