-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a257f23
commit 932548a
Showing
8 changed files
with
127 additions
and
29 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
package model | ||
|
||
data class ChatMessage(val text: String, val isSender: Boolean) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
package ui.component | ||
|
||
import androidx.compose.animation.core.FastOutSlowInEasing | ||
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.Spacer | ||
import androidx.compose.foundation.layout.fillMaxWidth | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.foundation.layout.size | ||
import androidx.compose.foundation.shape.RoundedCornerShape | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.getValue | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.geometry.Offset | ||
import androidx.compose.ui.graphics.Brush | ||
import androidx.compose.ui.graphics.Color | ||
import androidx.compose.ui.unit.dp | ||
import theme.PrimaryColor | ||
|
||
val ShimmerColorShades = listOf( | ||
Color.LightGray.copy(0.9f), | ||
PrimaryColor.copy(0.2f), | ||
Color.LightGray.copy(0.9f) | ||
) | ||
@Composable | ||
fun ShimmerAnimation( | ||
) { | ||
/* | ||
Create InfiniteTransition | ||
which holds child animation like [Transition] | ||
animations start running as soon as they enter | ||
the composition and do not stop unless they are removed | ||
*/ | ||
val transition = rememberInfiniteTransition() | ||
val translateAnim by transition.animateFloat( | ||
/* | ||
Specify animation positions, | ||
initial Values 0F means it | ||
starts from 0 position | ||
*/ | ||
initialValue = 0f, | ||
targetValue = 1000f, | ||
animationSpec = infiniteRepeatable( | ||
|
||
|
||
// Tween Animates between values over specified [durationMillis] | ||
tween(durationMillis = 1200, easing = FastOutSlowInEasing), | ||
RepeatMode.Reverse | ||
) | ||
) | ||
|
||
/* | ||
Create a gradient using the list of colors | ||
Use Linear Gradient for animating in any direction according to requirement | ||
start=specifies the position to start with in cartesian like system Offset(10f,10f) means x(10,0) , y(0,10) | ||
end = Animate the end position to give the shimmer effect using the transition created above | ||
*/ | ||
val brush = Brush.linearGradient( | ||
colors = ShimmerColorShades, | ||
start = Offset(10f, 10f), | ||
end = Offset(translateAnim, translateAnim) | ||
) | ||
|
||
ShimmerItem(brush = brush) | ||
} | ||
|
||
@Composable | ||
fun ShimmerItem( | ||
brush: Brush | ||
) { | ||
Spacer( | ||
modifier = Modifier | ||
.padding(top = 8.dp) | ||
.fillMaxWidth() | ||
.size(20.dp) | ||
.background(brush = brush, shape = RoundedCornerShape(8.dp)) | ||
) | ||
} |
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