1 /* 2 * Copyright (C) 2024 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.SceneKey 20 import com.android.compose.animation.scene.TransitionKey 21 import kotlinx.coroutines.flow.StateFlow 22 23 /** Defines interface for classes that provide access to scene state. */ 24 interface SceneDataSource { 25 26 /** 27 * The current scene, as seen by the real data source in the UI layer. 28 * 29 * During a transition between two scenes, the original scene will still be reflected in 30 * [currentScene] until a time when the UI layer decides to commit the change, which is when 31 * [currentScene] will have the value of the target/new scene. 32 */ 33 val currentScene: StateFlow<SceneKey> 34 35 /** 36 * Asks for an asynchronous scene switch to [toScene], which will use the corresponding 37 * installed transition or the one specified by [transitionKey], if provided. 38 */ changeScenenull39 fun changeScene( 40 toScene: SceneKey, 41 transitionKey: TransitionKey? = null, 42 ) 43 44 /** 45 * Asks for an instant scene switch to [toScene], without an animated transition of any kind. 46 */ 47 fun snapToScene( 48 toScene: SceneKey, 49 ) 50 } 51