(frame: &mut Frame<'_>, app: &App, area: Rect)
| 10 | use crate::app::{App, SandboxPolicyTab, SettingScope}; |
| 11 | |
| 12 | pub fn draw(frame: &mut Frame<'_>, app: &App, area: Rect) { |
| 13 | let t = &app.theme; |
| 14 | |
| 15 | let header = Row::new(vec![ |
| 16 | Cell::from(Span::styled(" KEY", t.muted)), |
| 17 | Cell::from(Span::styled("TYPE", t.muted)), |
| 18 | Cell::from(Span::styled("VALUE", t.muted)), |
| 19 | Cell::from(Span::styled("SCOPE", t.muted)), |
| 20 | ]) |
| 21 | .bottom_margin(1); |
| 22 | |
| 23 | let rows: Vec<Row<'_>> = app |
| 24 | .sandbox_settings |
| 25 | .iter() |
| 26 | .enumerate() |
| 27 | .map(|(i, entry)| { |
| 28 | let selected = i == app.sandbox_settings_selected; |
| 29 | let key_cell = if selected { |
| 30 | Cell::from(Line::from(vec![ |
| 31 | Span::styled("> ", t.accent), |
| 32 | Span::styled(&entry.key, t.text), |
| 33 | ])) |
| 34 | } else { |
| 35 | Cell::from(Line::from(vec![ |
| 36 | Span::raw(" "), |
| 37 | Span::styled(&entry.key, t.text), |
| 38 | ])) |
| 39 | }; |
| 40 | |
| 41 | let type_label = entry.kind.as_str(); |
| 42 | let value_display = entry.display_value(); |
| 43 | let value_style = if entry.value.is_some() { |
| 44 | if entry.is_globally_managed() { |
| 45 | t.status_warn |
| 46 | } else { |
| 47 | t.accent |
| 48 | } |
| 49 | } else { |
| 50 | t.muted |
| 51 | }; |
| 52 | |
| 53 | let scope_style = match entry.scope { |
| 54 | SettingScope::Global => t.status_warn, |
| 55 | SettingScope::Sandbox => t.accent, |
| 56 | SettingScope::Unset => t.muted, |
| 57 | }; |
| 58 | |
| 59 | Row::new(vec![ |
| 60 | key_cell, |
| 61 | Cell::from(Span::styled(type_label, t.muted)), |
| 62 | Cell::from(Span::styled(value_display, value_style)), |
| 63 | Cell::from(Span::styled(entry.scope.label(), scope_style)), |
| 64 | ]) |
| 65 | }) |
| 66 | .collect(); |
| 67 | |
| 68 | let widths = [ |
| 69 | Constraint::Percentage(30), |
nothing calls this directly
no test coverage detected