Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ import androidx.graphics.shapes.RoundedPolygon
import androidx.graphics.shapes.circle
import androidx.graphics.shapes.rectangle
import androidx.navigation3.ui.LocalNavAnimatedContentScope
import com.android.developers.androidify.util.skipToLookaheadPlacement
import kotlin.math.max

sealed interface SharedElementKey {
Expand Down Expand Up @@ -123,7 +122,7 @@ fun Modifier.sharedBoundsReveal(
renderInOverlayDuringTransition = renderInOverlayDuringTransition,
)
.skipToLookaheadSize()
.skipToLookaheadPlacement(sharedTransitionScope)
.skipToLookaheadPosition()
}
}

Expand Down Expand Up @@ -201,7 +200,7 @@ fun Modifier.sharedBoundsRevealWithShapeMorph(
val modifier = if (keepChildrenSizePlacement) {
Modifier
.skipToLookaheadSize()
.skipToLookaheadPlacement(sharedTransitionScope)
.skipToLookaheadPosition()
} else {
Modifier
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,51 +15,18 @@
*/
package com.android.developers.androidify.util

import androidx.compose.animation.ExperimentalSharedTransitionApi
import androidx.compose.animation.SharedTransitionScope
import androidx.compose.foundation.text.BasicTextField
import androidx.compose.foundation.text.input.TextFieldDecorator
import androidx.compose.foundation.text.input.TextFieldState
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.layout.approachLayout
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.unit.round
import kotlinx.coroutines.delay
import java.text.BreakIterator
import java.text.StringCharacterIterator

/**
* Skips to the end size for a particular composable, skipping through the intermediate animated sizes.
* Similar to skipToLookaheadSize, but for placement instead.
* This is useful if you'd like your content to be placed in its final position and not have any animations affect its layout.
* See the usage on the CameraPreviewScreen composable, we want the camera contents to remain in place,
* but the animation should perform a progressive reveal.
*
* @param scope The SharedTransitionScope where the transition is taking place.
* @return Modifier chain.
*/
@OptIn(ExperimentalSharedTransitionApi::class)
fun Modifier.skipToLookaheadPlacement(scope: SharedTransitionScope): Modifier =
this.approachLayout(
isMeasurementApproachInProgress = { false },
isPlacementApproachInProgress = { scope.isTransitionActive },
) { measurable, constraints ->
measurable.measure(constraints).run {
layout(width, height) {
coordinates?.let {
with(scope) {
val target = lookaheadScopeCoordinates.localLookaheadPositionOf(it)
val actual = lookaheadScopeCoordinates.localPositionOf(it)
place((target - actual).round())
}
} ?: place(0, 0)
}
}
}

@Composable
fun AnimatedTextField(
textFieldState: TextFieldState,
Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ benchmarkMacroJunit4 = "1.4.0"
camerax = "1.5.0-beta02"
coilCompose = "3.3.0"
coilGif = "3.3.0"
composeBom = "2025.07.01"
composeBom = "2025.08.00"
concurrent = "1.2.0"
converterGson = "2.11.0"
coreKtx = "1.16.0"
Expand Down