dead code + couleur
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
use chrono::{DateTime, Local, NaiveDate, NaiveDateTime, NaiveTime, TimeZone, Utc};
|
use chrono::{Local, NaiveDate, NaiveDateTime, NaiveTime, TimeZone};
|
||||||
use sqlite::Connection;
|
use sqlite::Connection;
|
||||||
|
|
||||||
use crate::{data_layer, entities::*, enums::*};
|
use crate::{data_layer, entities::*, enums::*};
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
use crate::{data_layer, entities::Account};
|
use crate::data_layer;
|
||||||
use chrono::{DateTime, Local, TimeZone, Utc};
|
use chrono::{DateTime, Local, TimeZone, Utc};
|
||||||
use sqlite::Connection;
|
use sqlite::Connection;
|
||||||
|
|
||||||
|
|||||||
@@ -71,7 +71,6 @@ where
|
|||||||
CurrentWidget::TrxList => {
|
CurrentWidget::TrxList => {
|
||||||
app.next_tr();
|
app.next_tr();
|
||||||
}
|
}
|
||||||
_ => {}
|
|
||||||
},
|
},
|
||||||
KeyCode::Char('k') => match app.current_widget {
|
KeyCode::Char('k') => match app.current_widget {
|
||||||
CurrentWidget::AccountList => {
|
CurrentWidget::AccountList => {
|
||||||
@@ -80,7 +79,6 @@ where
|
|||||||
CurrentWidget::TrxList => {
|
CurrentWidget::TrxList => {
|
||||||
app.previous_tr();
|
app.previous_tr();
|
||||||
}
|
}
|
||||||
_ => {}
|
|
||||||
},
|
},
|
||||||
KeyCode::Char('n') => match app.current_widget {
|
KeyCode::Char('n') => match app.current_widget {
|
||||||
CurrentWidget::AccountList => {
|
CurrentWidget::AccountList => {
|
||||||
@@ -92,7 +90,6 @@ where
|
|||||||
.set_account_id(app.acc_list.get_selected_id());
|
.set_account_id(app.acc_list.get_selected_id());
|
||||||
app.new_transaction.set_date(Local::now());
|
app.new_transaction.set_date(Local::now());
|
||||||
}
|
}
|
||||||
_ => {}
|
|
||||||
},
|
},
|
||||||
_ => {}
|
_ => {}
|
||||||
},
|
},
|
||||||
@@ -138,7 +135,6 @@ where
|
|||||||
app.current_screen = CurrentScreen::Main;
|
app.current_screen = CurrentScreen::Main;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
_ => {}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
16
src/ui.rs
16
src/ui.rs
@@ -1,13 +1,8 @@
|
|||||||
use crate::{
|
use crate::{app::App, entities::Account, enums::*};
|
||||||
app::App,
|
|
||||||
entities::{Account, Transaction},
|
|
||||||
enums::*,
|
|
||||||
};
|
|
||||||
use chrono::{Date, Local};
|
|
||||||
use ratatui::{
|
use ratatui::{
|
||||||
Frame,
|
Frame,
|
||||||
layout::{Constraint, Direction, Layout, Rect},
|
layout::{Constraint, Direction, Layout, Rect},
|
||||||
style::{Color, Modifier, Style, Stylize, palette::tailwind::SLATE},
|
style::{Color, Modifier, Style, palette::tailwind::SLATE},
|
||||||
text::{Line, Text},
|
text::{Line, Text},
|
||||||
widgets::{
|
widgets::{
|
||||||
Block, Borders, HighlightSpacing, List, ListItem, Paragraph, Row, StatefulWidget, Table,
|
Block, Borders, HighlightSpacing, List, ListItem, Paragraph, Row, StatefulWidget, Table,
|
||||||
@@ -50,7 +45,7 @@ pub fn ui(frame: &mut Frame, app: &mut App) {
|
|||||||
.get_list_accounts()
|
.get_list_accounts()
|
||||||
.iter()
|
.iter()
|
||||||
.enumerate()
|
.enumerate()
|
||||||
.map(|(i, acc)| ListItem::from(acc))
|
.map(|(_, acc)| ListItem::from(acc))
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
let list = List::new(ac_items)
|
let list = List::new(ac_items)
|
||||||
@@ -81,6 +76,11 @@ pub fn ui(frame: &mut Frame, app: &mut App) {
|
|||||||
tr.get_amount().to_string(),
|
tr.get_amount().to_string(),
|
||||||
tr.get_desc(),
|
tr.get_desc(),
|
||||||
])
|
])
|
||||||
|
.style(Style::new().fg(if tr.get_amount() > 0.0 {
|
||||||
|
Color::Green
|
||||||
|
} else {
|
||||||
|
Color::Red
|
||||||
|
}))
|
||||||
});
|
});
|
||||||
let widths = [
|
let widths = [
|
||||||
Constraint::Percentage(30),
|
Constraint::Percentage(30),
|
||||||
|
|||||||
Reference in New Issue
Block a user