CamoTimePicker
Concept
1. Why
Appointments, reminders and delivery slots need a time. Like the date picker (ADR-35), it's a field that opens a picker, with the picker's form chosen by the theme: typed fields (Minimal), a dial (Material) or wheels (Cupertino). Every dialect can draw all three, so the form is a theme choice (ADR-28), not a skin rule.
2. Shape
Material mapping preview: the M3 time picker dial with the hour/minute boxes above it and an AM/PM toggle. See Material Skin.
3. API
Contract
fun CamoTimeField(
value: CamoTime?, // hour + minute, no date or time zone
onValueChange: (CamoTime) -> Unit,
label: String? = null, placeholder: String? = null,
supportingText: String? = null, error: String? = null,
minuteStep: Int = 1, // 5, 15, 30 for slot pickers
use24Hour: Boolean? = null, // null → the device setting
minTime: CamoTime? = null, maxTime: CamoTime? = null,
presentation: PickerPresentation = Auto,
enabled: Boolean = true,
)
// building block (ADR-30): the inline time input
fun CamoTimeInput(value: CamoTime?, onValueChange: (CamoTime) -> Unit, minuteStep: Int = 1, use24Hour: Boolean? = null)
// inside a form: CamoTimeFormField(key, initialValue, rules, …)
use24Hour = nullfollows the device (the user's 12/24-hour setting), so the same app shows "14:30" or "2:30 PM" as the user expects.minuteSteplimits minutes to multiples; a value off the step is shown as is but the picker snaps when changed.- The field's text uses the locale's short time format.
State → renderer: TimePickerState(hour, minute, is24Hour, period: Am | Pm, activePart: Hour | Minute, minuteStep, interaction). Slots: core-built input fields (for Fields), and the confirm buttons when the theme asks for them.
Tokens used
colors.primary(active part, dial hand),primaryContainer(the selected part's box),surfaceContainerHighest(dial face, field boxes),onSurface/onSurfaceVarianttypography.displayMedium(time digits inFieldsandDial),bodyLarge(wheel items)shapes.small,motion.durationShort
Component theme
theme.components.timePicker: TimePickerTheme?. Every field is nullable in the theme. The skin's defaults(theme) fills whatever isn't set (Material defaults shown).
| Field | Type | Material default | What it's for |
|---|---|---|---|
style | Fields | Dial | Wheel | Dial | the picker's form (ADR-28; Minimal Fields, Cupertino Wheel) |
confirmButton | Boolean | true | Cancel/OK buttons (a time has two parts, so it confirms by default) |
digitStyle | CamoTextStyle | displayMedium | the big hour and minute digits |
colors | TimePickerColors(active, activeContainer, face, digits, period) | as in Tokens used | every color it uses |
Accessibility
- The field is announced like a select: "Pickup time, 2:30 PM, pop-up button".
Fields: two adjustable number fields ("Hour, 2", "Minute, 30") and a two-segment period control. Up/Down (keys and screen-reader swipes) change the value by 1 hour or byminuteStep.Dial: the dial is adjustable; screen readers get the same hour/minute adjustable controls asFields(a dial isn't operable by swiping otherwise).Wheel: each wheel is an adjustable control.
4. Build steps
CamoTime, 12/24-hour conversion, step snapping (unit tests).CamoTimeInputwith the three styles,TimePickerRenderer, the DebugSkin renderer (two number fields).CamoTimeField(popup and sheet),CamoTimeFormField.- Sample: a reminder (free time), a pickup slot (
minuteStep = 15,minTime/maxTime), in 12- and 24-hour device settings. - Tests: conversion and snapping; each style changes the value by touch and keyboard; the device setting is followed; announcements.
Done when
- Both samples work in all three styles, both hour formats, on every platform.
5. Edge cases
| Case | Decided behavior |
|---|---|
| Time zones and dates | Not involved: CamoTime is a wall-clock time. Combining with a date is the app's job. |
minTime > maxTime (an overnight window) | Allowed: the valid range wraps past midnight. |
| Seconds | Not in v1. |
- The theme's form is
form(TimePickerForm.Fields | Dial | Wheel); words areTimePickerTheme.strings(TimePickerStrings). - The theme gains
dialTextStyle,wheelTextStyle,wheelItemHeight,fieldSize,dialSize,autoPopupMinWidth,contentPaddingandclockIcon. - The renderer has three parts:
Render(state, slots)lays out core's hour and minute fields, the AM/PM control and the dial or wheels;Dial(DialState)draws the face (labels, an inner 13–23 ring on 24-hour dials, the hand);Wheels. Core maps touches to values (inner ring below 62% of the radius). - With
confirmButton = false, each change insideminTime…maxTimeis reported at once.
Implementation
1. Why
The time picker on kotlinx.datetime.LocalTime, with the device's 12/24-hour setting read through a small expect/actual, and the three styles (Fields, Dial, Wheel) drawn by the skin.
2. Shape
3. API
public typealias CamoTime = kotlinx.datetime.LocalTime
@Composable
public fun CamoTimeField(
value: LocalTime?, onValueChange: (LocalTime) -> Unit, modifier: Modifier = Modifier,
label: String? = null, placeholder: String? = null, supportingText: String? = null, error: String? = null,
minuteStep: Int = 1, use24Hour: Boolean? = null, minTime: LocalTime? = null, maxTime: LocalTime? = null,
presentation: PickerPresentation = PickerPresentation.Auto, enabled: Boolean = true,
)
@Composable public fun CamoTimeInput(value: LocalTime?, onValueChange: (LocalTime) -> Unit, modifier: Modifier = Modifier,
minuteStep: Int = 1, use24Hour: Boolean? = null)
@Composable internal expect fun isSystem24Hour(): Boolean
// android: DateFormat.is24HourFormat(LocalContext.current); ios: the "j" skeleton of NSDateFormatter has no "a";
// jvm: DateTimeFormatterBuilder.getLocalizedDateTimePattern(...) has no "a"; wasmJs: Intl hourCycle is h23/h24
- Fields: two digits-only
BasicTextFields (hour, minute) withsemantics { setProgress { … } }so screen readers adjust them, plus a two-optionCamoSegmentedControlfor AM/PM. - Dial: a
Canvasface with 12 (or 24) positions;pointerInputdrag maps the angle to the value; for screen readers the same two adjustable nodes asFieldsare exposed (the dial itself isclearAndSetSemantics). - Wheel:
LazyColumns with snap fling, each adjustable. - The field text uses
CamoLocaleData.formatShortTime(time, locale, use24Hour).
4. Build steps
isSystem24Houractuals, 12/24 conversion and step snapping (commonTest).- The three styles,
TimePickerTheme/Style, the DebugSkin renderer;CamoTimeField, the form field. - UI tests: each style by touch and keyboard; the device setting; adjustable semantics.
Done when
- The reminder and pickup-slot samples work in all styles and both hour formats on all four targets.
5. Edge cases
| Case | Decided behavior |
|---|---|
| The 24-hour setting changes while open (Android) | Read on each open; the open picker keeps its format. |
| Overnight windows | minTime > maxTime wraps past midnight (base). |