68 lines
2.0 KiB
Rust
68 lines
2.0 KiB
Rust
use crate::app::AppState;
|
|
use crate::steps;
|
|
|
|
pub struct WizardState {
|
|
pub current_step: usize,
|
|
pub total_steps: usize,
|
|
pub visited: Vec<bool>,
|
|
names: Vec<String>,
|
|
}
|
|
|
|
impl WizardState {
|
|
pub fn new() -> Self {
|
|
let names = vec![
|
|
"Workflow".into(),
|
|
"Images".into(),
|
|
"Resize".into(),
|
|
"Adjustments".into(),
|
|
"Convert".into(),
|
|
"Compress".into(),
|
|
"Metadata".into(),
|
|
"Watermark".into(),
|
|
"Rename".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<String> {
|
|
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 build_wizard_pages(state: &AppState) -> Vec<adw::NavigationPage> {
|
|
vec![
|
|
steps::step_workflow::build_workflow_page(state), // 0: Workflow
|
|
steps::step_images::build_images_page(state), // 1: Images
|
|
steps::step_resize::build_resize_page(state), // 2: Resize
|
|
steps::step_adjustments::build_adjustments_page(state),// 3: Adjustments
|
|
steps::step_convert::build_convert_page(state), // 4: Convert
|
|
steps::step_compress::build_compress_page(state), // 5: Compress
|
|
steps::step_metadata::build_metadata_page(state), // 6: Metadata
|
|
steps::step_watermark::build_watermark_page(state), // 7: Watermark
|
|
steps::step_rename::build_rename_page(state), // 8: Rename
|
|
steps::step_output::build_output_page(state), // 9: Output
|
|
]
|
|
}
|