-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
112 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ pub enum RouteId { | |
pub enum ActiveBlock { | ||
SearchBar, | ||
MyPositions, | ||
PositionInfo, | ||
} | ||
|
||
#[derive(Clone)] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
use ratatui::{ | ||
layout::{Constraint, Direction, Layout, Rect}, | ||
style::{Color, Style, Stylize}, | ||
text::{Line, Span}, | ||
widgets::{Block, Borders, Paragraph}, | ||
}; | ||
|
||
pub fn render_help_popup<'a>(size: Rect) -> (Paragraph<'a>, Block<'a>, Rect) { | ||
let block = Block::default() | ||
.title("Keybindings - Press Esc to close the popup") | ||
.borders(Borders::ALL); | ||
|
||
let input = Paragraph::new(vec![ | ||
Line::from( | ||
Span::raw(format!(" {:<4}: {}", "s", "Move to the Search Bar")).fg(Color::White), | ||
), | ||
Line::from( | ||
Span::raw(format!(" {:<4}: {}", "1", "Move to Positions Info area")).fg(Color::White), | ||
), | ||
Line::from( | ||
Span::raw(format!(" {:<4}: {}", "2", "Move to the My Positions")).fg(Color::White), | ||
), | ||
]) | ||
.style(Style::default().fg(Color::Green)) | ||
.block(block.to_owned()); | ||
|
||
let area = centered_rect(40, 10, size); | ||
|
||
(input, block, area) | ||
} | ||
|
||
/// helper function to create a centered rect using up certain percentage of the available rect `r` | ||
fn centered_rect(percent_x: u16, percent_y: u16, r: Rect) -> Rect { | ||
let popup_layout = Layout::default() | ||
.direction(Direction::Vertical) | ||
.constraints([ | ||
Constraint::Percentage((100 - percent_y) / 2), | ||
Constraint::Percentage(percent_y), | ||
Constraint::Percentage((100 - percent_y) / 2), | ||
]) | ||
.split(r); | ||
|
||
Layout::default() | ||
.direction(Direction::Horizontal) | ||
.constraints([ | ||
Constraint::Percentage((100 - percent_x) / 2), | ||
Constraint::Percentage(percent_x), | ||
Constraint::Percentage((100 - percent_x) / 2), | ||
]) | ||
.split(popup_layout[1])[1] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
pub mod chart; | ||
pub mod help; | ||
pub mod search; | ||
pub mod spinner; | ||
pub mod table; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters