返回 CodeWhale
verification.rs
根目录 / vendor / codewhale-ratatui / src / gallery / verification.rs
1 //! Fixed verification instants for the gallery; no fixture owns a timer.
2
3 use std::time::Duration;
4
5 use ratatui::{buffer::Buffer, layout::Rect};
6
7 use super::Entry;
8 use crate::{MotionMode, Paint, Theme, VerificationSpinner};
9
10 fn pending(area: Rect, buf: &mut Buffer, theme: &Theme) {
11 VerificationSpinner::new(
12 "Checking the received result",
13 Duration::from_millis(200),
14 MotionMode::Full,
15 )
16 .paint(area, buf, theme);
17 }
18
19 fn earned(area: Rect, buf: &mut Buffer, theme: &Theme) {
20 VerificationSpinner::new(
21 "Verifying terminal layout",
22 Duration::from_millis(1400),
23 MotionMode::Full,
24 )
25 .paint(area, buf, theme);
26 }
27
28 fn modes(area: Rect, buf: &mut Buffer, theme: &Theme) {
29 for (index, (motion, verb)) in [
30 (MotionMode::Full, "Checking"),
31 (MotionMode::Reduced, "Checking with reduced motion"),
32 (MotionMode::Still, "Checking with still motion"),
33 ]
34 .into_iter()
35 .enumerate()
36 {
37 let row = Rect::new(area.x, area.y.saturating_add(index as u16), area.width, 1)
38 .intersection(area);
39 VerificationSpinner::new(verb, Duration::from_secs(3), motion).paint(row, buf, theme);
40 }
41 }
42
43 pub(crate) fn entries() -> Vec<Entry> {
44 vec![
45 Entry {
46 name: "verification-pending",
47 width: 40,
48 height: 1,
49 draw: pending,
50 },
51 Entry {
52 name: "verification-earned",
53 width: 40,
54 height: 1,
55 draw: earned,
56 },
57 Entry {
58 name: "verification-modes",
59 width: 40,
60 height: 3,
61 draw: modes,
62 },
63 ]
64 }
65
65 lines RUST