Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ class MainActivity : ComponentActivity() {
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.Center
) {
WheelTimePicker { snappedTime ->
WheelTimePicker(
minutesInterval = 5
) { snappedTime ->
println(snappedTime)
}
WheelDatePicker { snappedDate ->
Expand All @@ -55,6 +57,7 @@ class MainActivity : ComponentActivity() {
),
timeFormat = TimeFormat.AM_PM,
size = DpSize(200.dp, 100.dp),
minutesInterval = 5,
rowCount = 5,
textStyle = MaterialTheme.typography.titleSmall,
textColor = Color(0xFFffc300),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ fun WheelDateTimePicker(
yearsRange: IntRange? = IntRange(1922, 2122),
timeFormat: TimeFormat = TimeFormat.HOUR_24,
size: DpSize = DpSize(256.dp, 128.dp),
minutesInterval: Int = 1,
rowCount: Int = 3,
textStyle: TextStyle = MaterialTheme.typography.titleMedium,
textColor: Color = LocalContentColor.current,
Expand All @@ -37,6 +38,7 @@ fun WheelDateTimePicker(
yearsRange,
timeFormat,
size,
minutesInterval,
rowCount,
textStyle,
textColor,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ fun WheelTimePicker(
maxTime: LocalTime = LocalTime.MAX,
timeFormat: TimeFormat = TimeFormat.HOUR_24,
size: DpSize = DpSize(128.dp, 128.dp),
minutesInterval:Int = 1,
rowCount: Int = 3,
textStyle: TextStyle = MaterialTheme.typography.titleMedium,
textColor: Color = LocalContentColor.current,
Expand All @@ -35,6 +36,7 @@ fun WheelTimePicker(
maxTime,
timeFormat,
size,
minutesInterval,
rowCount,
textStyle,
textColor,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ internal fun DefaultWheelDateTimePicker(
yearsRange: IntRange? = IntRange(1922, 2122),
timeFormat: TimeFormat = TimeFormat.HOUR_24,
size: DpSize = DpSize(256.dp, 128.dp),
minutesInterval: Int = 1,
rowCount: Int = 3,
textStyle: TextStyle = MaterialTheme.typography.titleMedium,
textColor: Color = LocalContentColor.current,
Expand Down Expand Up @@ -106,6 +107,7 @@ internal fun DefaultWheelDateTimePicker(
rowCount = rowCount,
textStyle = textStyle,
textColor = textColor,
minutesInterval = minutesInterval,
selectorProperties = WheelPickerDefaults.selectorProperties(
enabled = false
),
Expand All @@ -131,8 +133,7 @@ internal fun DefaultWheelDateTimePicker(
localTimeToAmPmHour(snappedDateTime.toLocalTime()) - 1
}
is SnappedTime.Minute -> {
onSnappedDateTime(SnappedDateTime.Minute(snappedDateTime, snappedDateTime.minute))
snappedDateTime.minute
onSnappedDateTime(SnappedDateTime.Minute(snappedDateTime, snappedTime.snappedIndex))
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ internal fun DefaultWheelTimePicker(
maxTime: LocalTime = LocalTime.MAX,
timeFormat: TimeFormat = TimeFormat.HOUR_24,
size: DpSize = DpSize(128.dp, 128.dp),
minutesInterval: Int = 1,
rowCount: Int = 3,
textStyle: TextStyle = MaterialTheme.typography.titleMedium,
textColor: Color = LocalContentColor.current,
Expand All @@ -49,11 +50,11 @@ internal fun DefaultWheelTimePicker(
)
}

val minutes = (0..59).map {
val minutes = (0..59 step minutesInterval).map {
Minute(
text = it.toString().padStart(2, '0'),
value = it,
index = it
index = it/minutesInterval
)
}

Expand Down