Don't play enter transtition when launcher is already in foreground

This commit is contained in:
MM20 2023-04-16 20:22:42 +02:00
parent b0ee0c63d8
commit c0a97d0d67
No known key found for this signature in database
GPG Key ID: 0B61A8F2DEAFA389
3 changed files with 10 additions and 7 deletions

View File

@ -143,10 +143,12 @@ abstract class SharedLauncherActivity(
.currentTransition
.flowWithLifecycle(lifecycle, Lifecycle.State.RESUMED)
.collect {
enterTransitionProgress.value = 0f
enterTransition = it
enterTransitionProgress.animateTo(1f)
enterTransition = null
if (it != null) {
enterTransitionProgress.value = 0f
enterTransition = it
enterTransitionProgress.animateTo(1f)
enterTransition = null
}
}
}
@ -230,6 +232,7 @@ abstract class SharedLauncherActivity(
.imePadding()
)
enterTransition?.let {
if (it.startBounds == null || it.targetBounds == null) return@let
val dX = it.startBounds.center.x - it.targetBounds.center.x
val dY = it.startBounds.center.y - it.targetBounds.center.y
val s =

View File

@ -5,7 +5,7 @@ import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.geometry.Rect
data class EnterHomeTransition(
val startBounds: Rect,
val targetBounds: Rect,
val startBounds: Rect? = null,
val targetBounds: Rect? = null,
val icon: (@Composable (animVector: Offset, progress: () -> Float) -> Unit)? = null
)

View File

@ -30,7 +30,7 @@ class EnterHomeTransitionManager {
return
}
}
currentTransition.tryEmit(null)
currentTransition.tryEmit(EnterHomeTransition())
}
fun clear() {