Skip to main content

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 = null follows the device (the user's 12/24-hour setting), so the same app shows "14:30" or "2:30 PM" as the user expects.
  • minuteStep limits 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 / onSurfaceVariant
  • typography.displayMedium (time digits in Fields and Dial), 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).

FieldTypeMaterial defaultWhat it's for
styleFields | Dial | WheelDialthe picker's form (ADR-28; Minimal Fields, Cupertino Wheel)
confirmButtonBooleantrueCancel/OK buttons (a time has two parts, so it confirms by default)
digitStyleCamoTextStyledisplayMediumthe big hour and minute digits
colorsTimePickerColors(active, activeContainer, face, digits, period)as in Tokens usedevery 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 by minuteStep.
  • Dial: the dial is adjustable; screen readers get the same hour/minute adjustable controls as Fields (a dial isn't operable by swiping otherwise).
  • Wheel: each wheel is an adjustable control.

4. Build steps​

  1. CamoTime, 12/24-hour conversion, step snapping (unit tests).
  2. CamoTimeInput with the three styles, TimePickerRenderer, the DebugSkin renderer (two number fields).
  3. CamoTimeField (popup and sheet), CamoTimeFormField.
  4. Sample: a reminder (free time), a pickup slot (minuteStep = 15, minTime/maxTime), in 12- and 24-hour device settings.
  5. 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​

CaseDecided behavior
Time zones and datesNot 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.
SecondsNot in v1.
Changed in the M5 build (2026-10-28)
  • The theme's form is form (TimePickerForm.Fields | Dial | Wheel); words are TimePickerTheme.strings (TimePickerStrings).
  • The theme gains dialTextStyle, wheelTextStyle, wheelItemHeight, fieldSize, dialSize, autoPopupMinWidth, contentPadding and clockIcon.
  • 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 inside minTime…maxTime is 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) with semantics { setProgress { … } } so screen readers adjust them, plus a two-option CamoSegmentedControl for AM/PM.
  • Dial: a Canvas face with 12 (or 24) positions; pointerInput drag maps the angle to the value; for screen readers the same two adjustable nodes as Fields are exposed (the dial itself is clearAndSetSemantics).
  • Wheel: LazyColumns with snap fling, each adjustable.
  • The field text uses CamoLocaleData.formatShortTime(time, locale, use24Hour).

4. Build steps​

  1. isSystem24Hour actuals, 12/24 conversion and step snapping (commonTest).
  2. The three styles, TimePickerTheme / Style, the DebugSkin renderer; CamoTimeField, the form field.
  3. 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​

CaseDecided behavior
The 24-hour setting changes while open (Android)Read on each open; the open picker keeps its format.
Overnight windowsminTime > maxTime wraps past midnight (base).