pub struct FileBrowser { /* private fields */ }Expand description
An explorer of folders and files: a breadcrumb that goes back, a header that sorts, and a
list of any length with icon, name, size and date. The entries are data from the app, which
answers on_navigate and on_open with another
folder; it never touches the file system, so it serves a backup on a server as well as a disk.
A click selects alone, Ctrl or Cmd adds, and Shift takes a range. The arrows, Home and End
move, Space adds, Enter opens, and Backspace goes up.
use ravenrs_widgets::{FileBrowser, FileEntry, Ui};
let browser = FileBrowser::new(
["Backups", "2026"],
vec![FileEntry::folder("October"), FileEntry::file("notes.txt", 2048)],
)
.on_open(|entry| println!("{}", entry.name))
.on_navigate(|depth| println!("{depth}"));
let mut ui = Ui::new(browser, ravenrs_style::Theme::raven_dark());
ui.update();Implementations§
Source§impl FileBrowser
impl FileBrowser
Sourcepub fn new(
path: impl IntoIterator<Item = impl Into<String>>,
entries: impl Into<Rc<[FileEntry]>>,
) -> Self
pub fn new( path: impl IntoIterator<Item = impl Into<String>>, entries: impl Into<Rc<[FileEntry]>>, ) -> Self
The folder at path, from the root, with entries inside it. Keep the entries in an
Rc between builds when they are many: they are sorted again only when they are not the
same ones.
Sourcepub fn selection(self, selection: Binding<BTreeSet<String>>) -> Self
pub fn selection(self, selection: Binding<BTreeSet<String>>) -> Self
The ids of the selected entries, to read and to change from outside.
Sourcepub fn mode(self, mode: SelectionMode) -> Self
pub fn mode(self, mode: SelectionMode) -> Self
How entries can be selected (SelectionMode::Multiple by default).
Called with the depth of the place to go back to, 0 being the root.
Sourcepub fn on_open(self, handler: impl Fn(&FileEntry) + 'static) -> Self
pub fn on_open(self, handler: impl Fn(&FileEntry) + 'static) -> Self
Called with an entry on a double click or on Enter.
Trait Implementations§
Source§impl Debug for FileBrowser
impl Debug for FileBrowser
Auto Trait Implementations§
impl !RefUnwindSafe for FileBrowser
impl !Send for FileBrowser
impl !Sync for FileBrowser
impl !UnwindSafe for FileBrowser
impl Freeze for FileBrowser
impl Unpin for FileBrowser
impl UnsafeUnpin for FileBrowser
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<T> ErasedDestructor for Twhere
T: 'static,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<V> ViewExt for Vwhere
V: View,
impl<V> ViewExt for Vwhere
V: View,
Source§fn padding(self, padding: impl Into<Insets>) -> Styled<Self>
fn padding(self, padding: impl Into<Insets>) -> Styled<Self>
Source§fn background(self, fill: impl Into<Fill>) -> Styled<Self>
fn background(self, fill: impl Into<Fill>) -> Styled<Self>
Source§fn frame(self, width: Option<f32>, height: Option<f32>) -> Styled<Self>
fn frame(self, width: Option<f32>, height: Option<f32>) -> Styled<Self>
None keeps the content size.