Skip to content

WheelPicker ​

A drum/wheel selector: a scrolling list with snap-to-center fling where the centered row is full-opacity while neighbours fade and shrink. Use the single-column form for a short list, or the multi-column form for compound values such as hour / minute / second.

Import ​

kotlin
import io.github.heartcoolman.prism.ui.PrismWheelPicker
import io.github.heartcoolman.prism.ui.PrismWheelColumn
import io.github.heartcoolman.prism.ui.PrismWheelOption

Basic usage (single column) ​

kotlin
var index by remember { mutableStateOf(1) }

PrismWheelPicker(
    options = listOf("Sun", "Mon", "Tue", "Wed", "Thu"),
    selectedIndex = index,
    onSelectedChange = { index = it },
)

Multi-column ​

Pass columns to render several wheels side by side. onChange reports (columnIndex, value), where value is the stable PrismWheelOption.value.

kotlin
var hour by remember { mutableStateOf("09") }
var minute by remember { mutableStateOf("30") }

PrismWheelPicker(
    columns = listOf(
        PrismWheelColumn(
            options = (0..23).map { PrismWheelOption(label = "%02d".format(it), value = "%02d".format(it)) },
            value = hour,
        ),
        PrismWheelColumn(
            options = (0..59).map { PrismWheelOption(label = "%02d".format(it), value = "%02d".format(it)) },
            value = minute,
        ),
    ),
    onChange = { columnIndex, value ->
        if (columnIndex == 0) hour = value else minute = value
    },
)

Sizing ​

visibleCount (forced odd) sets how many rows are shown, and itemHeight sets each row's height.

kotlin
PrismWheelPicker(
    options = options,
    selectedIndex = index,
    onSelectedChange = { index = it },
    visibleCount = 7,
    itemHeight = 40.dp,
)

API ​

PrismWheelPicker (single column) ​

ParameterTypeDefaultDescription
optionsList<String>—Row labels, in order.
selectedIndexInt—Index of the centered option (controlled).
onSelectedChange(Int) -> Unit—Fired when the wheel settles on or a row is tapped.
modifierModifierModifierModifier applied to the column.
visibleCountInt5Number of rows shown; coerced to an odd value.
itemHeightDp36.dpHeight of each row.

PrismWheelPicker (multi-column) ​

ParameterTypeDefaultDescription
columnsList<PrismWheelColumn>—One or more wheels, side by side.
onChange(columnIndex: Int, value: String) -> Unit—Fired with the column index and newly selected value.
modifierModifierModifierModifier applied to the row of columns.
visibleCountInt5Number of rows per column; coerced to an odd value.
itemHeightDp36.dpHeight of each row.

PrismWheelColumn ​

FieldTypeDescription
optionsList<PrismWheelOption>Ordered options shown in this column.
valueStringCurrently selected option value.

PrismWheelOption ​

FieldTypeDescription
labelStringVisible row text.
valueStringStable value matched against the column's value.

Assumes an enclosing PrismTheme { }. The center selection band uses PrismTheme.colors.fillTertiary.

Released under the MIT License.