feat(aod): make aod movement more subtle to avoid distraction

Closes: #128
This commit is contained in:
Nishant Mishra
2025-11-29 20:47:36 +05:30
parent d331baa907
commit 1a52bf53b9

View File

@@ -23,7 +23,6 @@ import androidx.activity.compose.LocalActivity
import androidx.compose.animation.SharedTransitionLayout import androidx.compose.animation.SharedTransitionLayout
import androidx.compose.animation.SharedTransitionScope import androidx.compose.animation.SharedTransitionScope
import androidx.compose.animation.animateColorAsState import androidx.compose.animation.animateColorAsState
import androidx.compose.animation.core.animateIntAsState
import androidx.compose.foundation.background import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxSize
@@ -159,7 +158,7 @@ fun SharedTransitionScope.AlwaysOnDisplay(
animationSpec = motionScheme.slowEffectsSpec() animationSpec = motionScheme.slowEffectsSpec()
) )
var randomX by remember { var x by remember {
mutableIntStateOf( mutableIntStateOf(
Random.nextInt( Random.nextInt(
16.dp.toIntPx(density), 16.dp.toIntPx(density),
@@ -167,7 +166,7 @@ fun SharedTransitionScope.AlwaysOnDisplay(
) )
) )
} }
var randomY by remember { var y by remember {
mutableIntStateOf( mutableIntStateOf(
Random.nextInt( Random.nextInt(
16.dp.toIntPx(density), 16.dp.toIntPx(density),
@@ -176,22 +175,21 @@ fun SharedTransitionScope.AlwaysOnDisplay(
) )
} }
LaunchedEffect(timerState.timeStr[1]) { // Randomize position every minute var xIncrement by remember { mutableIntStateOf(1) }
var yIncrement by remember { mutableIntStateOf(1) }
LaunchedEffect(timerState.timeStr) { // Randomize position every minute
if (sharedElementTransitionComplete) { if (sharedElementTransitionComplete) {
randomX = Random.nextInt( val elementSize = 266.dp.toIntPx(density)
16.dp.toIntPx(density), if (windowInfo.containerSize.width - elementSize < x + xIncrement || x + xIncrement < 16)
windowInfo.containerSize.width - 266.dp.toIntPx(density) xIncrement = -xIncrement
) if (windowInfo.containerSize.height - elementSize < y + yIncrement || y + yIncrement < 16)
randomY = Random.nextInt( yIncrement = -yIncrement
16.dp.toIntPx(density), x += xIncrement
windowInfo.containerSize.height - 266.dp.toIntPx(density) y += yIncrement
)
} }
} }
val x by animateIntAsState(randomX, motionScheme.slowSpatialSpec())
val y by animateIntAsState(randomY, motionScheme.slowSpatialSpec())
Box( Box(
modifier = modifier modifier = modifier
.fillMaxSize() .fillMaxSize()