Refactored tables and loading blocks to use the new dedicated widgets for Tables and Loading blocks

This commit is contained in:
2024-02-10 19:23:19 -07:00
parent 68de986c48
commit 51b789fd0f
19 changed files with 1174 additions and 1150 deletions
+33
View File
@@ -0,0 +1,33 @@
use crate::ui::styles::ManagarrStyle;
use ratatui::buffer::Buffer;
use ratatui::layout::Rect;
use ratatui::prelude::Text;
use ratatui::widgets::{Block, Paragraph, Widget};
pub struct LoadingBlock<'a> {
is_loading: bool,
block: Block<'a>,
}
impl<'a> LoadingBlock<'a> {
pub fn new(is_loading: bool, block: Block<'a>) -> Self {
Self { is_loading, block }
}
fn render_loading_block(&self, area: Rect, buf: &mut Buffer) {
if self.is_loading {
Paragraph::new(Text::from("\n\n Loading ...\n\n"))
.system_function()
.block(self.block.clone())
.render(area, buf);
} else {
self.block.clone().render(area, buf);
}
}
}
impl<'a> Widget for LoadingBlock<'a> {
fn render(self, area: Rect, buf: &mut Buffer) {
self.render_loading_block(area, buf);
}
}