diff --git a/src/app.rs b/src/app.rs index a7a30f5..7111c93 100644 --- a/src/app.rs +++ b/src/app.rs @@ -1,4 +1,4 @@ -use chrono::{DateTime, Local, NaiveDate, NaiveDateTime, NaiveTime, TimeZone, Utc}; +use chrono::{Local, NaiveDate, NaiveDateTime, NaiveTime, TimeZone}; use sqlite::Connection; use crate::{data_layer, entities::*, enums::*}; diff --git a/src/entities/transaction.rs b/src/entities/transaction.rs index 4feec51..5a28ad9 100644 --- a/src/entities/transaction.rs +++ b/src/entities/transaction.rs @@ -1,4 +1,4 @@ -use crate::{data_layer, entities::Account}; +use crate::data_layer; use chrono::{DateTime, Local, TimeZone, Utc}; use sqlite::Connection; diff --git a/src/main.rs b/src/main.rs index 02bf46e..5948839 100644 --- a/src/main.rs +++ b/src/main.rs @@ -71,7 +71,6 @@ where CurrentWidget::TrxList => { app.next_tr(); } - _ => {} }, KeyCode::Char('k') => match app.current_widget { CurrentWidget::AccountList => { @@ -80,7 +79,6 @@ where CurrentWidget::TrxList => { app.previous_tr(); } - _ => {} }, KeyCode::Char('n') => match app.current_widget { CurrentWidget::AccountList => { @@ -92,7 +90,6 @@ where .set_account_id(app.acc_list.get_selected_id()); app.new_transaction.set_date(Local::now()); } - _ => {} }, _ => {} }, @@ -138,7 +135,6 @@ where app.current_screen = CurrentScreen::Main; } }, - _ => {} } } } diff --git a/src/ui.rs b/src/ui.rs index a2eff15..64112cc 100644 --- a/src/ui.rs +++ b/src/ui.rs @@ -1,13 +1,8 @@ -use crate::{ - app::App, - entities::{Account, Transaction}, - enums::*, -}; -use chrono::{Date, Local}; +use crate::{app::App, entities::Account, enums::*}; use ratatui::{ Frame, layout::{Constraint, Direction, Layout, Rect}, - style::{Color, Modifier, Style, Stylize, palette::tailwind::SLATE}, + style::{Color, Modifier, Style, palette::tailwind::SLATE}, text::{Line, Text}, widgets::{ 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() .iter() .enumerate() - .map(|(i, acc)| ListItem::from(acc)) + .map(|(_, acc)| ListItem::from(acc)) .collect(); 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_desc(), ]) + .style(Style::new().fg(if tr.get_amount() > 0.0 { + Color::Green + } else { + Color::Red + })) }); let widths = [ Constraint::Percentage(30),