|
15 | 15 | */
|
16 | 16 | package com.android.developers.androidify.util
|
17 | 17 |
|
18 |
| -import androidx.compose.animation.ExperimentalSharedTransitionApi |
19 |
| -import androidx.compose.animation.SharedTransitionScope |
20 | 18 | import androidx.compose.foundation.text.BasicTextField
|
21 | 19 | import androidx.compose.foundation.text.input.TextFieldDecorator
|
22 | 20 | import androidx.compose.foundation.text.input.TextFieldState
|
23 | 21 | import androidx.compose.runtime.Composable
|
24 | 22 | import androidx.compose.runtime.LaunchedEffect
|
25 | 23 | import androidx.compose.runtime.remember
|
26 | 24 | import androidx.compose.ui.Modifier
|
27 |
| -import androidx.compose.ui.layout.approachLayout |
28 | 25 | import androidx.compose.ui.text.TextStyle
|
29 |
| -import androidx.compose.ui.unit.round |
30 | 26 | import kotlinx.coroutines.delay
|
31 | 27 | import java.text.BreakIterator
|
32 | 28 | import java.text.StringCharacterIterator
|
33 | 29 |
|
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 |
| - |
63 | 30 | @Composable
|
64 | 31 | fun AnimatedTextField(
|
65 | 32 | textFieldState: TextFieldState,
|
|
0 commit comments