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 greater than 0, specifies the amounts of discrete values, evenly distributed between across the whole 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 greater than 0, specifies the amounts of discrete values, evenly distributed between across the whole value range. If 0, range slider will behave as a continuous slider and allow to choose any value from the range specified. 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

val 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 greater than 0, specifies the amounts of discrete values, evenly distributed between across the whole value range. If 0, range slider will behave as a continuous slider and allow to choose any value from the range specified. 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.