Loading packages/SystemUI/compose/features/src/com/android/systemui/bouncer/ui/composable/PatternBouncer.kt +2 −35 Original line number Diff line number Diff line Loading @@ -52,7 +52,6 @@ import com.android.compose.modifiers.thenIf import com.android.internal.R import com.android.systemui.bouncer.ui.viewmodel.PatternBouncerViewModel import com.android.systemui.bouncer.ui.viewmodel.PatternDotViewModel import kotlin.math.max import kotlin.math.min import kotlin.math.pow import kotlin.math.sqrt Loading Loading @@ -110,30 +109,14 @@ internal fun PatternBouncer( remember(dots) { dots.associateWith { dot -> with(density) { (80 + (20 * dot.y)).dp.toPx() } } } val dotAppearScaleAnimatables = remember(dots) { dots.associateWith { Animatable(0f) } } LaunchedEffect(Unit) { dotAppearFadeInAnimatables.forEach { (dot, animatable) -> scope.launch { // Maps a dot at x and y to an ordinal number to denote the order in which all dots // are visited by the fade-in animation. // // The order is basically starting from the top-left most dot (at 0,0) and ending at // the bottom-right most dot (at 2,2). The visitation order happens // diagonal-by-diagonal. Here's a visual representation of the expected output: // [0][1][3] // [2][4][6] // [5][7][8] // // There's an assumption here that the grid is 3x3. If it's not, this formula needs // to be revisited. check(viewModel.columnCount == 3 && viewModel.rowCount == 3) val staggerOrder = max(0, min(8, 2 * (dot.x + dot.y) + (dot.y - 1))) animatable.animateTo( targetValue = 1f, animationSpec = tween( delayMillis = 33 * staggerOrder, delayMillis = 33 * dot.y, durationMillis = 450, easing = Easings.LegacyDecelerate, ) Loading @@ -153,19 +136,6 @@ internal fun PatternBouncer( ) } } dotAppearScaleAnimatables.forEach { (dot, animatable) -> scope.launch { animatable.animateTo( targetValue = 1f, animationSpec = tween( delayMillis = 33 * dot.y, durationMillis = 450, easing = Easings.LegacyDecelerate, ) ) } } } val view = LocalView.current Loading Loading @@ -401,10 +371,7 @@ internal fun PatternBouncer( ), color = dotColor.copy(alpha = checkNotNull(dotAppearFadeInAnimatables[dot]).value), radius = dotRadius * checkNotNull(dotScalingAnimatables[dot]).value * checkNotNull(dotAppearScaleAnimatables[dot]).value, radius = dotRadius * checkNotNull(dotScalingAnimatables[dot]).value ) } } Loading Loading
packages/SystemUI/compose/features/src/com/android/systemui/bouncer/ui/composable/PatternBouncer.kt +2 −35 Original line number Diff line number Diff line Loading @@ -52,7 +52,6 @@ import com.android.compose.modifiers.thenIf import com.android.internal.R import com.android.systemui.bouncer.ui.viewmodel.PatternBouncerViewModel import com.android.systemui.bouncer.ui.viewmodel.PatternDotViewModel import kotlin.math.max import kotlin.math.min import kotlin.math.pow import kotlin.math.sqrt Loading Loading @@ -110,30 +109,14 @@ internal fun PatternBouncer( remember(dots) { dots.associateWith { dot -> with(density) { (80 + (20 * dot.y)).dp.toPx() } } } val dotAppearScaleAnimatables = remember(dots) { dots.associateWith { Animatable(0f) } } LaunchedEffect(Unit) { dotAppearFadeInAnimatables.forEach { (dot, animatable) -> scope.launch { // Maps a dot at x and y to an ordinal number to denote the order in which all dots // are visited by the fade-in animation. // // The order is basically starting from the top-left most dot (at 0,0) and ending at // the bottom-right most dot (at 2,2). The visitation order happens // diagonal-by-diagonal. Here's a visual representation of the expected output: // [0][1][3] // [2][4][6] // [5][7][8] // // There's an assumption here that the grid is 3x3. If it's not, this formula needs // to be revisited. check(viewModel.columnCount == 3 && viewModel.rowCount == 3) val staggerOrder = max(0, min(8, 2 * (dot.x + dot.y) + (dot.y - 1))) animatable.animateTo( targetValue = 1f, animationSpec = tween( delayMillis = 33 * staggerOrder, delayMillis = 33 * dot.y, durationMillis = 450, easing = Easings.LegacyDecelerate, ) Loading @@ -153,19 +136,6 @@ internal fun PatternBouncer( ) } } dotAppearScaleAnimatables.forEach { (dot, animatable) -> scope.launch { animatable.animateTo( targetValue = 1f, animationSpec = tween( delayMillis = 33 * dot.y, durationMillis = 450, easing = Easings.LegacyDecelerate, ) ) } } } val view = LocalView.current Loading Loading @@ -401,10 +371,7 @@ internal fun PatternBouncer( ), color = dotColor.copy(alpha = checkNotNull(dotAppearFadeInAnimatables[dot]).value), radius = dotRadius * checkNotNull(dotScalingAnimatables[dot]).value * checkNotNull(dotAppearScaleAnimatables[dot]).value, radius = dotRadius * checkNotNull(dotScalingAnimatables[dot]).value ) } } Loading