pub fn progress<M>() -> Progress<M>Expand description
A progress bar.
Examples found in repository?
examples/progress.rs (line 81)
40fn view(build: &Build) -> View {
41 let fraction = build.done as f64 / STEPS.len() as f64;
42 let running = build.took.is_none();
43 let activity: ui::Node = if running {
44 ui::spinner()
45 .style("dots")
46 .label(STEPS[build.done.min(STEPS.len() - 1)])
47 .into()
48 } else {
49 ui::icon(if build.status == Status::Done {
50 "check"
51 } else {
52 "x"
53 })
54 .tone(if build.status == Status::Done {
55 "success"
56 } else {
57 "error"
58 })
59 .into()
60 };
61 let mut timer = ui::elapsed().age(0);
62 if let Some(took) = build.took {
63 timer = timer.stopped(took);
64 }
65 View::new().main([ui::card()
66 .key("build")
67 .head("Building demo")
68 .status(build.status.clone())
69 .child(
70 ui::row()
71 .key("head")
72 .gap("sm")
73 .children(nodes![activity.key("a"), timer.key("t")]),
74 )
75 .child(
76 ui::ansi(&build.log)
77 .key("log")
78 .follow(true)
79 .max(Bound::h(Extent::Lines(8.0))),
80 )
81 .child(ui::progress().key("bar").value(fraction).label(format!(
82 "{}/{}",
83 build.done,
84 STEPS.len()
85 )))])
86}