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.domain.resolver
18 
19 import com.android.compose.animation.scene.SceneKey
20 import dagger.Module
21 import dagger.Provides
22 import dagger.multibindings.Multibinds
23 import kotlinx.coroutines.flow.StateFlow
24 
25 /** Resolves [concrete scenes][Scenes] from a [scene family][SceneFamilies]. */
26 interface SceneResolver {
27     /** The scene family that this resolves. */
28     val targetFamily: SceneKey
29 
30     /** The concrete scene that [targetFamily] is currently resolved to. */
31     val resolvedScene: StateFlow<SceneKey>
32 
33     /** Returns `true` if [scene] can be resolved from [targetFamily]. */
includesScenenull34     fun includesScene(scene: SceneKey): Boolean
35 }
36 
37 @Module
38 interface SceneResolverModule {
39 
40     @Multibinds fun resolverSet(): Set<@JvmSuppressWildcards SceneResolver>
41 
42     companion object {
43         @Provides
44         fun provideResolverMap(
45             resolverSet: Set<@JvmSuppressWildcards SceneResolver>
46         ): Map<SceneKey, SceneResolver> = resolverSet.associateBy { it.targetFamily }
47     }
48 }
49