use crate::steps; pub struct WizardState { pub current_step: usize, pub total_steps: usize, pub visited: Vec, names: Vec, } impl WizardState { pub fn new() -> Self { let names = vec![ "Workflow".into(), "Images".into(), "Resize".into(), "Convert".into(), "Compress".into(), "Metadata".into(), "Output".into(), ]; let total = names.len(); let mut visited = vec![false; total]; visited[0] = true; Self { current_step: 0, total_steps: total, visited, names, } } pub fn step_names(&self) -> Vec { self.names.clone() } pub fn can_go_next(&self) -> bool { self.current_step < self.total_steps - 1 } pub fn can_go_back(&self) -> bool { self.current_step > 0 } pub fn is_last_step(&self) -> bool { self.current_step == self.total_steps - 1 } pub fn go_next(&mut self) { if self.can_go_next() { self.current_step += 1; self.visited[self.current_step] = true; } } pub fn go_back(&mut self) { if self.can_go_back() { self.current_step -= 1; } } } pub fn build_wizard_pages() -> Vec { vec![ steps::step_workflow::build_workflow_page(), steps::step_images::build_images_page(), steps::step_resize::build_resize_page(), steps::step_convert::build_convert_page(), steps::step_compress::build_compress_page(), steps::step_metadata::build_metadata_page(), steps::step_output::build_output_page(), ] }