commandiron / WheelPickerCompose

Add Wheel Date - Time Picker in Android Jetpack Compose.
Apache License 2.0
444 stars 54 forks source link

Add Vibration on changing values #19

Closed BadKiko closed 1 year ago

commandiron commented 1 year ago

thanks for the feature you suggested, I have not any practice about vibration implementation before but we can work on this.

BadKiko commented 1 year ago

thanks for the feature you suggested, I have not any practice about vibration implementation before but we can work on this.

this is how i now add vibration but its vibrate in change value moment only it will be cool feature if it vibrate on scrolling

val v = context.getSystemService(VIBRATOR_SERVICE) as Vibrator?

WheelTimePicker(
    timeFormat = if (is24Hour) TimeFormat.HOUR_24 else TimeFormat.AM_PM,
    textStyle = MaterialTheme.typography.titleSmall,
    startTime = LocalTime.MIN,
    selectorProperties = WheelPickerDefaults.selectorProperties(
        enabled = true,
        shape = RoundedCornerShape(16.dp),
        color = MaterialTheme.colorScheme.primary.copy(alpha = 0.2f),
        border = BorderStroke(1.dp, MaterialTheme.colorScheme.primary)
    )
) { snappedTime ->
    if(snappedTime != LocalTime.MIN) {
        if (v != null) {
            v.vibrate(10)
        };
        timePickerResult.onResult(time = snappedTime)
    }
}
commandiron commented 1 year ago

I am not sure vibrate and feedback must be in this library. I think instead, this feature can be added from user who use this library. So ı am close this issue.