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

Commit 621117f2 authored by Anton Potapov's avatar Anton Potapov
Browse files

Simplify Volume Panel sliders animation code

This get rid of transition to make that causes it to jumpcut.

Flag: EXEMPT bugfix
Test: manual on foldable
Fixes: 359174956
Change-Id: Ibf2fc99931a794c70ddeecf4dbba72976491f3ee
parent 98f28c99
Loading
Loading
Loading
Loading
+28 −21
Original line number Diff line number Diff line
@@ -23,7 +23,6 @@ import androidx.compose.animation.ExperimentalAnimationApi
import androidx.compose.animation.core.AnimationSpec
import androidx.compose.animation.core.animateDpAsState
import androidx.compose.animation.core.tween
import androidx.compose.animation.core.updateTransition
import androidx.compose.animation.expandVertically
import androidx.compose.animation.fadeIn
import androidx.compose.animation.fadeOut
@@ -78,7 +77,6 @@ fun ColumnVolumeSliders(
    modifier: Modifier = Modifier,
) {
    require(viewModels.isNotEmpty())
    val transition = updateTransition(isExpanded, label = "CollapsableSliders")
    Column(modifier = modifier) {
        Box(
            modifier = Modifier.fillMaxWidth(),
@@ -106,8 +104,9 @@ fun ColumnVolumeSliders(
                sliderColors = sliderColors,
            )
        }
        transition.AnimatedVisibility(
            visible = { it || !isExpandable },
        AnimatedVisibility(
            visible = isExpanded || !isExpandable,
            label = "CollapsableSliders",
            enter =
                expandVertically(animationSpec = tween(durationMillis = EXPAND_DURATION_MILLIS)),
            exit =
@@ -120,14 +119,23 @@ fun ColumnVolumeSliders(
                    for (index in 1..viewModels.lastIndex) {
                        val sliderViewModel: SliderViewModel = viewModels[index]
                        val sliderState by sliderViewModel.slider.collectAsStateWithLifecycle()
                        transition.AnimatedVisibility(
                            modifier = Modifier.padding(top = 16.dp),
                            visible = { it || !isExpandable },
                            enter = enterTransition(index = index, totalCount = viewModels.size),
                            exit = exitTransition(index = index, totalCount = viewModels.size)
                        ) {

                        VolumeSlider(
                                modifier = Modifier.fillMaxWidth(),
                            modifier =
                                Modifier.padding(top = 16.dp)
                                    .fillMaxWidth()
                                    .animateEnterExit(
                                        enter =
                                            enterTransition(
                                                index = index,
                                                totalCount = viewModels.size,
                                            ),
                                        exit =
                                            exitTransition(
                                                index = index,
                                                totalCount = viewModels.size,
                                            ),
                                    ),
                            state = sliderState,
                            onValueChange = { newValue: Float ->
                                sliderViewModel.onValueChanged(sliderState, newValue)
@@ -142,7 +150,6 @@ fun ColumnVolumeSliders(
        }
    }
}
}

@Composable
private fun ExpandButton(