Skip to main content

CamoFileUploader

Concept​

1. Why​

A file uploader is a drop zone and a button that start choosing files, with a list showing each file's progress: attachments, imports (Carbon's file uploader, Fluent patterns). Core never touches the filesystem (ADR-27): it reports the user's intent (onPick, onDrop) and the app opens the system picker and runs the upload, feeding progress back.

2. Shape​

Split of duties

CoreSkin (renderer)
the zone's states (idle, drag-over, disabled), onPick on click, Enter and Space, onFilesDropped on desktop and web (the platform's drop target, as a list of names and sizes plus an opaque handle), the file list model, remove and retry actions, semanticsthe zone's look (dashed border, fill, icon, text), the file row (name, size, progress bar, error), the state colors

Material mapping preview: the M3 has none.

  • A dashed outline zone, shapes.medium, surfaceContainerLow; rows with CamoProgressBar.

3. API​

Contract​

data class UploadFile(
val id: Any, val name: String, val sizeBytes: Long? = null,
val progress: Float? = null, // 0..1; null: waiting
val status: UploadStatus = Uploading, // Uploading | Done | Failed(message)
)

fun CamoFileUploader(
files: List<UploadFile>,
onPick: () -> Unit, // open the app's picker
onFilesDropped: ((List<DroppedFile>) -> Unit)? = null, // null: no drop target
onRemove: (UploadFile) -> Unit, onRetry: ((UploadFile) -> Unit)? = null,
hint: String? = null, // "PNG or JPG, up to 5 MB"
enabled: Boolean = true, multiple: Boolean = true,
label: String,
)

State → renderer: UploaderZoneState(dragOver, enabled, interaction) and UploadRowState(status, progress, interaction). Slots: icon, title, hint; the row's name, size, actions. Rows use skin.progressBar for the bar.

Tokens used​

  • colors.surfaceContainerLow, outline, primary (drag-over), error
  • shapes.medium, spacing.l, typography.bodyMedium

Component theme​

theme.components.file uploader. Every field is nullable in the theme. The skin's defaults(theme) fills whatever isn't set (Material defaults shown). See Theme §3.10.

FieldTypeMaterial defaultWhat it's for
zoneShapeShapeshapes.medium
dashedBooleantruethe border style
zoneHeightDp120
iconIconSourceupload
colorsUploaderColors(zone, border, dragBorder, error, text)M3 valuesevery color it uses
stringsUploaderStringsEnglish"Drop files here or", "Remove", "Retry", progress words

Accessibility​

  • The zone is one button ("Upload files, button") with the hint as its description; Enter and Space call onPick.
  • Each file row announces name, size and state ("report.pdf, 45%" with the bar's progress value); remove and retry are buttons. A failure is announced as an alert once.

4. Build steps​

  1. UploadFile, DroppedFile, the drop-target expect/actual (desktop, web; none on mobile), theme, state, renderer, the CamoSkin field.
  2. CamoFileUploader, the DebugSkin renderer.
  3. Tests: pick by click and keys, drop, rows and progress, remove and retry, disabled, semantics.

Done when

  • The upload wizard sample drives it with fake progress.

5. Edge cases​

CaseDecided behavior
CaseDecided behavior
------
Types and sizesThe app validates; Failed(message) shows the reason.
No drop target (mobile)The zone is just the button.
Many filesThe list scrolls inside the parent's constraints.
Changed in the M10 build (2026-11-03)
  • The renderer has two parts, Zone and Row; core builds each row's remove and retry buttons (ghost icon buttons) and the renderer draws the progress with the skin's progress bar. UploaderTheme has zoneShape, dashed, zoneHeight, the zone, remove and retry icons, titleStyle, hintStyle and UploaderColors(zone, border, dragBorder, error, text, mutedText).
  • The app's picker and drop API stay outside core (ADR-27): onPick opens the picker, and dropTarget (Kotlin, a function from DropTargetCallbacks to a Modifier) or dropTargetBuilder (Flutter, a wrapper around the zone) lets the app attach its platform's drop API, reporting through setDragOver and onDropped; onFilesDropped receives DroppedFile(name, sizeBytes, handle). There is no multiple parameter: the app's picker decides.
  • A row announces "1.0 MB, 45%", "Too large" or "Done"; a failed row is an assertive live region. The words ("Remove", "Retry", "Waiting") are English constants, not theme strings.
  • Which drop-target APIs per platform (Compose's dragAndDropTarget, the web drop event, Flutter's desktop drop plugin) are decided in the build; v0.1 may ship drop on desktop and web only.

Implementation​

1. Why​

Compose Multiplatform's dragAndDropTarget (desktop, web) turns drops into DroppedFile (name, size, the platform handle); on Android and iOS only the button.

2. Shape​

3. API​

@Composable public fun CamoFileUploader(files: List<UploadFile>, onPick: () -> Unit, onRemove: (UploadFile) -> Unit,
label: String, modifier: Modifier = Modifier, onFilesDropped: ((List<DroppedFile>) -> Unit)? = null,
onRetry: ((UploadFile) -> Unit)? = null, hint: String? = null, enabled: Boolean = true, multiple: Boolean = true)

4. Build steps​

  1. Zone, drop target, rows, renderer.
  2. Tests: pick, drop (desktop), rows, semantics.

Done when

  • Works by touch, mouse, keyboard and screen reader on all targets.

5. Edge cases​

CaseDecided behavior
Drop on FlutterVia the app's dropTargetBuilder; the example uses none (button only) so core stays plugin-free.
Changed in the M10 build (2026-11-03)
  • The zone is a clickable button with the label as its description; rows merge their content and carry the state as stateDescription.
  • None specific.