This commit is contained in:
thatscringebro
2026-03-17 10:19:47 -04:00
parent 460f6e9c94
commit 1a7a3baaf5
2 changed files with 35 additions and 0 deletions

View File

@@ -13,6 +13,7 @@ pub struct App {
pub selected_transaction_input: TransactionInput, pub selected_transaction_input: TransactionInput,
pub selected_account_input: AccountInput, pub selected_account_input: AccountInput,
pub current_input: String, pub current_input: String,
pub tr_types: Vec<TransactionType>,
pub connection: Connection, pub connection: Connection,
} }
@@ -38,6 +39,7 @@ impl App {
selected_transaction_input: TransactionInput::Type, selected_transaction_input: TransactionInput::Type,
selected_account_input: AccountInput::Asset, selected_account_input: AccountInput::Asset,
current_input: String::new(), current_input: String::new(),
tr_types: data_layer::get_transaction_types(&con),
connection: con, connection: con,
}; };
} }

View File

@@ -197,6 +197,28 @@ pub fn ui(frame: &mut Frame, app: &mut App) {
.title("Asset amount"), .title("Asset amount"),
); );
frame.render_widget(asset_amnt, chunks[4]); 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 { 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]; .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 { fn tr_input_style(input: TransactionInput, app: &mut App) -> Style {
if app.selected_transaction_input == input { if app.selected_transaction_input == input {