diff --git a/src/app.rs b/src/app.rs index 0676246..6e18450 100644 --- a/src/app.rs +++ b/src/app.rs @@ -13,6 +13,7 @@ pub struct App { pub selected_transaction_input: TransactionInput, pub selected_account_input: AccountInput, pub current_input: String, + pub tr_types: Vec, pub connection: Connection, } @@ -38,6 +39,7 @@ impl App { selected_transaction_input: TransactionInput::Type, selected_account_input: AccountInput::Asset, current_input: String::new(), + tr_types: data_layer::get_transaction_types(&con), connection: con, }; } diff --git a/src/ui.rs b/src/ui.rs index d2d5eee..ffef474 100644 --- a/src/ui.rs +++ b/src/ui.rs @@ -197,6 +197,28 @@ pub fn ui(frame: &mut Frame, app: &mut App) { .title("Asset amount"), ); frame.render_widget(asset_amnt, chunks[4]); + + if let TransactionInput::Type = app.selected_transaction_input { + let helper = Block::default() + .title("Helper") + .borders(Borders::all()) + .style(Style::default()); + + let helper_string: String = app + .tr_types + .iter() + .map(|tr_type| { + tr_type.get_id().to_string() + " " + &tr_type.get_description() + "\n" + }) + .collect(); + let helper_text = Text::styled(helper_string, Style::default()); + let helper_paragraph = Paragraph::new(helper_text) + .block(helper) + .wrap(Wrap { trim: false }); + let area = helper_rect(frame.area()); + frame.render_widget(Clear, area); + frame.render_widget(helper_paragraph, area); + } } if let CurrentScreen::Exiting = app.current_screen { @@ -239,6 +261,17 @@ fn centered_rect(percent_x: u16, percent_y: u16, r: Rect) -> Rect { ]) .split(popup_layout[1])[1]; } +fn helper_rect(r: Rect) -> Rect { + let popup_layout = Layout::default() + .direction(Direction::Vertical) + .constraints([Constraint::Percentage(70), Constraint::Percentage(30)]) + .split(r); + + return Layout::default() + .direction(Direction::Horizontal) + .constraints([Constraint::Percentage(30), Constraint::Percentage(70)]) + .split(popup_layout[1])[0]; +} fn tr_input_style(input: TransactionInput, app: &mut App) -> Style { if app.selected_transaction_input == input {