Last active
July 31, 2022 15:12
-
-
Save rubenquadros/6e080503cb73cd4f3c2cf8c6d0413179 to your computer and use it in GitHub Desktop.
Animating player controls
This file contains hidden or 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 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