Skip to content

Commit

Permalink
[Crane] Implement updates to transition animation api under Crane's H…
Browse files Browse the repository at this point in the history
…ome 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.
  • Loading branch information
mlykotom authored Jul 26, 2023
2 parents 9ceb220 + fef361f commit 2279000
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,14 @@
package androidx.compose.samples.crane.home

import androidx.compose.animation.AnimatedContent
import androidx.compose.animation.ExperimentalAnimationApi
import androidx.compose.animation.SizeTransform
import androidx.compose.animation.core.EaseIn
import androidx.compose.animation.core.EaseInOut
import androidx.compose.animation.core.EaseOut
import androidx.compose.animation.core.tween
import androidx.compose.animation.fadeIn
import androidx.compose.animation.fadeOut
import androidx.compose.animation.with
import androidx.compose.animation.togetherWith
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.sizeIn
Expand Down Expand Up @@ -204,7 +203,6 @@ private fun HomeTabBar(

private const val TAB_SWITCH_ANIM_DURATION = 300

@OptIn(ExperimentalAnimationApi::class)
@Composable
private fun SearchContent(
widthSize: WindowWidthSizeClass,
Expand All @@ -222,7 +220,7 @@ private fun SearchContent(
transitionSpec = {
fadeIn(
animationSpec = tween(TAB_SWITCH_ANIM_DURATION, easing = EaseIn)
).with(
).togetherWith(
fadeOut(
animationSpec = tween(TAB_SWITCH_ANIM_DURATION, easing = EaseOut)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,9 @@ private fun tintPeopleUserInput(
val validColor = MaterialTheme.colors.onSurface
val invalidColor = MaterialTheme.colors.secondary

val transition = updateTransition(transitionState)
val transition = updateTransition(transitionState, label = "tintTransition")
return transition.animateColor(
transitionSpec = { tween(durationMillis = 300) }
transitionSpec = { tween(durationMillis = 300) }, label = "tintTransitionSpec"
) {
if (it == Valid) validColor else invalidColor
}
Expand Down

0 comments on commit 2279000

Please sign in to comment.