use eframe::egui; use crate::adapters::filesystem::FilePickerAdapter; use crate::domain::value_objects::FilePath; /// Componente para seleção do arquivo de vídeo base. /// Ao confirmar, dispara LoadMediaInfo via callback. pub struct VideoSelector { pub selected_path: Option, } impl VideoSelector { pub fn new() -> Self { VideoSelector { selected_path: None } } /// Renderiza o seletor. Retorna `Some(FilePath)` se um novo arquivo foi selecionado. pub fn ui(&mut self, ui: &mut egui::Ui) -> Option { let mut selected = None; ui.group(|ui| { ui.heading("Arquivo de vídeo"); ui.horizontal(|ui| { if ui.button("Selecionar…").clicked() { if let Some(path) = FilePickerAdapter::pick_video() { self.selected_path = Some(path.clone()); selected = Some(path); } } let full_path = self .selected_path .as_ref() .map(|p| p.to_string_lossy().to_string()) .unwrap_or_default(); let display = self .selected_path .as_ref() .map(|p| { p.as_path() .file_name() .and_then(|n| n.to_str()) .unwrap_or("—") .to_string() }) .unwrap_or_else(|| "Nenhum arquivo selecionado".to_string()); ui.add(egui::Label::new(&display).truncate(true)) .on_hover_text(if full_path.is_empty() { display } else { full_path }); }); }); selected } }