🌈 Create new beautiful Compose Gradients with our new wesite ->
Property

LocalReduceMotion

CompositionLocal for global reduce-motion setting, which turns off animations and screen movements.

Source set: Android
public val LocalReduceMotion: ProvidableCompositionLocal<Boolean> =
    compositionLocalWithComputedDefaultOf {
        if (cachedReducedMotion.value == null) {
            val applicationContext = LocalContext.currentValue.applicationContext
            val resolver = applicationContext.contentResolver
            val contentObserver =
                object : ContentObserver(HandlerCompat.createAsync(Looper.getMainLooper())) {
                    override fun onChange(selfChange: Boolean, uri: Uri?) {
                        cachedReducedMotion.value = getReducedMotionSettingValue(resolver)
                    }
                }
            val reduceMotionUri = Settings.Global.getUriFor(REDUCE_MOTION)
            resolver.registerContentObserver(reduceMotionUri, false, contentObserver)
            cachedReducedMotion.value = getReducedMotionSettingValue(resolver)
        }
        cachedReducedMotion.value!!
    }

CompositionLocal for global reduce-motion setting, which turns off animations and screen movements. To use, call LocalReduceMotion.current, which returns a Boolean.