DocumentCarousel

fun DocumentCarousel(modifier: Modifier = Modifier, documentModel: DocumentModel, initialDocumentId: String? = null, allowReordering: Boolean = true, onDocumentClicked: (DocumentInfo) -> Unit = {}, onDocumentFocused: (DocumentInfo) -> Unit = {}, onDocumentReordered: (document: DocumentInfo, oldIndex: Int, newIndex: Int) -> Unit = { _, _, _ -> }, selectedDocumentInfo: @Composable (docInfo: DocumentInfo?, index: Int, total: Int) -> Unit = { _, _, _ -> }, emptyDocumentContent: @Composable () -> Unit = { })

A horizontal carousel composable that displays a collection of documents.

DocumentCarousel provides a highly interactive way to browse, select, and reorder documents. It features a "cover flow" style layout where the center item is elevated, and side items are scaled down.

Features

  • Snap Scrolling: Automatically snaps to the nearest card after dragging.

  • Reordering: Long-press and drag to reorder items (optional).

  • Focus Reporting: Reports which document is currently centered.

  • Custom Overlays: Supports custom views for selected item information and empty states.

Parameters

modifier
documentModel

a DocumentModel with the documents to show a carousel for.

initialDocumentId

the document to initially select.

allowReordering

if true allow the user to reorder documents by long pressing.

onDocumentClicked

action to perform when a document is tapped.

onDocumentFocused

called when a new document is focused.

onDocumentReordered

called when the user has reordered a document, to update the underlying DocumentStore.

selectedDocumentInfo

a composable to draw text underneath the focused document.

emptyDocumentContent

a composable to draw text when there are no documents. This will be rendered in the center of a dashed outline of a grey card .