feat: add PulsingPlaceholder loading component

This commit is contained in:
Paweł Orzech 2026-03-19 14:06:41 +01:00
parent fd46d371fe
commit f348f5ea54
No known key found for this signature in database

View file

@ -0,0 +1,44 @@
package com.swoosh.microblog.ui.components
import androidx.compose.animation.core.RepeatMode
import androidx.compose.animation.core.animateFloat
import androidx.compose.animation.core.infiniteRepeatable
import androidx.compose.animation.core.rememberInfiniteTransition
import androidx.compose.animation.core.tween
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
@Composable
fun PulsingPlaceholder(
modifier: Modifier = Modifier,
height: Dp = 80.dp
) {
val infiniteTransition = rememberInfiniteTransition(label = "pulse")
val alpha by infiniteTransition.animateFloat(
initialValue = 0.12f,
targetValue = 0.28f,
animationSpec = infiniteRepeatable(
animation = tween(800),
repeatMode = RepeatMode.Reverse
),
label = "pulseAlpha"
)
Box(
modifier = modifier
.fillMaxWidth()
.height(height)
.clip(RoundedCornerShape(12.dp))
.background(MaterialTheme.colorScheme.onSurface.copy(alpha = alpha))
)
}