summaryrefslogtreecommitdiff
path: root/src/render
diff options
context:
space:
mode:
authorJulian T <julian@jtle.dk>2024-05-17 20:22:23 +0200
committerJulian T <julian@jtle.dk>2024-05-17 20:22:23 +0200
commit829cbaf2d0fe95abc9c65b1e34e209fc32952805 (patch)
tree3a35d6e768b09ea91540eb2f3f7b2df5bb507841 /src/render
parent22c8553af68c6f5b2c62ba790e06b249ac82ed2a (diff)
Stuff i dont remember, sorry
Diffstat (limited to 'src/render')
-rw-r--r--src/render/tasks.rs34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/render/tasks.rs b/src/render/tasks.rs
new file mode 100644
index 0000000..0f6a79a
--- /dev/null
+++ b/src/render/tasks.rs
@@ -0,0 +1,34 @@
+use ratatui::{layout::Constraint, widgets::{Row, Table, Widget}, prelude::Text};
+
+use crate::model::Task;
+
+
+
+#[derive(Debug)]
+pub struct TaskList<'a> {
+ tasks: &'a[Task]
+}
+
+impl<'a> TaskList<'a> {
+ pub fn new(tasks: &'a[Task]) -> TaskList<'a> {
+ TaskList {
+ tasks
+ }
+ }
+}
+
+impl<'a> Widget for &TaskList<'a> {
+ fn render(self, area: ratatui::prelude::Rect, buf: &mut ratatui::prelude::Buffer) {
+ let rows: Vec<Row> = self.tasks.into_iter()
+ .map(|t: &Task| Row::new(vec![Text::from(t.name.as_str()), Text::from(t.description.as_str())]))
+ .collect();
+
+ let widths = [
+ Constraint::Percentage(50),
+ Constraint::Fill(1),
+ ];
+
+ Table::new(rows, widths)
+ .render(area, buf);
+ }
+}