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

View File

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

View File

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