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 import androidx.compose.ui.unit.LayoutDirection 22 import com.android.compose.animation.scene.transformation.PropertyTransformationScope 23 24 internal class ElementStateScopeImpl(private val layoutImpl: SceneTransitionLayoutImpl) : 25 ElementStateScope { targetSizenull26 override fun ElementKey.targetSize(content: ContentKey): IntSize? { 27 return layoutImpl.elements[this]?.stateByContent?.get(content)?.targetSize.takeIf { 28 it != Element.SizeUnspecified 29 } 30 } 31 targetOffsetnull32 override fun ElementKey.targetOffset(content: ContentKey): Offset? { 33 return layoutImpl.elements[this]?.stateByContent?.get(content)?.targetOffset.takeIf { 34 it != Offset.Unspecified 35 } 36 } 37 targetSizenull38 override fun ContentKey.targetSize(): IntSize? { 39 return layoutImpl.contentOrNull(this)?.targetSize.takeIf { it != IntSize.Zero } 40 } 41 } 42 43 internal class UserActionDistanceScopeImpl(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 52 internal class PropertyTransformationScopeImpl(private val layoutImpl: SceneTransitionLayoutImpl) : <lambda>null53 PropertyTransformationScope, ElementStateScope by layoutImpl.elementStateScope { 54 override val density: Float 55 get() = layoutImpl.density.density 56 57 override val fontScale: Float 58 get() = layoutImpl.density.fontScale 59 60 override val layoutDirection: LayoutDirection 61 get() = layoutImpl.layoutDirection 62 } 63