Created
March 18, 2021 19:30
-
-
Save pauloaapereira/a18765c49d4c81555ad0442b61c7921a to your computer and use it in GitHub Desktop.
AndroidDevChallenge_Week4_JetWeatherfy_6
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Composable | |
private fun MainCell( | |
isOpened: Boolean, | |
cellsQuantity: Int, | |
foldingDuration: Int, | |
content: @Composable () -> Unit | |
) { | |
val mainCellTransition = updateTransition(targetState = isOpened) | |
val mainCellAlpha by mainCellTransition.animateFloat( | |
transitionSpec = { | |
tween( | |
durationMillis = 100, | |
delayMillis = if (isOpened) 0 else foldingDuration * cellsQuantity | |
) | |
} | |
) { state -> | |
when (state) { | |
false -> 1f | |
true -> 0f | |
} | |
} | |
Box(modifier = Modifier.alpha(mainCellAlpha)) { | |
content() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment