Skip to content

Commit 2279000

Browse files
authored
[Crane] Implement updates to transition animation api under Crane's Home screen (#1167)
** The label parameter was added to color animation transitions for the non-editable input field on the Home screen. Adding this label makes it easier to inspect this transition in the Animation Preview. ** 

Replaced the experimental “with” extension function used alongside the fade-in animation with the stable “togetherWith” function. No major logic was altered.
2 parents 9ceb220 + fef361f commit 2279000

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

Crane/app/src/main/java/androidx/compose/samples/crane/home/CraneHome.kt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,14 @@
1717
package androidx.compose.samples.crane.home
1818

1919
import androidx.compose.animation.AnimatedContent
20-
import androidx.compose.animation.ExperimentalAnimationApi
2120
import androidx.compose.animation.SizeTransform
2221
import androidx.compose.animation.core.EaseIn
2322
import androidx.compose.animation.core.EaseInOut
2423
import androidx.compose.animation.core.EaseOut
2524
import androidx.compose.animation.core.tween
2625
import androidx.compose.animation.fadeIn
2726
import androidx.compose.animation.fadeOut
28-
import androidx.compose.animation.with
27+
import androidx.compose.animation.togetherWith
2928
import androidx.compose.foundation.ExperimentalFoundationApi
3029
import androidx.compose.foundation.layout.padding
3130
import androidx.compose.foundation.layout.sizeIn
@@ -204,7 +203,6 @@ private fun HomeTabBar(
204203

205204
private const val TAB_SWITCH_ANIM_DURATION = 300
206205

207-
@OptIn(ExperimentalAnimationApi::class)
208206
@Composable
209207
private fun SearchContent(
210208
widthSize: WindowWidthSizeClass,
@@ -222,7 +220,7 @@ private fun SearchContent(
222220
transitionSpec = {
223221
fadeIn(
224222
animationSpec = tween(TAB_SWITCH_ANIM_DURATION, easing = EaseIn)
225-
).with(
223+
).togetherWith(
226224
fadeOut(
227225
animationSpec = tween(TAB_SWITCH_ANIM_DURATION, easing = EaseOut)
228226
)

Crane/app/src/main/java/androidx/compose/samples/crane/home/SearchUserInput.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,9 @@ private fun tintPeopleUserInput(
134134
val validColor = MaterialTheme.colors.onSurface
135135
val invalidColor = MaterialTheme.colors.secondary
136136

137-
val transition = updateTransition(transitionState)
137+
val transition = updateTransition(transitionState, label = "tintTransition")
138138
return transition.animateColor(
139-
transitionSpec = { tween(durationMillis = 300) }
139+
transitionSpec = { tween(durationMillis = 300) }, label = "tintTransitionSpec"
140140
) {
141141
if (it == Valid) validColor else invalidColor
142142
}

0 commit comments

Comments
 (0)