diff --git a/src/ui_app.rs b/src/ui_app.rs index 6620b9a..37b8ca2 100644 --- a/src/ui_app.rs +++ b/src/ui_app.rs @@ -1,10 +1,10 @@ -use eframe::egui; -use std::path::PathBuf; -use rfd::FileDialog; use crate::dispatcher::Dispatcher; +use eframe::egui; +use rfd::FileDialog; +use std::path::PathBuf; pub struct UIApp { - picked_file: Option, + picked_file: Option, addresses: Vec, } @@ -21,7 +21,6 @@ impl eframe::App for UIApp { fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) { if self.addresses.is_empty() { self.addresses.push("localhost:3000".to_owned()); - } egui::CentralPanel::default().show(ctx, |ui| { let mut to_remove = Vec::new(); @@ -31,9 +30,11 @@ impl eframe::App for UIApp { ui.text_edit_singleline(address); if ui.button("Play sound").clicked() { if let Some(path) = &self.picked_file { - Dispatcher::handle_dispatch_sample(vec![address.clone()], path.to_str().unwrap().to_owned()); - - } + Dispatcher::handle_dispatch_sample( + vec![address.clone()], + path.to_str().unwrap().to_owned(), + ); + } } if ui.button("Remove").clicked() { to_remove.push(i); @@ -50,23 +51,25 @@ impl eframe::App for UIApp { ui.separator(); ui.add_space(25.0); - if ui.button("Pick file").clicked() { + if ui.button("Pick file").clicked() { let file = FileDialog::new().pick_file(); if !file.is_none() { self.picked_file = file; } } - + ui.label(format!("Picked file: {:?}", self.picked_file)); ui.add_space(25.0); ui.separator(); - ui.add_space(25.0); + ui.add_space(25.0); if ui.button("Play sound").clicked() { if let Some(path) = &self.picked_file { - Dispatcher::handle_dispatch_sample(self.addresses.clone(), path.to_str().unwrap().to_owned()); - + Dispatcher::handle_dispatch_sample( + self.addresses.clone(), + path.to_str().unwrap().to_owned(), + ); } } });