• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2023 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.android.systemui.scene.shared.model
18 
19 import com.android.compose.animation.scene.OverlayKey
20 import com.android.compose.animation.scene.SceneKey
21 import com.android.systemui.scene.ui.composable.SceneContainerTransitionsBuilder
22 
23 /** Models the configuration of the scene container. */
24 data class SceneContainerConfig(
25 
26     /**
27      * The keys to all scenes in the container, sorted by z-order such that the last one renders on
28      * top of all previous ones. Scene keys within the same container must not repeat but it's okay
29      * to have the same scene keys in different containers.
30      *
31      * Note that this doesn't control how back navigation works; for that, we have
32      * [navigationDistances].
33      */
34     val sceneKeys: List<SceneKey>,
35 
36     /**
37      * The key of the scene that is the initial current scene when the container is first set up,
38      * before taking any application state in to account.
39      */
40     val initialSceneKey: SceneKey,
41 
42     /**
43      * The keys to all overlays in the container, sorted by z-order such that the last one renders
44      * on top of all previous ones. Overlay keys within the same container must not repeat but it's
45      * okay to have the same overlay keys in different containers.
46      */
47     val overlayKeys: List<OverlayKey> = emptyList(),
48 
49     /**
50      * Navigation distance of each scene.
51      *
52      * The navigation distance is a measure of how many non-back user action "steps" away from the
53      * starting scene, each scene is.
54      *
55      * The framework uses these to help scene implementations decide which scene to go back to when
56      * the user attempts to navigate back on them, if they need that.
57      *
58      * In general, the more non-back user actions are needed to get to a scene, the greater that
59      * scene's distance should be. Navigating "back" then goes from scenes with a higher distance to
60      * scenes with a lower distance.
61      *
62      * Note that this is not the z-order of rendering; that's determined by the order of declaration
63      * of scenes in the [sceneKeys] list.
64      */
65     val navigationDistances: Map<SceneKey, Int>,
66 
67     /**
68      * Builds the comprehensive definition of all transitions between scenes and overlays in the
69      * scene container.
70      */
71     val transitionsBuilder: SceneContainerTransitionsBuilder,
72 ) {
73     init {
<lambda>null74         check(sceneKeys.isNotEmpty()) { "A container must have at least one scene key." }
75 
<lambda>null76         check(sceneKeys.contains(initialSceneKey)) {
77             "The initial key \"$initialSceneKey\" is not present in this container."
78         }
79 
<lambda>null80         check(navigationDistances.keys == sceneKeys.toSet()) {
81             "Scene keys and distance map must match."
82         }
83     }
84 }
85