Created
January 15, 2025 06:36
-
-
Save Rohit-554/d4d7ff250d0dbb2cf93f3e411b38c949 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 StackedUI(){ | |
| val cardColors = listOf( | |
| R.drawable.user_1, | |
| R.drawable.dog_png, | |
| R.drawable.user_2, | |
| R.drawable.user_3, | |
| R.drawable.user_4, | |
| ) | |
| Column( | |
| modifier = Modifier.fillMaxSize().horizontalScroll(rememberScrollState()), | |
| verticalArrangement = Arrangement.spacedBy(16.dp) | |
| ) { | |
| Box(modifier = Modifier.fillMaxWidth()) { | |
| cardColors.forEachIndexed { index, images -> | |
| Image( | |
| painter = painterResource(images), | |
| contentDescription = "Dog", | |
| contentScale = ContentScale.FillBounds, | |
| modifier = Modifier | |
| .offset(x = (index * 60).dp) | |
| .size(120.dp) | |
| .aspectRatio(1f) | |
| .zIndex(-index.toFloat()) | |
| .padding(8.dp) | |
| .graphicsLayer { | |
| compositingStrategy = CompositingStrategy.Offscreen | |
| } | |
| .drawWithCache { | |
| val path = Path() | |
| path.addOval( | |
| Rect( | |
| topLeft = Offset.Zero, | |
| bottomRight = Offset(size.width, size.height) | |
| ) | |
| ) | |
| onDrawWithContent { | |
| drawCircle( | |
| // You can change these colors or make them dynamic based on index | |
| Color(0xFFE3F2FD), // Light blue background | |
| radius = size.width / 2 | |
| ) | |
| clipPath(path) { | |
| [email protected]() | |
| } | |
| val dotSize = size.width / 8f | |
| drawCircle( | |
| Color.Black, | |
| radius = dotSize, | |
| center = Offset( | |
| x = size.width - dotSize, | |
| y = size.height - dotSize | |
| ), | |
| blendMode = BlendMode.Clear | |
| ) | |
| drawCircle( | |
| Color(0xFF6EC531), | |
| radius = dotSize * 0.8f, | |
| center = Offset( | |
| x = size.width - dotSize, | |
| y = size.height - dotSize | |
| ) | |
| ) | |
| } | |
| } | |
| ) | |
| } | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment