début new account

This commit is contained in:
thatscringebro
2026-02-09 14:30:51 -05:00
parent df4fd0202d
commit b267360b2e
7 changed files with 155 additions and 92 deletions

View File

@@ -1,12 +1,10 @@
mod app;
mod data_layer;
mod entities;
mod enums;
mod ui;
use crate::{
app::{App, CurrentScreen},
ui::ui,
};
use app::CurrentWidget;
use crate::{app::App, enums::*, ui::ui};
use entities::{Account, AccountType};
use ratatui::{
Terminal,
crossterm::{
@@ -62,27 +60,50 @@ fn run_app<B: Backend>(terminal: &mut Terminal<B>, app: &mut App) -> io::Result<
KeyCode::Left => {
app.current_widget = CurrentWidget::AccountList;
}
KeyCode::Char('j') => {
match app.current_widget {
CurrentWidget::AccountList => {
app.next_ac();
}
CurrentWidget::TrxList => {
//app.next_trx();
}
_ => {}
KeyCode::Char('j') => match app.current_widget {
CurrentWidget::AccountList => {
app.next_ac();
}
CurrentWidget::TrxList => {
app.next_tr();
}
_ => {}
},
KeyCode::Char('k') => match app.current_widget {
CurrentWidget::AccountList => {
app.previous_ac();
}
CurrentWidget::TrxList => {
app.previous_tr();
}
_ => {}
},
KeyCode::Char('n') => match app.current_widget {
CurrentWidget::AccountList => {
app.current_screen = CurrentScreen::NewAccount;
}
CurrentWidget::TrxList => {
app.current_screen = CurrentScreen::NewTransaction;
}
_ => {}
},
_ => {}
},
CurrentScreen::NewAccount => match key.code {
KeyCode::Enter => {
app.save_new_account();
app.current_screen = CurrentScreen::Main;
}
KeyCode::Char('k') => {
match app.current_widget {
CurrentWidget::AccountList => {
app.previous_ac();
}
CurrentWidget::TrxList => {
//app.previous_trx();
}
_ => {}
}
KeyCode::Esc => {
app.current_screen = CurrentScreen::Main;
app.new_account = Account::new(0, String::new(), AccountType::Cash);
}
_ => {}
},
CurrentScreen::NewTransaction => match key.code {
KeyCode::Enter => {}
KeyCode::Esc => {
app.current_screen = CurrentScreen::Main;
}
_ => {}
},
@@ -94,6 +115,7 @@ fn run_app<B: Backend>(terminal: &mut Terminal<B>, app: &mut App) -> io::Result<
app.current_screen = CurrentScreen::Main;
}
},
_ => {}
}
}
}