use cli_animate::interactive_menu::{InteractiveMenu, StyleBuilder as InteractiveMenuStyleBuilder};
use cli_animate::loading_indicator::LoadingIndicator;
use cli_animate::progress::{ProgressBar, StyleBuilder as ProgressBarStyleBuilder};
use cli_animate::utils::Color;
use std::sync::{Arc, Mutex};
use std::{thread, time};
fn main() {
let progress_value = Arc::new(Mutex::new(0));
let thread_progress_value = progress_value.clone();
let do_some_work = thread::spawn(move || {
let mut num = 0;
while num <= 100 {
thread::sleep(time::Duration::from_millis(20));
let mut val = thread_progress_value.lock().unwrap();
*val = num;
num += 1;
}
});
let style = ProgressBarStyleBuilder::new() .color(Color::Green)
.bar_length(60)
.build();
let progress_bar = ProgressBar::new(0, 100, move || *progress_value.lock().unwrap(), style);
let mut writer = std::io::stdout();
progress_bar.start(&mut writer);
do_some_work.join().unwrap();
let options = vec![
"Tokyo".to_string(),
"Saitama".to_string(),
"Kanagawa".to_string(),
];
let mut menu = InteractiveMenu::new(
options.clone(),
InteractiveMenuStyleBuilder::new() .color(Color::Blue)
.selected_prefix('*')
.build(),
);
let selected_index = menu.run().unwrap();
println!("You selected: {}", options[selected_index]);
let loading_indicator = LoadingIndicator::new(Color::Red);
loading_indicator.start();
let mut num = 0;
while num <= 100 {
thread::sleep(time::Duration::from_millis(20));
num += 1;
}
loading_indicator.stop();
}