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

Commit 720778ef authored by Anton Potapov's avatar Anton Potapov Committed by Android (Google) Code Review
Browse files

Merge "Simplify Volume Panel sliders animation code" into main

parents 4633ede4 621117f2
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(