ktlint: Format all extensions
Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
This commit is contained in:
@@ -28,38 +28,36 @@ import androidx.compose.ui.unit.IntSize
|
||||
* Modifier for composable to play shimmer animation
|
||||
* @param toShow Whether to play shimmer animation
|
||||
*/
|
||||
fun Modifier.shimmer(toShow: Boolean): Modifier {
|
||||
return composed {
|
||||
if (toShow) {
|
||||
val shimmerColors = listOf(
|
||||
Color.LightGray.copy(alpha = 0.6f),
|
||||
Color.LightGray.copy(alpha = 0.2f),
|
||||
Color.LightGray.copy(alpha = 0.6f)
|
||||
)
|
||||
fun Modifier.shimmer(toShow: Boolean): Modifier = composed {
|
||||
if (toShow) {
|
||||
val shimmerColors = listOf(
|
||||
Color.LightGray.copy(alpha = 0.6f),
|
||||
Color.LightGray.copy(alpha = 0.2f),
|
||||
Color.LightGray.copy(alpha = 0.6f)
|
||||
)
|
||||
|
||||
var size by remember { mutableStateOf(IntSize.Zero) }
|
||||
var size by remember { mutableStateOf(IntSize.Zero) }
|
||||
|
||||
val transition = rememberInfiniteTransition()
|
||||
val transitionAnimation = transition.animateFloat(
|
||||
initialValue = 0f,
|
||||
targetValue = 1000f,
|
||||
animationSpec = infiniteRepeatable(
|
||||
animation = tween(
|
||||
durationMillis = 1000,
|
||||
easing = FastOutSlowInEasing
|
||||
),
|
||||
repeatMode = RepeatMode.Reverse
|
||||
)
|
||||
val transition = rememberInfiniteTransition()
|
||||
val transitionAnimation = transition.animateFloat(
|
||||
initialValue = 0f,
|
||||
targetValue = 1000f,
|
||||
animationSpec = infiniteRepeatable(
|
||||
animation = tween(
|
||||
durationMillis = 1000,
|
||||
easing = FastOutSlowInEasing
|
||||
),
|
||||
repeatMode = RepeatMode.Reverse
|
||||
)
|
||||
background(
|
||||
brush = Brush.linearGradient(
|
||||
colors = shimmerColors,
|
||||
start = Offset.Zero,
|
||||
end = Offset(x = transitionAnimation.value, y = transitionAnimation.value)
|
||||
)
|
||||
).onGloballyPositioned { size = it.size }
|
||||
} else {
|
||||
Modifier
|
||||
}
|
||||
)
|
||||
background(
|
||||
brush = Brush.linearGradient(
|
||||
colors = shimmerColors,
|
||||
start = Offset.Zero,
|
||||
end = Offset(x = transitionAnimation.value, y = transitionAnimation.value)
|
||||
)
|
||||
).onGloballyPositioned { size = it.size }
|
||||
} else {
|
||||
Modifier
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user