use ratatui::{
widgets::{BorderType, Block, Borders},
style::Style,
};
#[derive(Debug)]
pub struct NodeLayout<'a> {
pub size: (u16, u16),
border_type: BorderType,
title: &'a str,
border_style: Style,
}
impl<'a> NodeLayout<'a> {
pub fn new(size: (u16, u16)) -> Self {
Self {
size,
border_type: BorderType::Plain,
title: "",
border_style: Style::default(),
}
}
pub fn with_title(mut self, title: &'a str) -> Self {
self.title = title;
self
}
pub fn title(&self) -> &str {
self.title
}
pub fn with_border_type(mut self, border: BorderType) -> Self {
self.border_type = border;
self
}
pub fn border_type(&self) -> BorderType {
self.border_type
}
pub fn with_border_style(mut self, style: Style) -> Self{
self.border_style = style;
self
}
pub fn block(&self) -> Block {
Block::default()
.borders(Borders::ALL)
.border_type(self.border_type)
.border_style(self.border_style)
.title(self.title)
}
}