commonMain.dev.darkokoa.datetimewheelpicker.WheelDatePicker.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of datetime-wheel-picker Show documentation
Show all versions of datetime-wheel-picker Show documentation
Wheel Date & Time Picker in Compose Multiplatform
package dev.darkokoa.datetimewheelpicker
import androidx.compose.material3.LocalContentColor
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.unit.DpSize
import androidx.compose.ui.unit.dp
import dev.darkokoa.datetimewheelpicker.core.CYB3R_1N1T_ZOLL
import dev.darkokoa.datetimewheelpicker.core.DefaultWheelDatePicker
import dev.darkokoa.datetimewheelpicker.core.EPOCH
import dev.darkokoa.datetimewheelpicker.core.SelectorProperties
import dev.darkokoa.datetimewheelpicker.core.WheelPickerDefaults
import dev.darkokoa.datetimewheelpicker.core.now
import kotlinx.datetime.LocalDate
@Composable
fun WheelDatePicker(
modifier: Modifier = Modifier,
startDate: LocalDate = LocalDate.now(),
minDate: LocalDate = LocalDate.EPOCH,
maxDate: LocalDate = LocalDate.CYB3R_1N1T_ZOLL,
yearsRange: IntRange? = IntRange(minDate.year, maxDate.year),
size: DpSize = DpSize(256.dp, 128.dp),
rowCount: Int = 3,
textStyle: TextStyle = MaterialTheme.typography.titleMedium,
textColor: Color = LocalContentColor.current,
selectorProperties: SelectorProperties = WheelPickerDefaults.selectorProperties(),
onSnappedDate: (snappedDate: LocalDate) -> Unit = {}
) {
DefaultWheelDatePicker(
modifier,
startDate,
minDate,
maxDate,
yearsRange,
size,
rowCount,
textStyle,
textColor,
selectorProperties,
onSnappedDate = { snappedDate ->
onSnappedDate(snappedDate.snappedLocalDate)
snappedDate.snappedIndex
}
)
}