| 1 | //! Gallery: icons. |
| 2 | |
| 3 | use std::time::Duration; |
| 4 | |
| 5 | use ratatui::{ |
| 6 | buffer::Buffer, |
| 7 | layout::Rect, |
| 8 | text::{Line, Span}, |
| 9 | widgets::Widget, |
| 10 | }; |
| 11 | |
| 12 | use super::Entry; |
| 13 | use crate::{Icon, MotionMode, Role, Theme}; |
| 14 | |
| 15 | fn icons(area: Rect, buf: &mut Buffer, theme: &Theme) { |
| 16 | let rows: [(Icon, &str); 4] = [ |
| 17 | ( |
| 18 | Icon::Sonar { |
| 19 | elapsed: Duration::from_millis(600), |
| 20 | motion: MotionMode::Full, |
| 21 | }, |
| 22 | "Searching the codebase", |
| 23 | ), |
| 24 | (Icon::tide(3, 5).expect("known total"), "3 of 5 phases done"), |
| 25 | (Icon::Shell, "Receipt: edited summary.md"), |
| 26 | (Icon::Kelp, "Divider"), |
| 27 | ]; |
| 28 | for (row, (icon, words)) in rows.iter().enumerate() { |
| 29 | Line::from(vec![ |
| 30 | icon.span(theme), |
| 31 | Span::raw(" "), |
| 32 | Span::styled(*words, theme.fg(Role::Foreground)), |
| 33 | Span::styled(format!(" ({})", icon.label()), theme.fg(Role::Muted)), |
| 34 | ]) |
| 35 | .render( |
| 36 | Rect { |
| 37 | y: area.y.saturating_add(row as u16), |
| 38 | height: 1, |
| 39 | ..area |
| 40 | } |
| 41 | .intersection(area), |
| 42 | buf, |
| 43 | ); |
| 44 | } |
| 45 | } |
| 46 | |
| 47 | pub(crate) fn entries() -> Vec<Entry> { |
| 48 | vec![Entry { |
| 49 | name: "icons", |
| 50 | width: 50, |
| 51 | height: 4, |
| 52 | draw: icons, |
| 53 | }] |
| 54 | } |
| 55 |