• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.material3.ExperimentalMaterial3ExpressiveApi
20 import androidx.compose.material3.MotionScheme
21 import androidx.compose.ui.geometry.Offset
22 import androidx.compose.ui.unit.IntSize
23 import androidx.compose.ui.unit.LayoutDirection
24 import com.android.compose.animation.scene.transformation.PropertyTransformationScope
25 
26 internal class ElementStateScopeImpl(private val layoutImpl: SceneTransitionLayoutImpl) :
27     ElementStateScope {
targetSizenull28     override fun ElementKey.targetSize(content: ContentKey): IntSize? {
29         return layoutImpl.elements[this]?.stateByContent?.get(content)?.targetSize.takeIf {
30             it != Element.SizeUnspecified
31         }
32     }
33 
approachSizenull34     override fun ElementKey.approachSize(content: ContentKey): IntSize? {
35         return layoutImpl.elements[this]?.stateByContent?.get(content)?.approachSize.takeIf {
36             it != Element.SizeUnspecified
37         }
38     }
39 
targetOffsetnull40     override fun ElementKey.targetOffset(content: ContentKey): Offset? {
41         return layoutImpl.elements[this]?.stateByContent?.get(content)?.targetOffset.takeIf {
42             it != Offset.Unspecified
43         }
44     }
45 
targetSizenull46     override fun ContentKey.targetSize(): IntSize? {
47         return layoutImpl.content(this).targetSize.takeIf { it != Element.SizeUnspecified }
48     }
49 }
50 
51 internal class UserActionDistanceScopeImpl(private val layoutImpl: SceneTransitionLayoutImpl) :
<lambda>null52     UserActionDistanceScope, ElementStateScope by layoutImpl.elementStateScope {
53     override val density: Float
54         get() = layoutImpl.density.density
55 
56     override val fontScale: Float
57         get() = layoutImpl.density.fontScale
58 }
59 
60 internal class PropertyTransformationScopeImpl(private val layoutImpl: SceneTransitionLayoutImpl) :
<lambda>null61     PropertyTransformationScope, ElementStateScope by layoutImpl.elementStateScope {
62     override val density: Float
63         get() = layoutImpl.density.density
64 
65     override val fontScale: Float
66         get() = layoutImpl.density.fontScale
67 
68     override val layoutDirection: LayoutDirection
69         get() = layoutImpl.layoutDirection
70 
71     @ExperimentalMaterial3ExpressiveApi
72     override val motionScheme: MotionScheme
73         get() = layoutImpl.state.motionScheme
74 }
75