CamoProgress
Concept
1. Why
Progress indicators show that work is happening: determinate when the fraction is known (an upload at 40%), indeterminate when it isn't (loading). There are two shapes, a bar and a circle. Every system has both, so Camouflage gives both, with tone support (a red failing upload).
2. Shape
Material mapping preview: M3 progress indicators (2024 update).
- Bar: 4 dp track, with an active
primarypart and a gap before thesecondaryContainertrack, plus a stop dot at the end. - Circle: 48 diameter, stroke 4.
(The M3 Expressive "wavy" style is a skin option, MaterialSkin(expressiveProgress = true), Later.)
3. API
Contract
fun CamoProgressBar(
progress: Float? = null, // null = indeterminate; 0f..1f = determinate
tone: Tone = Default,
label: String? = null, // accessible name ("Uploading photo")
)
fun CamoProgressCircle(
progress: Float? = null,
tone: Tone = Default,
size: ProgressSize = Medium, // Small 24 | Medium 48 | Large 64
label: String? = null,
)
State → renderer: ProgressState(progress?, tone). Slots: none.
Tokens used
- the tone's strong color (active part),
secondaryContainer/ the tone's container (track) motion.durationLong+easingStandardfor indeterminate cycles, anddurationMediumfor determinate changes
Component theme
theme.components.progress: ProgressTheme?. Every field is nullable in the theme. The skin's defaults(theme) fills whatever isn't set (Material defaults shown). See Theme §3.10.
| Field | Type | Material default | What it's for |
|---|---|---|---|
barHeight | Dp | 4 | bar thickness |
circleStroke | Dp | 4 | circle stroke |
circleSizeSmall / Medium / Large | Dp | 24 / 48 / 64 | circle sizes |
trackGap | Dp | 4 | the gap between active and track (M3 2024 look) |
showStopIndicator | Boolean | true | end dot on determinate bars |
colors | ProgressColors(active, track) | the tone's strong, secondaryContainer | colors for tone = Default |
Accessibility
- A progress bar role with name =
label, and value = percentage (determinate) or "in progress" (indeterminate). - Determinate value changes are not announced continuously. Apps announce milestones ("Upload complete").
- Reduced motion: indeterminate indicators switch to a slow opacity pulse instead of sweeping movement.
4. Build steps
CamoProgressBar,CamoProgressCircle, and their renderers (indeterminate animations driven by motion tokens).- Tests:
- determinate draws the fraction;
nullanimates;- reduced motion uses the pulse;
- the semantics value;
- tone colors.
Done when
- Upload (determinate bar), page loading (indeterminate circle), and a failed upload (
tone = Error) render on every platform, with and without reduced motion.
5. Edge cases
| Case | Decided behavior |
|---|---|
progress outside 0..1 | Clamped. |
| Switching from indeterminate to determinate | Animates from the current sweep position to the value. |
| RTL | Bars fill from the right. |
| A loading button | CamoButton(loading = true): the button draws a small CamoProgressCircle itself and keeps its width (see CamoButton §5). |
ProgressThemegainsbarHeight,trackGapandshowStopIndicator; the bar has its own renderer (progressBar), whosedefaultsreturn the same style as the circle's.ProgressStyle.colorsFor(tone, theme): the style's colors for the default tone, the tone's strong color over the same track otherwise.- A bar fills the width it's given; only an indeterminate one animates forever.
- Minimal: 2 px ink on a hairline track, no gap or stop dot. Fluent: its 2 px ProgressBar.
Implementation
1. Why
Bars and circles, determinate or indeterminate, drawn on a Canvas (Material's indicators aren't a v1 dependency). The Kotlin points: an infinite transition for indeterminate motion, the reduced-motion pulse, and progressSemantics.
2. Shape
3. API
@Composable public fun CamoProgressBar(modifier: Modifier = Modifier, progress: Float? = null, tone: Tone = Tone.Default, label: String? = null)
@Composable public fun CamoProgressCircle(modifier: Modifier = Modifier, progress: Float? = null, tone: Tone = Tone.Default,
size: ProgressSize = ProgressSize.Medium, label: String? = null)
- Semantics:
Modifier.progressSemantics(value = progress.coerceIn(0f, 1f))for determinate,progressSemantics()for indeterminate, pluscontentDescription = label. - Determinate changes animate with
animateFloatAsState(progress, tween(theme.motion.durationMedium)). - Indeterminate:
rememberInfiniteTransition()drives the sweep (circle: rotation + arc length; bar: a moving segment) withtheme.motion.durationLong-based cycles. When the provider's motion is reduced, the renderer switches to a slow alpha pulse (animateFloat(0.4f → 1f)) instead of movement. - Drawing uses
drawArc/drawLinewithStrokeCap.Roundper the style; the bar respects RTL by flipping withscale(-1f, 1f)whenLocalLayoutDirectionis RTL.
4. Build steps
ProgressTheme/Style, both composables, the DebugSkin renderers.commonTest: determinate draws the fraction (screenshot);nullanimates; reduced motion pulses; semantics range info; clamping.
Done when
- Upload, page loading and a failed upload (Error tone) render on all targets, with and without reduced motion.
5. Edge cases
| Case | Decided behavior |
|---|---|
| Many indeterminate indicators on screen | Each has its own transition; acceptable (they're rarely many). Skeletons, which are, share one clock. |
| Loading buttons | CamoButton(loading = true) uses CamoProgressCircle(size = Small) internally. |
CamoProgressBar(modifier, progress, tone, label)withprogressSemantics, like the circle; the skin field isprogressBar: ProgressBarRenderer.