Popup
This commit is contained in:
24
src/view.rs
24
src/view.rs
@@ -1,7 +1,29 @@
|
||||
use component::Component;
|
||||
use std::io;
|
||||
|
||||
use crossterm::event::Event;
|
||||
use ratatui::{
|
||||
layout::{Flex, Layout, Rect},
|
||||
Frame,
|
||||
};
|
||||
|
||||
pub mod component;
|
||||
pub mod home;
|
||||
pub mod setting;
|
||||
|
||||
pub trait View {
|
||||
fn draw(&self, frame: &mut Frame);
|
||||
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);
|
||||
}
|
||||
|
||||
fn center_rect(area: Rect, width: u16, height: u16) -> Rect {
|
||||
let horizontal = Layout::horizontal([width]).flex(Flex::Center);
|
||||
let vertical = Layout::vertical([height]).flex(Flex::Center);
|
||||
let [area] = vertical.areas(area);
|
||||
let [area] = horizontal.areas(area);
|
||||
area
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user