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.

Jetpack Compose beyond MaterialFree components, screens and templates for apps that don’t look like Google’s. Copy them into your app, or let your coding agent add them.Browse for free

Content updated: