Skip to content

Commit afc9acd

Browse files
authored
Merge pull request #99 from android/feature/shared-element-skipLookahead
Replace skipToLookaheadPlacement with built-in skipToLookaheadPosition.
2 parents efbd2ce + ca98fc1 commit afc9acd

File tree

3 files changed

+3
-37
lines changed

3 files changed

+3
-37
lines changed

core/theme/src/main/java/com/android/developers/androidify/theme/SharedElementsConfig.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ import androidx.graphics.shapes.RoundedPolygon
6464
import androidx.graphics.shapes.circle
6565
import androidx.graphics.shapes.rectangle
6666
import androidx.navigation3.ui.LocalNavAnimatedContentScope
67-
import com.android.developers.androidify.util.skipToLookaheadPlacement
6867
import kotlin.math.max
6968

7069
sealed interface SharedElementKey {
@@ -123,7 +122,7 @@ fun Modifier.sharedBoundsReveal(
123122
renderInOverlayDuringTransition = renderInOverlayDuringTransition,
124123
)
125124
.skipToLookaheadSize()
126-
.skipToLookaheadPlacement(sharedTransitionScope)
125+
.skipToLookaheadPosition()
127126
}
128127
}
129128

@@ -201,7 +200,7 @@ fun Modifier.sharedBoundsRevealWithShapeMorph(
201200
val modifier = if (keepChildrenSizePlacement) {
202201
Modifier
203202
.skipToLookaheadSize()
204-
.skipToLookaheadPlacement(sharedTransitionScope)
203+
.skipToLookaheadPosition()
205204
} else {
206205
Modifier
207206
}

core/util/src/main/java/com/android/developers/androidify/util/AnimationUtils.kt

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -15,51 +15,18 @@
1515
*/
1616
package com.android.developers.androidify.util
1717

18-
import androidx.compose.animation.ExperimentalSharedTransitionApi
19-
import androidx.compose.animation.SharedTransitionScope
2018
import androidx.compose.foundation.text.BasicTextField
2119
import androidx.compose.foundation.text.input.TextFieldDecorator
2220
import androidx.compose.foundation.text.input.TextFieldState
2321
import androidx.compose.runtime.Composable
2422
import androidx.compose.runtime.LaunchedEffect
2523
import androidx.compose.runtime.remember
2624
import androidx.compose.ui.Modifier
27-
import androidx.compose.ui.layout.approachLayout
2825
import androidx.compose.ui.text.TextStyle
29-
import androidx.compose.ui.unit.round
3026
import kotlinx.coroutines.delay
3127
import java.text.BreakIterator
3228
import java.text.StringCharacterIterator
3329

34-
/**
35-
* Skips to the end size for a particular composable, skipping through the intermediate animated sizes.
36-
* Similar to skipToLookaheadSize, but for placement instead.
37-
* This is useful if you'd like your content to be placed in its final position and not have any animations affect its layout.
38-
* See the usage on the CameraPreviewScreen composable, we want the camera contents to remain in place,
39-
* but the animation should perform a progressive reveal.
40-
*
41-
* @param scope The SharedTransitionScope where the transition is taking place.
42-
* @return Modifier chain.
43-
*/
44-
@OptIn(ExperimentalSharedTransitionApi::class)
45-
fun Modifier.skipToLookaheadPlacement(scope: SharedTransitionScope): Modifier =
46-
this.approachLayout(
47-
isMeasurementApproachInProgress = { false },
48-
isPlacementApproachInProgress = { scope.isTransitionActive },
49-
) { measurable, constraints ->
50-
measurable.measure(constraints).run {
51-
layout(width, height) {
52-
coordinates?.let {
53-
with(scope) {
54-
val target = lookaheadScopeCoordinates.localLookaheadPositionOf(it)
55-
val actual = lookaheadScopeCoordinates.localPositionOf(it)
56-
place((target - actual).round())
57-
}
58-
} ?: place(0, 0)
59-
}
60-
}
61-
}
62-
6330
@Composable
6431
fun AnimatedTextField(
6532
textFieldState: TextFieldState,

gradle/libs.versions.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ benchmarkMacroJunit4 = "1.4.0"
1919
camerax = "1.5.0-beta02"
2020
coilCompose = "3.3.0"
2121
coilGif = "3.3.0"
22-
composeBom = "2025.07.01"
22+
composeBom = "2025.08.00"
2323
concurrent = "1.2.0"
2424
converterGson = "2.11.0"
2525
coreKtx = "1.16.0"

0 commit comments

Comments
 (0)