use nika::tui::widgets::{DagAscii, NodeBoxData, NodeBoxMode};
use nika::tui::{TaskStatus, VerbColor};
use ratatui::{buffer::Buffer, layout::Rect, widgets::Widget};
use std::collections::HashMap;
fn main() {
let nodes = vec![
NodeBoxData::new("task1", VerbColor::Infer)
.with_status(TaskStatus::Pending)
.with_estimate("~1s"),
NodeBoxData::new("task2", VerbColor::Exec)
.with_status(TaskStatus::Pending)
.with_estimate("~2s"),
];
let mut deps = HashMap::new();
deps.insert("task2".to_string(), vec!["task1".to_string()]);
let widget = DagAscii::new(&nodes)
.with_dependencies(deps)
.mode(NodeBoxMode::Minimal);
let area = Rect::new(0, 0, 60, 15);
let mut buffer = Buffer::empty(area);
widget.render(area, &mut buffer);
println!(
"DAG ASCII Render Output ({} x {}):",
area.width, area.height
);
println!("{}", "=".repeat(area.width as usize));
for y in 0..area.height {
let mut line = String::new();
for x in 0..area.width {
let cell = buffer.cell((x, y)).unwrap();
line.push_str(cell.symbol());
}
println!("|{}|", line);
}
println!("{}", "=".repeat(area.width as usize));
}