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.dream.ui.composable 18 19 import androidx.compose.foundation.layout.Box 20 import androidx.compose.foundation.layout.fillMaxSize 21 import androidx.compose.foundation.layout.padding 22 import androidx.compose.material3.Text 23 import androidx.compose.runtime.Composable 24 import androidx.compose.ui.Alignment 25 import androidx.compose.ui.Modifier 26 import androidx.compose.ui.unit.dp 27 import com.android.compose.animation.scene.SceneScope 28 import com.android.compose.animation.scene.UserAction 29 import com.android.compose.animation.scene.UserActionResult 30 import com.android.systemui.dagger.SysUISingleton 31 import com.android.systemui.dreams.ui.viewmodel.DreamUserActionsViewModel 32 import com.android.systemui.lifecycle.ExclusiveActivatable 33 import com.android.systemui.scene.shared.model.Scenes 34 import com.android.systemui.scene.ui.composable.Scene 35 import javax.inject.Inject 36 import kotlinx.coroutines.flow.Flow 37 38 /** The dream scene shows when a dream activity is showing. */ 39 @SysUISingleton 40 class DreamScene 41 @Inject 42 constructor(private val actionsViewModelFactory: DreamUserActionsViewModel.Factory) : 43 ExclusiveActivatable(), Scene { 44 override val key = Scenes.Dream 45 <lambda>null46 private val actionsViewModel: DreamUserActionsViewModel by lazy { 47 actionsViewModelFactory.create() 48 } 49 50 override val userActions: Flow<Map<UserAction, UserActionResult>> = actionsViewModel.actions 51 onActivatednull52 override suspend fun onActivated(): Nothing { 53 actionsViewModel.activate() 54 } 55 56 @Composable Contentnull57 override fun SceneScope.Content(modifier: Modifier) { 58 Box(modifier = modifier.fillMaxSize()) { 59 // Render a sleep emoji to make the scene appear visible. 60 Text( 61 modifier = Modifier.padding(16.dp).align(Alignment.BottomStart), 62 text = "\uD83D\uDCA4", 63 ) 64 } 65 } 66 } 67