Remove PopupView Trait
This commit is contained in:
@@ -15,10 +15,7 @@ pub trait View {
|
||||
fn handle_event(&mut self, event: &Event) -> io::Result<()>;
|
||||
}
|
||||
|
||||
pub trait PopupView {
|
||||
fn draw(&self, frame: &mut Frame);
|
||||
fn handle_event(&mut self, event: &Event);
|
||||
}
|
||||
pub trait EventAcceptable {}
|
||||
|
||||
fn center_rect(area: Rect, width: u16, height: u16) -> Rect {
|
||||
let horizontal = Layout::horizontal([width]).flex(Flex::Center);
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
use std::io;
|
||||
|
||||
use ratatui::layout::{Constraint, Layout, Rect};
|
||||
|
||||
use super::{
|
||||
center_rect,
|
||||
component::{list::ListComponent, Component},
|
||||
PopupView,
|
||||
View,
|
||||
};
|
||||
|
||||
pub struct SettingView {
|
||||
@@ -22,7 +24,7 @@ impl Default for SettingView {
|
||||
}
|
||||
}
|
||||
|
||||
impl PopupView for SettingView {
|
||||
impl View for SettingView {
|
||||
fn draw(&self, frame: &mut ratatui::Frame) {
|
||||
let area = center_rect(frame.area(), self.area.width, self.area.height);
|
||||
let layout = Layout::default()
|
||||
@@ -31,5 +33,7 @@ impl PopupView for SettingView {
|
||||
frame.render_widget(self.menu.widget(), layout[0]);
|
||||
}
|
||||
|
||||
fn handle_event(&mut self, _event: &crossterm::event::Event) {}
|
||||
fn handle_event(&mut self, _event: &crossterm::event::Event) -> io::Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user