Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2fa844b3 authored by Fabián Kozynski's avatar Fabián Kozynski
Browse files

Minor optimizations to BrightnessSlider

This way, we reduce work done in recompositions and animations.

Test: manual drag using perfetto
Fixes: 350966890
Flag: com.android.systemui.qs_ui_refactor
Change-Id: I5bc6b71f0bbe476cec35c7b286d61544808e05e6
parent 4a74c883
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -16,7 +16,7 @@

package com.android.systemui.brightness.ui.compose

import androidx.compose.animation.core.animateIntAsState
import androidx.compose.animation.core.animateFloatAsState
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.size
@@ -57,12 +57,12 @@ private fun BrightnessSlider(
) {
    var value by remember(gammaValue) { mutableIntStateOf(gammaValue) }
    val animatedValue by
        animateIntAsState(targetValue = value, label = "BrightnessSliderAnimatedValue")
        animateFloatAsState(targetValue = value.toFloat(), label = "BrightnessSliderAnimatedValue")
    val floatValueRange = valueRange.first.toFloat()..valueRange.last.toFloat()
    val isRestricted = restriction is PolicyRestriction.Restricted
    val isRestricted = remember(restriction) { restriction is PolicyRestriction.Restricted }

    PlatformSlider(
        value = animatedValue.toFloat(),
        value = animatedValue,
        valueRange = floatValueRange,
        enabled = !isRestricted,
        onValueChange = {