feat: add native dialog

This commit is contained in:
2021-05-01 12:31:13 +08:00
parent 813a7d5b2f
commit ba796dd652
3 changed files with 388 additions and 0 deletions

View File

@@ -0,0 +1,26 @@
use native_dialog::{FileDialog, MessageDialog, MessageType};
fn main() {
let path = FileDialog::new()
.set_location("~/Desktop")
.add_filter("PNG Image", &["png"])
.add_filter("JPEG Image", &["jpg", "jpeg"])
.show_open_single_file()
.unwrap();
let path = match path {
Some(path) => path,
None => return,
};
let yes = MessageDialog::new()
.set_type(MessageType::Info)
.set_title("Do you want to open the file?")
.set_text(&format!("{:#?}", path))
.show_confirm()
.unwrap();
if yes {
println!("{:?}", path);
}
}