mirror of
https://github.com/kristoferssolo/traxor.git
synced 2025-10-21 20:10:35 +00:00
feat(popup): position popup
This commit is contained in:
parent
a8c160222b
commit
f347768aac
@ -102,4 +102,12 @@ impl<'a> App<'a> {
|
||||
pub fn toggle_popup(&mut self) {
|
||||
self.show_popup = !self.show_popup;
|
||||
}
|
||||
|
||||
pub fn close_popup(&mut self) {
|
||||
self.show_popup = false;
|
||||
}
|
||||
|
||||
pub fn open_popup(&mut self) {
|
||||
self.show_popup = true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -56,7 +56,7 @@ pub fn render(app: &mut App, frame: &mut Frame) {
|
||||
|
||||
if app.show_popup {
|
||||
let block = Block::default().title("Popup").borders(Borders::ALL);
|
||||
let size = render_popup(60, 20, size);
|
||||
let size = render_popup(size);
|
||||
frame.render_widget(Clear, size);
|
||||
frame.render_widget(block, size);
|
||||
}
|
||||
|
||||
@ -1,21 +1,17 @@
|
||||
use ratatui::layout::{Constraint, Direction, Layout, Rect};
|
||||
|
||||
pub fn render_popup(percent_x: u16, percent_y: u16, r: Rect) -> Rect {
|
||||
pub fn render_popup(r: Rect) -> Rect {
|
||||
let percent_y = 20;
|
||||
let popup_layput = Layout::default()
|
||||
.direction(Direction::Vertical)
|
||||
.constraints([
|
||||
Constraint::Percentage((100 - percent_y) / 2),
|
||||
Constraint::Percentage(100 - percent_y),
|
||||
Constraint::Percentage(percent_y),
|
||||
Constraint::Percentage((100 - percent_y) / 2),
|
||||
])
|
||||
.split(r);
|
||||
|
||||
Layout::default()
|
||||
.direction(Direction::Horizontal)
|
||||
.constraints([
|
||||
Constraint::Percentage((100 - percent_y) / 2),
|
||||
Constraint::Percentage(percent_y),
|
||||
Constraint::Percentage((100 - percent_y) / 2),
|
||||
])
|
||||
.constraints([Constraint::Percentage(0), Constraint::Percentage(100)])
|
||||
.split(popup_layput[1])[1]
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user