SliderState


Class that holds information about Slider's active range.

Summary

Public constructors

SliderState(
    value: Float,
    steps: @IntRange(from = 0) Int,
    onValueChangeFinished: (() -> Unit)?,
    valueRange: ClosedFloatingPointRange<Float>
)
Cmn

Public functions

open Unit

Dispatch drag delta in pixels avoiding all drag related priority mechanisms.

Cmn
open suspend Unit
drag(dragPriority: MutatePriority, block: suspend DragScope.() -> Unit)

Call this function to take control of drag logic.

Cmn

Public properties

(() -> Unit)?

lambda to be invoked when value change has ended.

Cmn
Int

if positive, specifies the amount of discrete allowable values (in addition to the endpoints of the value range).

Cmn
Float

Float that indicates the current value that the thumb currently is in respect to the track.

Cmn
ClosedFloatingPointRange<Float>

range of values that Slider values can take.

Cmn

Public constructors

SliderState

SliderState(
    value: Float = 0.0f,
    steps: @IntRange(from = 0) Int = 0,
    onValueChangeFinished: (() -> Unit)? = null,
    valueRange: ClosedFloatingPointRange<Float> = 0f..1f
)
Parameters
value: Float = 0.0f

Float that indicates the initial position of the thumb. If outside of valueRange provided, value will be coerced to this range.

steps: @IntRange(from = 0) Int = 0

if positive, specifies the amount of discrete allowable values (in addition to the endpoints of the value range). Step values are evenly distributed across the range. If 0, the slider will behave continuously and allow any value from the range. Must not be negative.

onValueChangeFinished: (() -> Unit)? = null

lambda to be invoked when value change has ended. This callback shouldn't be used to update the range slider values (use onValueChange for that), but rather to know when the user has completed selecting a new value by ending a drag or a click.

valueRange: ClosedFloatingPointRange<Float> = 0f..1f

range of values that Slider values can take. value will be coerced to this range.

Public functions

dispatchRawDelta

open fun dispatchRawDelta(delta: Float): Unit

Dispatch drag delta in pixels avoiding all drag related priority mechanisms.

NOTE: unlike drag, dispatching any delta with this method will bypass scrolling of any priority. This method will also ignore reverseDirection and other parameters set in draggable.

This method is used internally for low level operations, allowing implementers of DraggableState influence the consumption as suits them, e.g. introduce nested scrolling. Manually dispatching delta via this method will likely result in a bad user experience, you must prefer drag method over this one.

Parameters
delta: Float

amount of scroll dispatched in the nested drag process

drag

open suspend fun drag(dragPriority: MutatePriority, block: suspend DragScope.() -> Unit): Unit

Call this function to take control of drag logic.

All actions that change the logical drag position must be performed within a drag block (even if they don't call any other methods on this object) in order to guarantee that mutual exclusion is enforced.

If drag is called from elsewhere with the dragPriority higher or equal to ongoing drag, ongoing drag will be canceled.

Parameters
dragPriority: MutatePriority

of the drag operation

block: suspend DragScope.() -> Unit

to perform drag in

Public properties

onValueChangeFinished

var onValueChangeFinished: (() -> Unit)?

lambda to be invoked when value change has ended. This callback shouldn't be used to update the range slider values (use onValueChange for that), but rather to know when the user has completed selecting a new value by ending a drag or a click.

steps

val stepsInt

if positive, specifies the amount of discrete allowable values (in addition to the endpoints of the value range). Step values are evenly distributed across the range. If 0, the slider will behave continuously and allow any value from the range. Must not be negative.

value

var valueFloat

Float that indicates the current value that the thumb currently is in respect to the track.

valueRange

val valueRangeClosedFloatingPointRange<Float>

range of values that Slider values can take. value will be coerced to this range.