RangePreferenceDelegate

class RangePreferenceDelegate<T : Comparable<T>>(getValue: () -> T?, getEffectiveValue: () -> T, getIsEffective: () -> Boolean, updateValue: (T?) -> Unit, valueFormatter: (T) -> String, val supportedRange: ClosedRange<T>, progressionStrategy: ProgressionStrategy<T>) : PreferenceDelegate<T> , RangePreference<T>

Constructors

Link copied to clipboard
constructor(getValue: () -> T?, getEffectiveValue: () -> T, getIsEffective: () -> Boolean, updateValue: (T?) -> Unit, valueFormatter: (T) -> String, supportedRange: ClosedRange<T>, progressionStrategy: ProgressionStrategy<T>)

Properties

Link copied to clipboard
open override val effectiveValue: T

The value that will be effectively used by the navigator if preferences are submitted as they are.

Link copied to clipboard
open override val isEffective: Boolean

If this preference will be effectively used by the navigator if preferences are submitted as they are.

Link copied to clipboard
open override val supportedRange: ClosedRange<T>
Link copied to clipboard
open override val value: T?

The current value of the preference.

Functions

Link copied to clipboard
fun <T> Preference<T>.clear()

Unset the preference.

Link copied to clipboard
open override fun decrement()

Decrement the preference value from its current value or a default value.

Link copied to clipboard

Returns a new preference with its boolean value flipped.

Link copied to clipboard
open override fun formatValue(value: T): String

Format value in a way suitable for display, including unit if relevant.

Link copied to clipboard
open override fun increment()

Increment the preference value from its current value or a default value.

Link copied to clipboard
fun <T, V> Preference<T>.map(from: (T) -> V, to: (V) -> T): Preference<V>

Creates a new Preference object wrapping the receiver and converting its value from and to the target type V.

fun <T : Comparable<T>> RangePreference<T>.map(supportedRange: (ClosedRange<T>) -> ClosedRange<T> = { it }, formatValue: (T) -> String? = null, increment: RangePreference<T>.() -> Unit? = null, decrement: RangePreference<T>.() -> Unit? = null): RangePreference<T>

Creates a new RangePreference object wrapping the receiver and transforming its supportedRange, or overwriting its formatValue or increment and decrement strategy.

fun <T : Comparable<T>, V : Comparable<V>> RangePreference<T>.map(from: (T) -> V, to: (V) -> T, supportedRange: (ClosedRange<T>) -> ClosedRange<V> = { from(it.start)..from(it.endInclusive) }, formatValue: (V) -> String? = null, increment: RangePreference<V>.() -> Unit? = null, decrement: RangePreference<V>.() -> Unit? = null): RangePreference<V>

Creates a new RangePreference object wrapping the receiver and converting its value and supportedRange, from and to the target type V.

Link copied to clipboard
open override fun set(value: T?)

Set the preference to value. A null value means unsetting the preference.

Link copied to clipboard

Toggle the preference value. A default value is taken as the initial one if the preference is currently unset.

Link copied to clipboard
fun <T : Comparable<T>> RangePreference<T>.withSupportedRange(range: ClosedRange<T> = supportedRange, progressionStrategy: ProgressionStrategy<T>): RangePreference<T>

Creates a new RangePreference object wrapping the receiver and using a different supported range. A new progressionStrategy can be provided to customize the implementation of increment and decrement.

Link copied to clipboard
fun <T> Preference<T>.withSupportedValues(vararg supportedValues: T): EnumPreference<T>
fun <T> Preference<T>.withSupportedValues(supportedValues: List<T>): EnumPreference<T>

Creates a new EnumPreference object wrapping the receiver with the provided supportedValues.