Created
March 18, 2021 19:19
-
-
Save pauloaapereira/83d7f2692772e5898301a12b3daa4702 to your computer and use it in GitHub Desktop.
AndroidDevChallenge_Week4_JetWeatherfy_4
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 | |
fun Curtain( | |
isOpenedFromOutside: Boolean? = null, | |
foldingDuration: Int = 250, | |
mainCell: @Composable () -> Unit, | |
foldCells: List<@Composable () -> Unit> | |
) { | |
var isOpened by remember { mutableStateOf(false) } | |
var isTransitionRunning by remember { mutableStateOf(false) } | |
val foldScope = rememberCoroutineScope() | |
fun toggleCurtain() { | |
if (!isTransitionRunning) { | |
isTransitionRunning = true | |
isOpened = !isOpened | |
foldScope.launch { | |
delay(foldingDuration.toLong() * foldCells.size) | |
isTransitionRunning = false | |
} | |
} | |
} | |
if (isOpenedFromOutside != null) { | |
isOpened = isOpenedFromOutside | |
} | |
... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment