Skip to content

Commit

Permalink
Remove Boxed content in Popup
Browse files Browse the repository at this point in the history
  • Loading branch information
TheRealLorenz committed Jan 16, 2024
1 parent bb0f1a2 commit 6a53869
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions rq-cli/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ pub struct App {
should_exit: bool,
file_path: String,
focus: FocusState,
popups: VecDeque<Popup>,
popups: VecDeque<Box<dyn BlockComponent>>,
}

fn spawn_request_handler(
Expand Down Expand Up @@ -206,7 +206,7 @@ impl App {
Event::NewInput((content, typ)) => {
match typ {
crate::event::InputType::FileName(save_option) => {
self.popups.push_back(Popup::new(Box::new(
self.popups.push_back(Box::new(Popup::new(
InputComponent::from(content.as_str())
.with_cursor(0)
.with_confirm_callback(move |value| {
Expand All @@ -232,7 +232,7 @@ impl App {
}
Event::Message(message) => {
self.popups
.push_back(Popup::new(Box::new(MessageDialog::new(message))));
.push_back(Box::new(Popup::new(MessageDialog::new(message))));
Ok(())
}
};
Expand Down
10 changes: 5 additions & 5 deletions rq-cli/src/components/popup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ use ratatui::{

use super::{legend::Legend, BlockComponent};

pub struct Popup {
component: Box<dyn BlockComponent>,
pub struct Popup<T: BlockComponent> {
component: T,
w_percent: u16,
h_percent: u16,
}

impl Popup {
pub fn new(widget: Box<dyn BlockComponent>) -> Self {
impl<T: BlockComponent> Popup<T> {
pub fn new(widget: T) -> Self {
Self {
component: widget,
w_percent: 40,
Expand All @@ -21,7 +21,7 @@ impl Popup {
}
}

impl BlockComponent for Popup {
impl<T: BlockComponent> BlockComponent for Popup<T> {
fn on_event(&mut self, key_event: crossterm::event::KeyEvent) -> super::HandleResult {
self.component.on_event(key_event)
}
Expand Down

0 comments on commit 6a53869

Please sign in to comment.