### Include Compose Symphony as a Local Module Source: https://github.com/jay3-yy/compose-symphony/blob/main/README_EN.md This section provides instructions on how to integrate the Compose Symphony library into your Android project by including it as a local module. It details the necessary modifications to `settings.gradle.kts` and `build.gradle.kts` files. ```kotlin // In settings.gradle.kts: include(":compose-symphony") project(":compose-symphony").projectDir = file("path/to/Compose-Symphony/library") // In your app's build.gradle.kts: implementation(project(":compose-symphony")) ``` -------------------------------- ### Dissolvable Video Card with Particle Effect (Kotlin) Source: https://context7.com/jay3-yy/compose-symphony/llms.txt Wraps any composable content to enable a 'Thanos snap' particle dissolution effect using OpenGL. It captures the content's pixels and animates them as physics-simulated particles. The component requires a unique ID for coordination and a callback for when the dissolve animation completes. ```kotlin import com.compose.symphony.particle.DissolvableVideoCard import com.compose.symphony.particle.DissolveAnimationManager @Composable fun DissolvableItem(item: Item, onRemoved: () -> Unit) { var isDissolving by remember { mutableStateOf(false) } var isVisible by remember { mutableStateOf(true) } if (isVisible) { DissolvableVideoCard( isDissolving = isDissolving, onDissolveComplete = { isVisible = false onRemoved() }, cardId = item.id, // Unique ID for jiggle coordination modifier = Modifier.fillMaxWidth() ) { // Any composable content to dissolve Card( modifier = Modifier .fillMaxWidth() .padding(16.dp), elevation = CardDefaults.cardElevation(4.dp) ) { Row( modifier = Modifier.padding(16.dp), verticalAlignment = Alignment.CenterVertically ) { AsyncImage( model = item.thumbnail, modifier = Modifier.size(80.dp) ) Spacer(modifier = Modifier.width(16.dp)) Column { Text(item.title, style = MaterialTheme.typography.titleMedium) Text(item.subtitle, style = MaterialTheme.typography.bodySmall) } } } } // Trigger dissolution on swipe or button SwipeToDismiss( onDismiss = { isDissolving = true } ) } } // Add jiggle effect to other cards while one is dissolving Card( modifier = Modifier.jiggleOnDissolve( cardId = "other-card-id", enabled = true ) ) { // This card will jiggle when another card is dissolving } ``` -------------------------------- ### Coin Success Animation in Kotlin Source: https://context7.com/jay3-yy/compose-symphony/llms.txt Displays a 3D-like spinning coin reward animation using CoinSuccessAnimation. It supports single or double coin displays and is triggered by a coin count. Requires `com.compose.symphony.animation.CoinSuccessAnimation`. ```kotlin import com.compose.symphony.animation.CoinSuccessAnimation import androidx.compose.runtime.* import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.ui.Modifier @Composable fun CoinRewardOverlay(coinCount: Int) { var showAnimation by remember { mutableStateOf(false) } LaunchedEffect(coinCount) { if (coinCount > 0) { showAnimation = true } } Box( modifier = Modifier.fillMaxSize(), contentAlignment = Alignment.Center ) { CoinSuccessAnimation( visible = showAnimation, coinCount = coinCount, // 1 = single coin, 2+ = double coin display onAnimationEnd = { showAnimation = false } ) } } ``` -------------------------------- ### iOS Spring Animation Presets for Compose Source: https://context7.com/jay3-yy/compose-symphony/llms.txt Utilizes `iOSSpringSpecs` to apply pre-tuned spring animation specifications that match iOS interaction patterns. These presets are designed for various UI elements like buttons, cards, drawers, and list items, offering specific damping ratios and stiffness values for organic animations. ```kotlin import com.compose.symphony.animation.iOSSpringSpecs import androidx.compose.animation.core.animateFloatAsState // Button press animation with quick response and slight bounce val buttonScale by animateFloatAsState( targetValue = if (isPressed) 0.92f else 1f, animationSpec = iOSSpringSpecs.ButtonPress, // dampingRatio=0.6f, stiffness=400f label = "buttonScale" ) // Card expansion with moderate bounce for liveliness val cardHeight by animateFloatAsState( targetValue = if (isExpanded) 400f else 100f, animationSpec = iOSSpringSpecs.CardExpand, // dampingRatio=0.8f, stiffness=300f label = "cardHeight" ) // Page transition with no bounce for smooth navigation val pageOffset by animateFloatAsState( targetValue = if (showNextPage) -screenWidth else 0f, animationSpec = iOSSpringSpecs.PageTransition, // dampingRatio=1f (critical damping) label = "pageOffset" ) // Drawer animation with slight bounce val drawerOffset by animateFloatAsState( targetValue = if (isDrawerOpen) 0f else -drawerWidth, animationSpec = iOSSpringSpecs.Drawer, // dampingRatio=0.7f, stiffness=350f label = "drawerOffset" ) // List item entrance with bouncy effect val itemAlpha by animateFloatAsState( targetValue = if (isVisible) 1f else 0f, animationSpec = iOSSpringSpecs.ListItem, // dampingRatio=0.65f, stiffness=300f label = "itemAlpha" ) ``` -------------------------------- ### Like Burst Animation in Kotlin Source: https://context7.com/jay3-yy/compose-symphony/llms.txt Implements an Instagram-style heart explosion effect using LikeBurstAnimation. It triggers on a button click and displays particles radiating outwards. Requires `com.compose.symphony.animation.LikeBurstAnimation`. ```kotlin import com.compose.symphony.animation.LikeBurstAnimation import androidx.compose.runtime.* import androidx.compose.material.* import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.Favorite import androidx.compose.material.icons.outlined.FavoriteBorder import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color import androidx.compose.ui.unit.dp @Composable fun LikeButton() { var isLiked by remember { mutableStateOf(false) } var showBurst by remember { mutableStateOf(false) } Box(contentAlignment = Alignment.Center) { // Heart icon IconButton( onClick = { if (!isLiked) { isLiked = true showBurst = true } } ) { Icon( imageVector = if (isLiked) Icons.Filled.Favorite else Icons.Outlined.FavoriteBorder, contentDescription = "Like", tint = if (isLiked) Color(0xFFFF2D55) else Color.Gray ) } // Particle burst overlay LikeBurstAnimation( visible = showBurst, onAnimationEnd = { showBurst = false } ) } } ``` -------------------------------- ### Damped Drag Animation State for Horizontal Paging (Kotlin) Source: https://context7.com/jay3-yy/compose-symphony/llms.txt Implements iOS-style physics for horizontal paging with rubber-band overscroll and velocity-aware snapping. It requires an initial index, item count, and an optional callback for index changes. The state can be updated programmatically or synced with external pager states. ```kotlin import com.compose.symphony.physics.rememberDampedDragAnimationState import com.compose.symphony.physics.horizontalDragGesture import androidx.compose.ui.platform.LocalDensity @Composable fun SwipeableCarousel() { val cardWidth = 300.dp val cardWidthPx = with(LocalDensity.current) { cardWidth.toPx() } val pages = listOf(Color.Red, Color.Orange, Color.Blue) val dragState = rememberDampedDragAnimationState( initialIndex = 0, itemCount = pages.size, onIndexChanged = { newIndex -> println("Swiped to page: $newIndex") } ) Box( modifier = Modifier .width(cardWidth) .height(400.dp) .horizontalDragGesture(dragState, cardWidthPx) ) { pages.forEachIndexed { index, color -> val offset = (index - dragState.value) * cardWidthPx val distanceFromCenter = abs(index - dragState.value) val scale = (1f - (distanceFromCenter * 0.1f)).coerceAtLeast(0.8f) Box( modifier = Modifier .fillMaxSize() .graphicsLayer { translationX = offset scaleX = scale scaleY = scale } .clip(RoundedCornerShape(24.dp)) .background(color), contentAlignment = Alignment.Center ) { Text("Page ${index + 1}", color = Color.White) } } } // Programmatic navigation Button(onClick = { dragState.updateIndex(2) }) { Text("Go to Page 3") } // Sync with external pager state LaunchedEffect(externalPagerPosition) { dragState.snapTo(externalPagerPosition.toFloat()) } } ``` -------------------------------- ### Implement 3D Perspective Tilt Animation in Compose Source: https://context7.com/jay3-yy/compose-symphony/llms.txt The 'perspectiveTilt' modifier provides a realistic 3D card tilting effect based on press position. It requires tracking the press offset and a boolean for the pressed state. Key parameters are 'pressOffset', 'isPressed', and 'maxRotation'. ```kotlin import com.compose.symphony.animation.perspectiveTilt import androidx.compose.ui.geometry.Offset var pressOffset by remember { mutableStateOf(Offset.Zero) } var isPressed by remember { mutableStateOf(false) } Card( modifier = Modifier .size(200.dp) .pointerInput(Unit) { detectTapGestures( onPress = { offset -> // Normalize offset to -1..1 range relative to center val centerX = size.width / 2f val centerY = size.height / 2f pressOffset = Offset( (offset.x - centerX) / centerX, (offset.y - centerY) / centerY ) isPressed = true tryAwaitRelease() isPressed = false } ) } .perspectiveTilt( pressOffset = pressOffset, isPressed = isPressed, maxRotation = 8f // Maximum tilt angle in degrees ) ) { Box( modifier = Modifier.fillMaxSize(), contentAlignment = Alignment.Center ) { Text("Tilt Me!") } } ``` -------------------------------- ### Animated List Item Entrance with animateEnter Source: https://context7.com/jay3-yy/compose-symphony/llms.txt The animateEnter modifier provides staggered wave entrance animations for list items in LazyColumn or LazyRow. It supports slide-up, scale, and fade effects, with customizable stagger delay, key reset, initial offset, and animation enablement. It's useful for enhancing the visual appeal of dynamic lists. ```kotlin import com.compose.symphony.animation.animateEnter import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.itemsIndexed LazyColumn { itemsIndexed(items) { index, item -> Card( modifier = Modifier .fillMaxWidth() .padding(horizontal = 16.dp, vertical = 8.dp) .animateEnter( index = index, // Used for stagger delay (30ms per item, max 200ms) key = item.id, // Reset animation when key changes initialOffsetY = 60f, // Start 60px below final position animationEnabled = true // Toggle animation on/off ) ) { Text(item.title) } } } // Disable animation for performance in certain scenarios Card( modifier = Modifier.animateEnter( index = 0, animationEnabled = false // Instantly visible, no animation ) ) { Text("Static Card") } ``` -------------------------------- ### Implement Damped Dragging with Compose Symphony Source: https://github.com/jay3-yy/compose-symphony/blob/main/README_EN.md This snippet demonstrates how to use `DampedDragAnimationState` from Compose Symphony to create a fluid dragging experience, suitable for components like tab bars or card lists. It manages the dragging state and updates the UI based on user input. ```kotlin import androidx.compose.foundation.gestures.horizontalDragGesture import androidx.compose.foundation.layout.Box import androidx.compose.runtime.Composable import androidx.compose.runtime.remember import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.graphicsLayer import com.compose.symphony.physics.rememberDampedDragAnimationState @Composable fun LiquidDragExample(widthPx: Float) { val dragState = rememberDampedDragAnimationState( initialIndex = 0, itemCount = 3, onIndexChanged = { index -> /* Handle Selection */ } ) Box( modifier = Modifier .horizontalDragGesture(dragState, widthPx) .graphicsLayer { translationX = -dragState.value * widthPx } ) { // Content for the draggable items } } ``` -------------------------------- ### Add Dissolve Effect to Composable Content Source: https://github.com/jay3-yy/compose-symphony/blob/main/README_EN.md This code shows how to integrate the `DissolveEffect` from Compose Symphony to create a disintegration animation, similar to the 'Thanos Snap' effect. It allows any Composable content to become dissolvable, triggering a callback upon completion. ```kotlin import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember import androidx.compose.runtime.setValue import com.compose.symphony.particle.DissolvableVideoCard // Assuming this is the component @Composable fun DissolveEffectExample() { var isDissolving by remember { mutableStateOf(false) } DissolvableVideoCard( isDissolving = isDissolving, onDissolveComplete = { // Logic to execute after dissolve completes, e.g., remove data from list } ) { // Content to be dissolved, e.g., VideoCardContent() // VideoCardContent() } } ``` -------------------------------- ### Triple Success Animation in Kotlin Source: https://context7.com/jay3-yy/compose-symphony/llms.txt Implements a celebratory firework effect with expanding particles and bouncing emojis using TripleSuccessAnimation. Designed for significant achievements like 'triple combo'. Requires `com.compose.symphony.animation.TripleSuccessAnimation`. ```kotlin import com.compose.symphony.animation.TripleSuccessAnimation import androidx.compose.runtime.* import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.ui.Modifier // Assume hasCompletedTriple is a boolean state variable defined elsewhere // var hasCompletedTriple by remember { mutableStateOf(false) } @Composable fun CelebrationOverlay() { var showCelebration by remember { mutableStateOf(false) } // Trigger on achievement LaunchedEffect(hasCompletedTriple) { if (hasCompletedTriple) { showCelebration = true } } if (showCelebration) { Box( modifier = Modifier.fillMaxSize(), contentAlignment = Alignment.Center ) { TripleSuccessAnimation( visible = true, onAnimationEnd = { showCelebration = false } ) } } } ``` -------------------------------- ### Apply Bouncy Clickable Modifier for Enhanced Interactions Source: https://github.com/jay3-yy/compose-symphony/blob/main/README_EN.md This snippet demonstrates how to apply the `bouncyClickable` modifier provided by Compose Symphony to any Composable. This modifier adds a subtle scaling animation on click, providing visual feedback and a premium feel, similar to iOS button interactions. ```kotlin import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip import androidx.compose.ui.unit.dp import com.compose.symphony.animation.bouncyClickable @Composable fun BouncyClickExample() { Box( modifier = Modifier .clip(RoundedCornerShape(12.dp)) .bouncyClickable(scaleDown = 0.92f) { // Action to perform on click println("Button Clicked!") } ) { Text("Press Me") } } ``` -------------------------------- ### Bouncy Clickable Modifier for Compose Source: https://context7.com/jay3-yy/compose-symphony/llms.txt Adds Apple Music-style press feedback to any composable using the `bouncyClickable` modifier. It provides a smooth scale-down effect on press and a bounce back on release, with customizable `scaleDown` values for different interaction intensities. ```kotlin import com.compose.symphony.animation.bouncyClickable import androidx.compose.foundation.layout.Box import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.ui.draw.clip import androidx.compose.ui.unit.dp // Basic bouncy button - default scale 0.90f Box( modifier = Modifier .size(120.dp) .clip(RoundedCornerShape(24.dp)) .background(Color(0xFF007AFF)) .bouncyClickable { // Handle click action println("Button clicked!") }, contentAlignment = Alignment.Center ) { Text("Press Me", color = Color.White) } // Deep press effect for confirmation buttons Box( modifier = Modifier .fillMaxWidth() .height(60.dp) .clip(RoundedCornerShape(12.dp)) .background(Color(0xFFFF3B30)) .bouncyClickable(scaleDown = 0.85f) { // Confirm action }, contentAlignment = Alignment.Center ) { Text("Delete", color = Color.White) } // Subtle press for list items Box( modifier = Modifier .fillMaxWidth() .padding(16.dp) .clip(RoundedCornerShape(8.dp)) .background(Color.White) .bouncyClickable(scaleDown = 0.98f) { // Navigate to detail } ) { Text("List Item") } ``` -------------------------------- ### Gravity Drop Animation with gravityDrop Source: https://context7.com/jay3-yy/compose-symphony/llms.txt The gravityDrop modifier simulates a realistic falling and bouncing animation, ideal for dialogs, notifications, or dramatic entrance effects. It allows configuration of the initial drop position and the number of bounces, creating an engaging visual experience. ```kotlin import com.compose.symphony.animation.gravityDrop // Dialog with gravity drop entrance var showDialog by remember { mutableStateOf(false) } if (showDialog) { Box( modifier = Modifier .fillMaxSize() .background(Color.Black.copy(alpha = 0.5f)), contentAlignment = Alignment.Center ) { Card( modifier = Modifier .width(300.dp) .gravityDrop( enabled = true, initialOffsetY = -200f, // Drop from 200px above bounceCount = 2 // Bounce twice before settling ) ) { Column(modifier = Modifier.padding(24.dp)) { Text("Attention!", style = MaterialTheme.typography.headlineMedium) Spacer(modifier = Modifier.height(16.dp)) Text("This dialog dropped in with physics!") Spacer(modifier = Modifier.height(24.dp)) Button(onClick = { showDialog = false }) { Text("Dismiss") } } } } } ``` -------------------------------- ### Add Bounce In Animation with Compose Source: https://context7.com/jay3-yy/compose-symphony/llms.txt The 'bounceIn' modifier applies enter/exit animations with a spring overshoot effect. It's suitable for elements that appear or disappear, such as icons or toggle states. The 'visible' and 'initialOffsetY' parameters control its behavior. ```kotlin import com.compose.symphony.animation.bounceIn var selectedTab by remember { mutableIntStateOf(0) } Row( modifier = Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.SpaceEvenly ) { listOf("Home", "Search", "Profile").forEachIndexed { index, label -> Column( horizontalAlignment = Alignment.CenterHorizontally, modifier = Modifier .clickable { selectedTab = index } .padding(16.dp) ) { Icon( imageVector = icons[index], contentDescription = label, modifier = Modifier.bounceIn( visible = selectedTab == index, initialOffsetY = 30f // Bounce up from 30px below ) ) Text(label) } } } ``` -------------------------------- ### Apply Breathing Animation with Compose Source: https://context7.com/jay3-yy/compose-symphony/llms.txt The 'breathe' modifier creates a continuous pulsing effect. It's useful for indicators, loading states, or drawing attention. Parameters include 'enabled', 'minScale', 'maxScale', and 'durationMs'. ```kotlin import com.compose.symphony.animation.breathe // Recording indicator with breathing effect Box( modifier = Modifier .size(16.dp) .clip(CircleShape) .background(Color.Red) .breathe( enabled = isRecording, minScale = 0.95f, // Minimum scale factor maxScale = 1.05f, // Maximum scale factor durationMs = 2000 // Full cycle duration in milliseconds ) ) // Glowing "live" badge Box( modifier = Modifier .background(Color.Red, RoundedCornerShape(4.dp)) .padding(horizontal = 8.dp, vertical = 4.dp) .breathe(enabled = true, durationMs = 1500) ) { Text("LIVE", color = Color.White, fontSize = 12.sp) } ``` -------------------------------- ### Pendulum Swing Animation with pendulumSwing Source: https://context7.com/jay3-yy/compose-symphony/llms.txt The pendulumSwing modifier creates an attention-grabbing oscillating motion that naturally decays, suitable for error states or drawing user focus to specific elements. The animation can be triggered by changing a specified value and has a configurable initial swing angle. ```kotlin import com.compose.symphony.animation.pendulumSwing var errorTrigger by remember { mutableStateOf(0) } // Text field with shake on error OutlinedTextField( value = text, onValueChange = { text = it }, isError = hasError, modifier = Modifier .fillMaxWidth() .pendulumSwing( trigger = errorTrigger, // Change this value to trigger animation initialAngle = 15f // Maximum swing angle in degrees ) ) // Trigger shake on validation error Button(onClick = { if (text.isEmpty()) { hasError = true errorTrigger++ // Increment to retrigger animation } }) { Text("Submit") } ``` -------------------------------- ### Rubber Band Overscroll Effect with rubberBand Source: https://context7.com/jay3-yy/compose-symphony/llms.txt The rubberBand modifier implements an iOS-style elastic resistance effect for dragging gestures past boundaries. It uses logarithmic damping to provide a natural, "sticky" feel, enhancing user interaction with scrollable content or draggable areas. ```kotlin import com.compose.symphony.animation.rubberBand import androidx.compose.foundation.gestures.detectVerticalDragGestures import androidx.compose.ui.input.pointer.pointerInput var dragOffset by remember { mutableFloatStateOf(0f) } Box( modifier = Modifier .fillMaxWidth() .height(400.dp) .pointerInput(Unit) { detectVerticalDragGestures( onDragEnd = { // Animate back to 0 dragOffset = 0f }, onVerticalDrag = { _, dragAmount -> dragOffset += dragAmount } ) } .rubberBand( dragOffset = dragOffset, resistance = 0.55f // 0-1, higher = more resistance ) ) { // Content that stretches with rubber band effect Column { repeat(10) { Text("Item $it", modifier = Modifier.padding(16.dp)) } } } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.