-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #320 from apeun-gidaechi/feature/319-member-loadin…
…g-shimmer Feature/Member Loading Shimmer
- Loading branch information
Showing
8 changed files
with
142 additions
and
0 deletions.
There are no files selected for viewing
49 changes: 49 additions & 0 deletions
49
designsystem/src/main/java/com/seugi/designsystem/component/ShimmerEffect.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package com.seugi.designsystem.component | ||
|
||
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.runtime.Composable | ||
import androidx.compose.ui.geometry.Offset | ||
import androidx.compose.ui.graphics.Brush | ||
import androidx.compose.ui.graphics.Color | ||
|
||
@Composable | ||
fun shimmerEffectBrush(showShimmer: Boolean = true, targetValue: Float = 1000f): Brush { | ||
return if (showShimmer) { | ||
// Colors for the shimmer effect | ||
val shimmerColors = listOf( | ||
Color.LightGray.copy(alpha = 0.6f), | ||
Color.LightGray.copy(alpha = 0.2f), | ||
Color.LightGray.copy(alpha = 0.6f), | ||
) | ||
|
||
// Start the animation transition | ||
val transition = rememberInfiniteTransition(label = "") | ||
val translateAnimation = transition.animateFloat( | ||
initialValue = 0f, | ||
targetValue = targetValue, | ||
animationSpec = infiniteRepeatable( | ||
animation = tween(800), | ||
repeatMode = RepeatMode.Reverse, | ||
), | ||
label = "", | ||
) | ||
|
||
// Return a linear gradient brush | ||
Brush.linearGradient( | ||
colors = shimmerColors, | ||
start = Offset.Zero, | ||
end = Offset(x = translateAnimation.value, y = translateAnimation.value), | ||
) | ||
} else { | ||
// If shimmer is turned off, return a transparent brush | ||
Brush.linearGradient( | ||
colors = listOf(Color.Transparent, Color.Transparent), | ||
start = Offset.Zero, | ||
end = Offset.Zero, | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
ui/src/main/java/com/seugi/ui/component/SeugiMemberListLoading.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package com.seugi.ui.component | ||
|
||
import androidx.compose.foundation.background | ||
import androidx.compose.foundation.layout.Box | ||
import androidx.compose.foundation.layout.Row | ||
import androidx.compose.foundation.layout.Spacer | ||
import androidx.compose.foundation.layout.fillMaxWidth | ||
import androidx.compose.foundation.layout.height | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.foundation.layout.size | ||
import androidx.compose.foundation.layout.width | ||
import androidx.compose.foundation.shape.CircleShape | ||
import androidx.compose.foundation.shape.RoundedCornerShape | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.unit.dp | ||
import com.seugi.designsystem.component.shimmerEffectBrush | ||
|
||
@Composable | ||
fun SeugiMemberListLoading(modifier: Modifier = Modifier) { | ||
Row( | ||
modifier = modifier | ||
.fillMaxWidth() | ||
.height(56.dp), | ||
verticalAlignment = Alignment.CenterVertically, | ||
) { | ||
Row( | ||
modifier = Modifier.padding( | ||
horizontal = 16.dp, | ||
vertical = 10.dp, | ||
), | ||
verticalAlignment = Alignment.CenterVertically, | ||
) { | ||
Box( | ||
modifier = Modifier | ||
.size(36.dp) | ||
.background( | ||
brush = shimmerEffectBrush(), | ||
shape = CircleShape, | ||
), | ||
) | ||
Spacer(modifier = Modifier.width(16.dp)) | ||
|
||
Box( | ||
modifier = Modifier | ||
.width(52.dp) | ||
.height(21.dp) | ||
.background( | ||
brush = shimmerEffectBrush(), | ||
shape = RoundedCornerShape(12.dp), | ||
), | ||
) | ||
Spacer(modifier = Modifier.weight(1f)) | ||
} | ||
} | ||
} |