//! Problems: what is wrong, most serious first. use eframe::egui::{self, RichText, Stroke, Ui}; use sccache_dash_api::{Severity, View}; use crate::style; pub fn section(ui: &mut Ui, view: &View, dark: bool) { style::section(ui, "problems", "Problems", |ui| { if view.problems.is_empty() { ui.label("No problems."); return; } let [_, warn, bad] = style::marks(dark); for problem in &view.problems { let color = match problem.severity { Severity::Error => bad, Severity::Warning => warn, }; let kind = match problem.severity { Severity::Error => "Error", Severity::Warning => "Warning", }; // As wide as there is room, minus a little (see `banner`). let width = ui.available_rect_before_wrap().width() - 2.0 * 8.0; egui::Frame::NONE .fill(color.gamma_multiply(0.14)) .stroke(Stroke::new(1.0, color)) .corner_radius(6.0) .inner_margin(8.0) .show(ui, |ui| { ui.set_min_width(width - 6.0); ui.horizontal_wrapped(|ui| { ui.label(RichText::new(kind).small().strong().color(color)); ui.label(RichText::new(&problem.title).strong()); }); ui.add(egui::Label::new(&problem.detail).wrap()); }); ui.add_space(4.0); } }); }