| 1 | //! Gallery: the spinner, before and after it is earned, and under reduced |
| 2 | //! motion. |
| 3 | |
| 4 | use std::time::Duration; |
| 5 | |
| 6 | use ratatui::{buffer::Buffer, layout::Rect}; |
| 7 | |
| 8 | use super::Entry; |
| 9 | use crate::{MotionMode, Paint, Spinner, Theme}; |
| 10 | |
| 11 | fn spinners(area: Rect, buf: &mut Buffer, theme: &Theme) { |
| 12 | for (row, (elapsed, motion)) in [ |
| 13 | (Duration::from_millis(200), MotionMode::Full), |
| 14 | (Duration::from_millis(1400), MotionMode::Full), |
| 15 | (Duration::from_secs(246), MotionMode::Reduced), |
| 16 | ] |
| 17 | .into_iter() |
| 18 | .enumerate() |
| 19 | { |
| 20 | Spinner::new("Running cargo test", elapsed, motion).paint( |
| 21 | Rect { |
| 22 | y: area.y.saturating_add(row as u16), |
| 23 | height: 1, |
| 24 | ..area |
| 25 | } |
| 26 | .intersection(area), |
| 27 | buf, |
| 28 | theme, |
| 29 | ); |
| 30 | } |
| 31 | } |
| 32 | |
| 33 | pub(crate) fn entries() -> Vec<Entry> { |
| 34 | vec![Entry { |
| 35 | name: "spinner", |
| 36 | width: 40, |
| 37 | height: 3, |
| 38 | draw: spinners, |
| 39 | }] |
| 40 | } |
| 41 |