FileUploadList

fun FileUploadList(files: ImmutableList<UploadedFile>, onClearFile: (UploadedFile) -> Unit, modifier: Modifier = Modifier, onClick: (UploadedFile) -> Unit? = null, clearIcon: SparkIcon = LeboncoinIcons.Cross)(source)

Default preview implementation that displays uploaded files in a list.

This function provides a standard preview layout that:

  • Shows each file with its icon, name, and size.

  • Displays progress bars during upload.

  • Shows error messages with a red border and warning icon.

  • Disables the clear button during upload (when progress is active).

Parameters

files

List of uploaded files to display.

onClearFile

Callback invoked when a file should be removed.

modifier

Modifier to be applied to the preview container.

onClick

Optional callback invoked when a file preview is clicked. Receives the clicked file.

clearIcon

Icon to use for the clear button. Defaults to LeboncoinIcons.Cross.

Samples

var selectedFiles by remember {
    mutableStateOf<ImmutableSet<UploadedFile>>(persistentSetOf())
}

Column(modifier = Modifier.fillMaxWidth()) {
    FileUpload.Button(
        onResult = { files ->
            selectedFiles = selectedFiles.plus(files).toImmutableSet()
        },
        label = "Add files",
        modifier = Modifier.fillMaxWidth(),
    )

    VerticalSpacer(16.dp)

    if (selectedFiles.isNotEmpty()) {
        FileUploadList(
            files = selectedFiles.toImmutableList(),
            onClearFile = { file ->
                selectedFiles = selectedFiles.filterNot { it == file }.toImmutableSet()
            },
            onClick = { file -> FileUploadDefaults.openFile(file) },
        )
    }
}