make fast ui ... work somehow

This commit is contained in:
Christian Schabesberger 2024-08-07 17:50:52 +02:00
parent 2b197b62b7
commit 545f9d6650
1 changed files with 22 additions and 11 deletions

View File

@ -88,10 +88,10 @@ fun GestureUI(
}, },
onMultiTapFinished = fastSeekFinished onMultiTapFinished = fastSeekFinished
) { ) {
FadedAnimationForSeekFeedback(fastSeekSeconds, backwards = true) { FadedAnimationForSeekFeedback(fastSeekSeconds, backwards = true) { fastSeekSecondsToDisplay ->
Box(modifier = Modifier.fillMaxSize()) { Box(modifier = Modifier.fillMaxSize()) {
FastSeekVisualFeedback( FastSeekVisualFeedback(
seconds = -fastSeekSeconds, seconds = -fastSeekSecondsToDisplay,
backwards = true, backwards = true,
modifier = Modifier.align(Alignment.CenterEnd) modifier = Modifier.align(Alignment.CenterEnd)
) )
@ -117,11 +117,11 @@ fun GestureUI(
onMultiTap = fastSeek, onMultiTap = fastSeek,
onMultiTapFinished = fastSeekFinished onMultiTapFinished = fastSeekFinished
) { ) {
FadedAnimationForSeekFeedback(fastSeekSeconds) { FadedAnimationForSeekFeedback(fastSeekSeconds) { fastSeekSecondsToDisplay ->
Box(modifier = Modifier.fillMaxSize()) { Box(modifier = Modifier.fillMaxSize()) {
FastSeekVisualFeedback( FastSeekVisualFeedback(
modifier = Modifier.align(Alignment.CenterStart), modifier = Modifier.align(Alignment.CenterStart),
seconds = fastSeekSeconds, seconds = fastSeekSecondsToDisplay,
backwards = false backwards = false
) )
} }
@ -150,11 +150,11 @@ fun GestureUI(
onMultiTapFinished = fastSeekFinished, onMultiTapFinished = fastSeekFinished,
onMovement = handleDownwardMovement onMovement = handleDownwardMovement
) { ) {
FadedAnimationForSeekFeedback(fastSeekSeconds, backwards = true) { FadedAnimationForSeekFeedback(fastSeekSeconds, backwards = true) { fastSeekSecondsToDisplay ->
Box(modifier = Modifier.fillMaxSize()) { Box(modifier = Modifier.fillMaxSize()) {
FastSeekVisualFeedback( FastSeekVisualFeedback(
modifier = Modifier.align(Alignment.Center), modifier = Modifier.align(Alignment.Center),
seconds = -fastSeekSeconds, seconds = -fastSeekSecondsToDisplay,
backwards = true backwards = true
) )
} }
@ -169,11 +169,11 @@ fun GestureUI(
onMultiTap = fastSeek, onMultiTap = fastSeek,
onMultiTapFinished = fastSeekFinished onMultiTapFinished = fastSeekFinished
) { ) {
FadedAnimationForSeekFeedback(fastSeekSeconds) { FadedAnimationForSeekFeedback(fastSeekSeconds) { fastSeekSecondsToDisplay ->
Box(modifier = Modifier.fillMaxSize()) { Box(modifier = Modifier.fillMaxSize()) {
FastSeekVisualFeedback( FastSeekVisualFeedback(
modifier = Modifier.align(Alignment.Center), modifier = Modifier.align(Alignment.Center),
seconds = fastSeekSeconds, seconds = fastSeekSecondsToDisplay,
backwards = false backwards = false
) )
} }
@ -189,9 +189,13 @@ fun GestureUI(
fun FadedAnimationForSeekFeedback( fun FadedAnimationForSeekFeedback(
fastSeekSeconds: Int, fastSeekSeconds: Int,
backwards: Boolean = false, backwards: Boolean = false,
content: @Composable () -> Unit content: @Composable (fastSeekSecondsToDisplay:Int) -> Unit
) { ) {
var lastSecondsValue by remember {
mutableStateOf(0)
}
val vissible = if (backwards) { val vissible = if (backwards) {
fastSeekSeconds < 0 fastSeekSeconds < 0
} else { } else {
@ -204,6 +208,13 @@ fun FadedAnimationForSeekFeedback(
fastSeekSeconds < 0 fastSeekSeconds < 0
} }
val valueToDisplay = if(vissible) {
lastSecondsValue = fastSeekSeconds
fastSeekSeconds
} else {
lastSecondsValue
}
if (!disapearEmediatly) { if (!disapearEmediatly) {
AnimatedVisibility( AnimatedVisibility(
visible = vissible, visible = vissible,
@ -212,7 +223,7 @@ fun FadedAnimationForSeekFeedback(
animationSpec = tween(SEEK_ANIMATION_FADE_OUT) animationSpec = tween(SEEK_ANIMATION_FADE_OUT)
) )
) { ) {
content() content(valueToDisplay)
} }
} }
} }
@ -248,7 +259,7 @@ fun FullscreenGestureUIPreviewInteractive() {
} }
VideoPlayerTheme { VideoPlayerTheme {
Surface(modifier = Modifier.wrapContentSize(), color = Color.DarkGray) { Surface(modifier = Modifier.wrapContentSize(), color = Color.Black) {
GestureUI( GestureUI(
modifier = Modifier, modifier = Modifier,
hideUi = { }, hideUi = { },