Remove PopupView Trait

This commit is contained in:
RainBus
2024-10-17 23:22:43 +08:00
parent c79e17a06f
commit ca05dfd3da
2 changed files with 8 additions and 7 deletions

View File

@@ -15,10 +15,7 @@ pub trait View {
fn handle_event(&mut self, event: &Event) -> io::Result<()>; fn handle_event(&mut self, event: &Event) -> io::Result<()>;
} }
pub trait PopupView { pub trait EventAcceptable {}
fn draw(&self, frame: &mut Frame);
fn handle_event(&mut self, event: &Event);
}
fn center_rect(area: Rect, width: u16, height: u16) -> Rect { fn center_rect(area: Rect, width: u16, height: u16) -> Rect {
let horizontal = Layout::horizontal([width]).flex(Flex::Center); let horizontal = Layout::horizontal([width]).flex(Flex::Center);

View File

@@ -1,9 +1,11 @@
use std::io;
use ratatui::layout::{Constraint, Layout, Rect}; use ratatui::layout::{Constraint, Layout, Rect};
use super::{ use super::{
center_rect, center_rect,
component::{list::ListComponent, Component}, component::{list::ListComponent, Component},
PopupView, View,
}; };
pub struct SettingView { 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) { fn draw(&self, frame: &mut ratatui::Frame) {
let area = center_rect(frame.area(), self.area.width, self.area.height); let area = center_rect(frame.area(), self.area.width, self.area.height);
let layout = Layout::default() let layout = Layout::default()
@@ -31,5 +33,7 @@ impl PopupView for SettingView {
frame.render_widget(self.menu.widget(), layout[0]); 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(())
}
} }