Components / controls
UploadList builder
A list of files being uploaded, optionally over the zone that took them.
A builder is RenderOnce. Construct and mount it in one expression.
use gpui_kit::controls::upload_list::UploadList;
Reviewed in upload-list.
Construct
new(ident: impl Into<Ident>) -> Self
Options
Chain onto the value.
upload(upload: Upload) -> Self
uploads(uploads: impl IntoIterator<Item = Upload>) -> Self
dropzone(zone: impl Into<EffectScoped<Dropzone>>) -> Self
show_overall(show: bool) -> Self
on_retry(handler: impl Fn(SharedString, &mut Window, &mut App) + 'static) -> Self
on_cancel(handler: impl Fn(SharedString, &mut Window, &mut App) + 'static) -> Self
on_remove(handler: impl Fn(SharedString, &mut Window, &mut App) + 'static) -> Self
Queries
Only answer; they change nothing.
overall() -> OverallProgress
Example · upload-list
fn upload_list(_window: &mut Window, cx: &mut App) -> AnyElement {
let theme = cx.theme().clone();
stack(&theme)
.w(px(560.0))
.child(caption(
&theme,
"a refusal is not a failure, and only a failure is offered a retry",
))
.child(
UploadList::new("scene.uploads")
.dropzone(
Dropzone::new("scene.uploads.zone", "Drop files to attach")
.hint("PDF, PNG, or plain text")
.on_files(|_, _, _| {}),
)
.uploads([
Upload::new("brief", "brief.pdf").size("1.2 MB").done(),
Upload::new("capture", "capture.png")
.size("4.8 MB")
.uploading(0.4),
Upload::new("notes", "notes.txt").size("12 KB"),
Upload::new("archive", "archive.zip")
.size("240 MB")
.failed("The connection dropped."),
Upload::new("installer", "installer.exe")
.size("64 MB")
.refused("This zone does not take programs."),
])
.on_retry(|_, _, _| {})
.on_cancel(|_, _, _| {})
.on_remove(|_, _, _| {}),
)
.into_any_element()
}