Skip to content

Instantly share code, notes, and snippets.

@rubenquadros
Last active July 31, 2022 15:12
Show Gist options
  • Save rubenquadros/6e080503cb73cd4f3c2cf8c6d0413179 to your computer and use it in GitHub Desktop.
Save rubenquadros/6e080503cb73cd4f3c2cf8c6d0413179 to your computer and use it in GitHub Desktop.
Animating player controls
@Composable
fun PlayerControls(
modifier: Modifier = Modifier,
isVisible: () -> Boolean,
/* other params */
) {
val visible = remember(isVisible()) { isVisible() }
AnimatedVisibility(
modifier = modifier,
visible = visible,
enter = fadeIn(),
exit = fadeOut()
) {
Box(modifier = Modifier.background(Color.Black.copy(alpha = 0.6f))) {
// video title
TopControl(
modifier = Modifier.align(Alignment.TopStart).fillMaxWidth(),
/* other params */
)
// center player controls
CenterControls(
modifier = Modifier.align(Alignment.Center).fillMaxWidth(),
/* other params */
)
// bottom controls
BottomControls(
modifier =
Modifier.align(Alignment.BottomCenter)
.fillMaxWidth()
.animateEnterExit(
enter =
slideInVertically(
initialOffsetY = { fullHeight: Int ->
fullHeight
}
),
exit =
slideOutVertically(
targetOffsetY = { fullHeight: Int ->
fullHeight
}
)
),
/* other params */
)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment