-
Notifications
You must be signed in to change notification settings - Fork 142
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
keep the "files" example, and use it as a crate
- Loading branch information
Showing
6 changed files
with
18 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
pub mod files; | ||
pub use files::*; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,99 +1,5 @@ | ||
use floem::{ | ||
action::{open_file, save_as}, | ||
file::{FileDialogOptions, FileSpec}, | ||
keyboard::{Key, NamedKey}, | ||
views::{button, h_stack, Decorators}, | ||
IntoView, View, | ||
}; | ||
|
||
fn app_view() -> impl IntoView { | ||
let view = h_stack(( | ||
button("Select file").on_click_cont(|_| { | ||
open_file( | ||
FileDialogOptions::new() | ||
.force_starting_directory("/") | ||
.title("Select file") | ||
.allowed_types(vec![FileSpec { | ||
name: "text", | ||
extensions: &["txt", "rs", "md"], | ||
}]), | ||
move |file_info| { | ||
if let Some(file) = file_info { | ||
println!("Selected file: {:?}", file.path); | ||
} | ||
}, | ||
); | ||
}), | ||
button("Select multiple files").on_click_cont(|_| { | ||
open_file( | ||
FileDialogOptions::new() | ||
.multi_selection() | ||
.title("Select file") | ||
.allowed_types(vec![FileSpec { | ||
name: "text", | ||
extensions: &["txt", "rs", "md"], | ||
}]), | ||
move |file_info| { | ||
if let Some(file) = file_info { | ||
println!("Selected file: {:?}", file.path); | ||
} | ||
}, | ||
); | ||
}), | ||
button("Select folder").on_click_cont(|_| { | ||
open_file( | ||
FileDialogOptions::new() | ||
.select_directories() | ||
.title("Select Folder"), | ||
move |file_info| { | ||
if let Some(file) = file_info { | ||
println!("Selected folder: {:?}", file.path); | ||
} | ||
}, | ||
); | ||
}), | ||
button("Select multiple folder").on_click_cont(|_| { | ||
open_file( | ||
FileDialogOptions::new() | ||
.select_directories() | ||
.multi_selection() | ||
.title("Select multiple Folder"), | ||
move |file_info| { | ||
if let Some(file) = file_info { | ||
println!("Selected folder: {:?}", file.path); | ||
} | ||
}, | ||
); | ||
}), | ||
button("Save file").on_click_cont(|_| { | ||
save_as( | ||
FileDialogOptions::new() | ||
.default_name("floem.file") | ||
.title("Save file"), | ||
move |file_info| { | ||
if let Some(file) = file_info { | ||
println!("Save file to: {:?}", file.path); | ||
} | ||
}, | ||
); | ||
}), | ||
)) | ||
.style(|s| { | ||
s.row_gap(5) | ||
.width_full() | ||
.height_full() | ||
.items_center() | ||
.justify_center() | ||
}); | ||
|
||
let id = view.id(); | ||
view.on_key_up( | ||
Key::Named(NamedKey::F11), | ||
|m| m.is_empty(), | ||
move |_| id.inspect(), | ||
) | ||
} | ||
pub mod files; | ||
|
||
fn main() { | ||
floem::launch(app_view); | ||
floem::launch(files::files_view); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters