CamoListItem
Concept
1. Why
List rows are the backbone of settings screens, menus, pickers, contacts and search results. CamoListItem is one row with three text lines at most, a leading widget and a trailing widget. CamoListSection groups rows under a header, which is how Apple's grouped lists and Material's list headers look. Menus, selects and pickers reuse it, so it comes early in M6.
2. Shape
Material mapping preview: M3 lists.
- Heights: one line 56, two lines 72, three lines 88.
- Headline
bodyLarge,onSurface. Supporting textbodyMedium,onSurfaceVariant. OverlinelabelSmall. - Leading icons 24 in
onSurfaceVariant, and leading avatars 40.
3. API
Contract
fun CamoListItem(
headline: String,
supporting: String? = null,
overline: String? = null,
leading: Widget? = null, // icon, CamoAvatar, image, or a display-only CamoCheckbox/CamoRadio
trailing: Widget? = null, // icon, meta text, CamoSwitch/CamoCheckbox (display-only), chevron
onClick: (() -> Unit)? = null, // null → not interactive
selected: Boolean = false, // highlights the row (navigation lists, pickers)
enabled: Boolean = true,
)
fun CamoListSection(
title: String? = null,
footer: String? = null,
level: SurfaceLevel = Surface, // the section's fill only; inset or edge-to-edge is the skin's choice
content: Slot, // CamoListItems; dividers between rows come from ListItemTheme.dividers
)
Rows with controls (a settings row with a switch): make the row the control. Pass the switch display-only (CamoSwitch(checked, onCheckedChange = null)) as trailing, and onClick = { toggle() }. Core merges them, so the whole row toggles and is announced as a switch. (It's the same pattern as the labelled CamoSwitch, which is shorter when the row is just a label and a switch.)
State → renderer: ListItemState(headline, supporting?, overline?, lines, clickable, selected, enabled, interaction). Slots: ListItemSlots(leading?, trailing?).
Tokens used
colors.onSurface,onSurfaceVariant,secondaryContainer(selected), andsurface*levels for sectionstypography.bodyLarge,bodyMedium,labelSmall,titleSmall(section title)spacing.lhorizontal padding,spacing.lbetween leading and text
Component theme
theme.components.listItem: ListItemTheme?. 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 |
|---|---|---|---|
minHeightOneLine / TwoLines / ThreeLines | Dp | 56 / 72 / 88 | row heights |
contentPadding | Padding | horizontal 16, vertical 8 | row padding |
leadingGap / trailingGap | Dp | 16 / 16 | spacing around the text |
headlineStyle / supportingStyle / overlineStyle | CamoTextStyle | bodyLarge / bodyMedium / labelSmall | texts |
iconSize | Dp | 24 | the ambient icon style for leading and trailing icons |
sectionShape | Shape | shapes.none (Material) | Apple dialect: shapes.medium for inset grouped sections |
dividers | ListDividers (None | Full | Inset) | None (Material) | dividers CamoListSection draws between its rows (ADR-28: a brand-wide choice). Inset starts after the leading slot. Minimal and Cupertino: Inset. |
colors | ListItemColors(headline, supporting, overline, icon, selectedContainer) | onSurface, onSurfaceVariant, onSurfaceVariant, onSurfaceVariant, secondaryContainer | every color it uses |
Accessibility
- A clickable row is one merged element (headline, supporting text, trailing state), with role button, or switch/checkbox when the trailing control is the row's toggle.
- A non-clickable row keeps its children's semantics.
selectedis announced ("selected").- The section title is a heading.
4. Build steps
CamoListItem(line count → min height, clickable whenonClick != null, merged semantics, a toggle role when the trailing is a display-only control).CamoListSection(title as a heading, footer, level background, dividers between rows fromListItemTheme.dividers).ListItemRenderer,ListSectionRenderer, and the DebugSkin renderers.- Sample: a settings screen (sections, switches, chevrons), a contacts list (avatars), a search results list.
- Tests:
- line counts produce the right heights;
- a switch row toggles from anywhere and is announced as a switch;
- a non-clickable row isn't focusable;
- the section title is a heading.
Done when
- The settings sample reads like a native settings screen on Android and iOS (under the Minimal skin; the Cupertino skin later gives it iOS inset-grouped structure).
5. Edge cases
| Case | Decided behavior |
|---|---|
| Long headline at 200% font scale | The text wraps. Rows grow past their min height, and leading/trailing align to the first line. |
A trailing control that is itself interactive (a real CamoSwitch with a callback) inside a clickable row | Discouraged (two targets). A debug warning suggests the display-only pattern. |
| Swipe actions (swipe to delete) | Not in v1. |
| Dividers in a section | Drawn by CamoListSection between rows, never after the last one. A hand-placed CamoDivider still works for one-off separators. Rows in a plain lazy list (no section) get no automatic dividers. |
| Very long lists | The app uses the platform's lazy lists (LazyColumn, ListView.builder). CamoListItem is a plain row, so it works in them. |
- One renderer draws rows and sections:
ListItemRendererhas aRenderpart (a row) and aSectionpart (title, rows, footer), not a separateskin.listSection. Core lays the section's rows out with the dividers and hands them over as one slot. ListItemThemegainssectionTitleStyle,sectionFooterStyleanddividerInsetStart;ListItemColorsgainssectionTitleandsectionFooter.- A display-only switch, checkbox or radio in a clickable row reports itself to the row, which is then announced as that control with its state ("Wi-Fi, switch, on") instead of a button.
- The debug warning for an interactive trailing control isn't built yet.
Implementation
1. Why
A row with three text lines, a leading and a trailing slot, optional click and selection. The Kotlin specifics are the conditional behavior modifier (like CamoCard), aligning leading and trailing to the first text line when the row grows, and CamoListSection drawing dividers between its rows (ListItemTheme.dividers) with a custom Layout.
2. Shape
3. API
@Composable
public fun CamoListItem(
headline: String,
modifier: Modifier = Modifier,
supporting: String? = null,
overline: String? = null,
leading: (@Composable () -> Unit)? = null,
trailing: (@Composable () -> Unit)? = null,
onClick: (() -> Unit)? = null,
selected: Boolean = false,
enabled: Boolean = true,
interactionSource: MutableInteractionSource? = null,
)
@Composable
public fun CamoListSection(
modifier: Modifier = Modifier,
title: String? = null,
footer: String? = null,
level: SurfaceLevel = SurfaceLevel.Surface,
content: @Composable () -> Unit,
)
- Behavior: with
onClick,clickable(role = Role.Button)+semantics(mergeDescendants = true); withselected = true,semantics { selected = true }; withoutonClick, no role and no focus stop. - Slot alignment: the renderer lays out
leading | texts | trailingin aRow; for one- and two-line rows the slots are centered vertically, for three lines they align to the top of the first text line (Alignment.Top+ a padding equal to the overline height). - Display-only controls in
trailing:CamoSwitch(checked, onCheckedChange = null)has no semantics of its own, so the merged row announces "Wi-Fi, on". Core reads the trailing control's state through aCamoToggleInfosemantics key and appends it to the row'sstateDescription. - Section dividers:
CamoListSectionuses aLayoutthat measures its children, places them in a column, and draws a line between consecutive children indrawWithContent.Insetstarts after the leading slot width (read fromstyle.dividerInsetStart),Fullspans the width,Nonedraws nothing. The sectiontitleis a heading (semantics { heading() }).
4. Build steps
ListItemTheme/Style(includingdividers,sectionShape),CamoListItem,CamoListSection, the DebugSkin renderers.- The settings sample: sections with switches (display-only trailing), a chevron row, a selected row in a picker.
commonTest: no role withoutonClick; the merged announcement includes the trailing switch state; dividers appear between rows and not after the last;Insetstarts after the leading slot; RTL mirrors.
Done when
- The settings sample matches the Minimal skin table in light and dark, and TalkBack/VoiceOver read each row as one element.
5. Edge cases
| Case | Decided behavior |
|---|---|
| A real interactive trailing control inside a clickable row | Two targets. A debug warning suggests onCheckedChange = null on the control. |
Items inside a LazyColumn (no section) | Plain rows; dividers only via CamoPagedList or a hand-placed CamoDivider. |
| Very long headline at 200% | Wraps; the slots keep their alignment rule. |
- The trailing control reports through a composition local (
RowToggle), not aCamoToggleInfosemantics key:CamoSwitch,CamoCheckboxandCamoRadioreport their role and state on the display-only path, and the row sets its role from it. Dividers are drawn by a sharedDividedColumnlayout.