-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
117 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Iced File Tree | ||
|
||
[![Crates.io](https://img.shields.io/crates/v/iced_file_tree.svg)](https://crates.io/crates/iced_file_tree) | ||
[![Documentation](https://docs.rs/iced_file_tree/badge.svg)](https://docs.rs/iced_file_tree) | ||
[![Iced](https://img.shields.io/badge/0.13-blue.svg?logo=iced)](https://github.com/iced-rs/iced/tree/master) | ||
[![License](https://img.shields.io/crates/l/iced_file_tree.svg)](https://github.com/edwloef/iced-file-tree/blob/master/LICENSE) | ||
|
||
A lightweight file tree widget for the [iced](https://github.com/iced-rs/iced/tree/master) toolkit. | ||
|
||
## Usage | ||
|
||
Include `iced_file_tree` as a dependency in your `Cargo.toml`: | ||
|
||
```toml | ||
[dependencies] | ||
iced = "0.13.1" | ||
iced_file_tree = "0.1.0" | ||
``` | ||
|
||
The `FileTree` widget is recommended to be put in an iced [`Scrollable`](https://docs.rs/iced/latest/iced/widget/scrollable/). |
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 @@ | ||
format_code_in_doc_comments = true |
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 |
---|---|---|
@@ -1,6 +1,41 @@ | ||
//! A lightweight file tree widget for the [iced](https://github.com/iced-rs/iced/tree/master) toolkit. | ||
//! | ||
//! # Example | ||
//! ```no_run | ||
//! use iced::widget::scrollable; | ||
//! use iced_file_tree::file_tree; | ||
//! | ||
//! enum Message { | ||
//! FileTreeMessage(PathBuf), | ||
//! // ... | ||
//! } | ||
//! | ||
//! fn view(state: &State) -> Element<'_, Message> { | ||
//! let path: PathBuf = /* */ | ||
//! | ||
//! scrollable( | ||
//! file_tree(path) | ||
//! .unwrap() | ||
//! .on_double_click(Message::FileTreeMessage), | ||
//! ) | ||
//! .into() | ||
//! } | ||
//! ``` | ||
mod errentry; | ||
mod file; | ||
mod folder; | ||
|
||
#[doc(inline)] | ||
pub use folder::Folder as FileTree; | ||
|
||
use std::path::PathBuf; | ||
|
||
/// Creates a new [`FileTree`] with the root at the given path. | ||
#[must_use] | ||
pub fn file_tree<'a, Message>(path: PathBuf) -> Option<FileTree<'a, Message>> | ||
where | ||
Message: Clone + 'a, | ||
{ | ||
FileTree::<'a, Message>::new(path) | ||
} |