use crate::reply::balls::BoundBall;
use crate::ui::{Model, theme};
pub const UNAIMED: &str = "aim at a workspace to see the balls it holds";
pub const NOT_ANSWERED: &str = "waiting to hear what this workspace holds";
pub const NOTHING: &str = "this workspace holds no balls";
pub fn render(ui: &mut egui::Ui, model: &Model) {
ui.separator();
let Some(aim) = model.aim.clone() else {
ui.label(UNAIMED);
return;
};
ui.label(aim.address);
if let Some(branch) = &model.marks {
ui.colored_label(
theme::tone_ink(&crate::reply::convs::Tone::Weak),
tracking(branch),
);
}
let Some(rows) = model.holding.as_deref() else {
ui.label(NOT_ANSWERED);
return;
};
if rows.is_empty() {
ui.label(NOTHING);
return;
}
for row in rows {
ui.label(bound(row));
ui.colored_label(
theme::tone_ink(&crate::reply::convs::Tone::Weak),
super::cost(&row.spend),
);
}
}
pub fn tracking(branch: &str) -> String {
format!("tracking tasks on {branch}")
}
pub fn bound(row: &BoundBall) -> String {
let mut said = vec![row.id.clone(), format!("[{}]", row.state)];
if let Some(badge) = &row.badge {
said.push(badge.clone());
}
said.push(format!("in {} as {}", row.project, row.owner));
said.join(" ")
}
#[cfg(test)]
mod tests;