use crate::ui::input::Input;
#[derive(Debug, Clone)]
pub enum DialogType {
DirectorySelection,
MatchPatternInput,
ExclusionPatternInput,
RenamingRuleInput,
TemplateSelection {
field: TemplateField,
},
FileSelection,
DirectorySelectionForRemoval,
MatchFileInput,
MatchFileSelection,
}
#[derive(Debug, Clone)]
pub enum TemplateField {
MatchPattern,
ExclusionPattern,
RenamingRule,
}
pub struct Dialog {
pub dialog_type: DialogType,
pub input: Input,
pub selected_files: Vec<usize>,
pub selected_file_index: Option<usize>,
pub selected_template: Option<usize>,
}
impl Dialog {
pub fn new(dialog_type: DialogType, title: impl Into<String>) -> Self {
let selected_template = if matches!(dialog_type, DialogType::TemplateSelection { .. }) {
Some(0) } else {
None
};
let selected_file_index = if matches!(dialog_type, DialogType::FileSelection | DialogType::DirectorySelectionForRemoval | DialogType::MatchFileSelection) {
Some(0) } else {
None
};
Self {
dialog_type,
input: Input::new(title),
selected_files: Vec::new(),
selected_file_index,
selected_template,
}
}
pub fn with_value(dialog_type: DialogType, title: impl Into<String>, value: String) -> Self {
Self {
dialog_type,
input: Input::with_value(title, value),
selected_files: Vec::new(),
selected_file_index: None,
selected_template: None,
}
}
}