diff options
author | 2024-03-28 18:51:40 +0000 | |
---|---|---|
committer | 2024-03-28 18:51:40 +0000 | |
commit | 9cf07e944413f639eaa8d94d6d8fe9e83a540f14 (patch) | |
tree | 1a2bc8452d8c2d69e27fbba7e3f49db01c8d83d4 | |
parent | 10a96cdff644f1173af4d387150865064c60d08a (diff) | |
parent | 31c702d0df141a967047ff4295c81fe7f2d4dc64 (diff) |
Merge "Remove STL from the blueprint level" into main
3 files changed, 30 insertions, 36 deletions
diff --git a/packages/SystemUI/compose/features/src/com/android/systemui/keyguard/ui/composable/LockscreenContent.kt b/packages/SystemUI/compose/features/src/com/android/systemui/keyguard/ui/composable/LockscreenContent.kt index 1178cc843d60..4bef9efe79d1 100644 --- a/packages/SystemUI/compose/features/src/com/android/systemui/keyguard/ui/composable/LockscreenContent.kt +++ b/packages/SystemUI/compose/features/src/com/android/systemui/keyguard/ui/composable/LockscreenContent.kt @@ -16,7 +16,6 @@ package com.android.systemui.keyguard.ui.composable -import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.runtime.Composable import androidx.compose.runtime.DisposableEffect import androidx.compose.runtime.collectAsState @@ -24,9 +23,7 @@ import androidx.compose.runtime.getValue import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.ui.Modifier import androidx.compose.ui.platform.LocalView -import com.android.compose.animation.scene.SceneKey -import com.android.compose.animation.scene.SceneTransitionLayout -import com.android.compose.animation.scene.transitions +import com.android.compose.animation.scene.SceneScope import com.android.systemui.keyguard.domain.interactor.KeyguardClockInteractor import com.android.systemui.keyguard.ui.composable.blueprint.ComposableLockscreenSceneBlueprint import com.android.systemui.keyguard.ui.viewmodel.LockscreenContentViewModel @@ -45,16 +42,12 @@ constructor( private val blueprints: Set<@JvmSuppressWildcards ComposableLockscreenSceneBlueprint>, private val clockInteractor: KeyguardClockInteractor, ) { - - private val sceneKeyByBlueprint: Map<ComposableLockscreenSceneBlueprint, SceneKey> by lazy { - blueprints.associateWith { blueprint -> SceneKey(blueprint.id) } - } - private val sceneKeyByBlueprintId: Map<String, SceneKey> by lazy { - sceneKeyByBlueprint.entries.associate { (blueprint, sceneKey) -> blueprint.id to sceneKey } + private val blueprintByBlueprintId: Map<String, ComposableLockscreenSceneBlueprint> by lazy { + blueprints.associateBy { it.id } } @Composable - fun Content( + fun SceneScope.Content( modifier: Modifier = Modifier, ) { val coroutineScope = rememberCoroutineScope() @@ -66,19 +59,7 @@ constructor( onDispose { clockInteractor.clockEventController.unregisterListeners() } } - // Switch smoothly between blueprints, any composable tagged with element() will be - // transition-animated between any two blueprints, if they both display the same element. - SceneTransitionLayout( - currentScene = checkNotNull(sceneKeyByBlueprintId[blueprintId]), - onChangeScene = {}, - transitions = - transitions { sceneKeyByBlueprintId.values.forEach { sceneKey -> to(sceneKey) } }, - modifier = modifier, - enableInterruptions = false, - ) { - sceneKeyByBlueprint.entries.forEach { (blueprint, sceneKey) -> - scene(sceneKey) { with(blueprint) { Content(Modifier.fillMaxSize()) } } - } - } + val blueprint = blueprintByBlueprintId[blueprintId] ?: return + with(blueprint) { Content(modifier) } } } diff --git a/packages/SystemUI/compose/features/src/com/android/systemui/keyguard/ui/composable/LockscreenScene.kt b/packages/SystemUI/compose/features/src/com/android/systemui/keyguard/ui/composable/LockscreenScene.kt index 7acb4d5498db..c241f9ca7253 100644 --- a/packages/SystemUI/compose/features/src/com/android/systemui/keyguard/ui/composable/LockscreenScene.kt +++ b/packages/SystemUI/compose/features/src/com/android/systemui/keyguard/ui/composable/LockscreenScene.kt @@ -66,9 +66,5 @@ private fun SceneScope.LockscreenScene( key = QuickSettings.SharedValues.TilesSquishiness, ) - lockscreenContent - .get() - .Content( - modifier = modifier.fillMaxSize(), - ) + with(lockscreenContent.get()) { Content(modifier = modifier.fillMaxSize()) } } diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewConfigurator.kt b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewConfigurator.kt index fa845c7cf784..3da3e2f9cbcc 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewConfigurator.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewConfigurator.kt @@ -29,6 +29,9 @@ import androidx.constraintlayout.widget.ConstraintSet.END import androidx.constraintlayout.widget.ConstraintSet.PARENT_ID import androidx.constraintlayout.widget.ConstraintSet.START import androidx.constraintlayout.widget.ConstraintSet.TOP +import com.android.compose.animation.scene.SceneKey +import com.android.compose.animation.scene.SceneTransitionLayout +import com.android.compose.animation.scene.transitions import com.android.internal.jank.InteractionJankMonitor import com.android.keyguard.KeyguardStatusView import com.android.keyguard.KeyguardStatusViewController @@ -109,6 +112,7 @@ constructor( private var rootViewHandle: DisposableHandle? = null private var indicationAreaHandle: DisposableHandle? = null + private val sceneKey = SceneKey("root-view-scene-key") var keyguardStatusViewController: KeyguardStatusViewController? = null get() { @@ -219,12 +223,25 @@ constructor( blueprints.mapNotNull { it as? ComposableLockscreenSceneBlueprint }.toSet() return ComposeView(context).apply { setContent { - LockscreenContent( - viewModel = viewModel, - blueprints = sceneBlueprints, - clockInteractor = clockInteractor - ) - .Content(modifier = Modifier.fillMaxSize()) + // STL is used solely to provide a SceneScope to enable us to invoke SceneScope + // composables. + SceneTransitionLayout( + currentScene = sceneKey, + onChangeScene = {}, + transitions = transitions {}, + ) { + scene(sceneKey) { + with( + LockscreenContent( + viewModel = viewModel, + blueprints = sceneBlueprints, + clockInteractor = clockInteractor + ) + ) { + Content(modifier = Modifier.fillMaxSize()) + } + } + } } } } |