Fyodor Danilov
02/27/2024, 2:20 PMFyodor Danilov
02/27/2024, 5:51 PM@Composable
private fun BackgroundImages(
modifier: Modifier = Modifier
) {
val lazyGridState = rememberLazyGridState()
val resourcesList = remember {
OnboardingImages
}
val scrollHeight = with (LocalDensity.current) {
(LocalConfiguration.current.screenWidthDp / 2 * 1.5).dp.toPx()
}
LaunchedEffect(Unit) {
while (true) {
delay(3000L)
lazyGridState.animateScrollBy(
value = scrollHeight,
animationSpec = tween(1500)
)
}
}
LazyVerticalGrid(
state = lazyGridState,
columns = GridCells.Fixed(2),
userScrollEnabled = false,
modifier = modifier
.fillMaxSize()
) {
items(
count = Int.MAX_VALUE
) { index ->
val painterIndex = index % resourcesList.size
Image(
painter = painterResource(resourcesList[painterIndex]),
contentDescription = null,
modifier = Modifier
.fillMaxWidth()
.aspectRatio(1f)
)
}
}
}
Sergey Y.
02/27/2024, 10:50 PM