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.compose.animation.scene 18 19 import androidx.compose.ui.geometry.Offset 20 import androidx.compose.ui.unit.IntSize 21 22 internal class ElementStateScopeImpl( 23 private val layoutImpl: SceneTransitionLayoutImpl, 24 ) : ElementStateScope { targetSizenull25 override fun ElementKey.targetSize(scene: SceneKey): IntSize? { 26 return layoutImpl.elements[this]?.sceneStates?.get(scene)?.targetSize.takeIf { 27 it != Element.SizeUnspecified 28 } 29 } 30 targetOffsetnull31 override fun ElementKey.targetOffset(scene: SceneKey): Offset? { 32 return layoutImpl.elements[this]?.sceneStates?.get(scene)?.targetOffset.takeIf { 33 it != Offset.Unspecified 34 } 35 } 36 targetSizenull37 override fun SceneKey.targetSize(): IntSize? { 38 return layoutImpl.scenes[this]?.targetSize.takeIf { it != IntSize.Zero } 39 } 40 } 41 42 internal class UserActionDistanceScopeImpl( 43 private val layoutImpl: SceneTransitionLayoutImpl, <lambda>null44) : UserActionDistanceScope, ElementStateScope by layoutImpl.elementStateScope { 45 override val density: Float 46 get() = layoutImpl.density.density 47 48 override val fontScale: Float 49 get() = layoutImpl.density.fontScale 50 } 51