début new account
This commit is contained in:
70
src/main.rs
70
src/main.rs
@@ -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;
|
||||
}
|
||||
},
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user