2024-02-06 03:27:00 +03:00
|
|
|
use ratatui::{buffer::Buffer, layout::{Constraint, Layout, Rect}, widgets::Widget};
|
2023-07-08 14:46:43 +03:00
|
|
|
|
2023-11-04 01:30:52 +03:00
|
|
|
use super::{completion, input, select, tasks, which};
|
2023-12-26 14:48:33 +03:00
|
|
|
use crate::{components, help, Ctx};
|
2023-07-08 14:46:43 +03:00
|
|
|
|
2023-08-02 05:29:49 +03:00
|
|
|
pub(super) struct Root<'a> {
|
2023-07-30 06:53:40 +03:00
|
|
|
cx: &'a Ctx,
|
2023-07-08 14:46:43 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> Root<'a> {
|
2023-08-02 05:29:49 +03:00
|
|
|
pub(super) fn new(cx: &'a Ctx) -> Self { Self { cx } }
|
2023-07-08 14:46:43 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> Widget for Root<'a> {
|
|
|
|
fn render(self, area: Rect, buf: &mut Buffer) {
|
2024-02-06 03:27:00 +03:00
|
|
|
let chunks =
|
2024-02-15 15:20:28 +03:00
|
|
|
Layout::vertical([Constraint::Length(1), Constraint::Fill(1), Constraint::Length(1)])
|
2024-02-06 03:27:00 +03:00
|
|
|
.split(area);
|
2023-07-08 14:46:43 +03:00
|
|
|
|
2023-12-26 14:48:33 +03:00
|
|
|
components::Header.render(chunks[0], buf);
|
|
|
|
components::Manager.render(chunks[1], buf);
|
|
|
|
components::Status.render(chunks[2], buf);
|
|
|
|
components::Preview::new(self.cx).render(area, buf);
|
2023-07-08 14:46:43 +03:00
|
|
|
|
|
|
|
if self.cx.tasks.visible {
|
|
|
|
tasks::Layout::new(self.cx).render(area, buf);
|
|
|
|
}
|
|
|
|
|
2023-07-18 17:23:27 +03:00
|
|
|
if self.cx.select.visible {
|
2023-08-02 05:29:49 +03:00
|
|
|
select::Select::new(self.cx).render(area, buf);
|
2023-07-18 17:23:27 +03:00
|
|
|
}
|
|
|
|
|
2023-07-08 14:46:43 +03:00
|
|
|
if self.cx.input.visible {
|
2023-08-02 05:29:49 +03:00
|
|
|
input::Input::new(self.cx).render(area, buf);
|
2023-07-08 14:46:43 +03:00
|
|
|
}
|
2023-07-24 02:26:16 +03:00
|
|
|
|
2023-10-15 04:09:36 +03:00
|
|
|
if self.cx.help.visible {
|
2023-08-31 08:58:13 +03:00
|
|
|
help::Layout::new(self.cx).render(area, buf);
|
|
|
|
}
|
|
|
|
|
2023-11-04 01:30:52 +03:00
|
|
|
if self.cx.completion.visible {
|
|
|
|
completion::Completion::new(self.cx).render(area, buf);
|
|
|
|
}
|
|
|
|
|
2023-07-24 02:26:16 +03:00
|
|
|
if self.cx.which.visible {
|
2023-08-02 05:29:49 +03:00
|
|
|
which::Which::new(self.cx).render(area, buf);
|
2023-07-24 02:26:16 +03:00
|
|
|
}
|
2023-07-08 14:46:43 +03:00
|
|
|
}
|
|
|
|
}
|