-
-
Save rahat14/2751327fa5522b8b5a370b4088eb882e to your computer and use it in GitHub Desktop.
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
@Composable | |
fun MainScreen() { | |
Column( | |
modifier = Modifier | |
.fillMaxSize() | |
.background(MaterialTheme.colorScheme.surface), | |
verticalArrangement = Arrangement.Center, | |
horizontalAlignment = Alignment.CenterHorizontally | |
) { | |
AnimatedBorderCard( | |
modifier = Modifier | |
.fillMaxWidth() | |
.padding(24.dp), | |
shape = RoundedCornerShape(8.dp), | |
gradient = Brush.sweepGradient(listOf(Color.Magenta, Color.Cyan)), | |
onCardClick = {} | |
) { | |
Column(modifier = Modifier.padding(24.dp)) { | |
Text( | |
fontSize = MaterialTheme.typography.displaySmall.fontSize, | |
text = "Kaan Enes KAPICI", | |
fontWeight = FontWeight.Bold | |
) | |
Spacer(modifier = Modifier.height(12.dp)) | |
Text( | |
fontSize = MaterialTheme.typography.bodyMedium.fontSize, | |
text = "Türk Telekom| Innova Mobile Application Engineer Specialist \uD83D\uDCBB | Technical Writer \uD83D\uDCD6 | Speaker \uD83C\uDF99\uFE0F", | |
) | |
} | |
} | |
} | |
} | |
@Composable | |
fun AnimatedBorderCard( | |
modifier: Modifier = Modifier, | |
shape: Shape = RoundedCornerShape(size = 0.dp), | |
borderWidth: Dp = 2.dp, | |
gradient: Brush = Brush.sweepGradient(listOf(Color.Gray, Color.White)), | |
animationDuration: Int = 10000, | |
onCardClick: () -> Unit = {}, | |
content: @Composable () -> Unit | |
) { | |
val infiniteTransition = rememberInfiniteTransition(label = "Infinite Color Animation") | |
val degrees by infiniteTransition.animateFloat( | |
initialValue = 0f, | |
targetValue = 360f, | |
animationSpec = infiniteRepeatable( | |
animation = tween(durationMillis = animationDuration, easing = LinearEasing), | |
repeatMode = RepeatMode.Restart | |
), | |
label = "Infinite Colors" | |
) | |
Surface( | |
modifier = modifier | |
.clip(shape) | |
.clickable { onCardClick() }, | |
shape = shape | |
) { | |
Surface( | |
modifier = Modifier | |
.fillMaxWidth() | |
.padding(borderWidth) | |
.drawWithContent { | |
rotate(degrees = degrees) { | |
drawCircle( | |
brush = gradient, | |
radius = size.width, | |
blendMode = BlendMode.SrcIn, | |
) | |
} | |
drawContent() | |
}, | |
color = MaterialTheme.colorScheme.surface, | |
shape = shape | |
) { | |
content() | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment