|
| 1 | +<div align="center"><img width="300px" height="300px" src="https://raw.githubusercontent.com/omkar-tenkale/ExplodingComposable/master/art/exploding-composable.webp"/></div> |
| 2 | +<h1 align="center">💢 ExplodingComposable</h1> |
| 3 | +<h4 align="center">A Jetpack Compose utility library to add explosive dust effect animation to any composable</h4> |
1 | 4 |
|
2 | | - |
| 5 | +<div align="center"> |
| 6 | + <img src="https://img.shields.io/maven-central/v/dev.omkartenkale/exploding-composable" /> |
| 7 | + <a href=""> |
| 8 | + <img src="https://img.shields.io/badge/PRs-welcome-brightgreen.svg"/> |
| 9 | + </a> |
| 10 | +</div> |
| 11 | + |
| 12 | +<div align="center"> |
| 13 | + <sub>Based on |
| 14 | + <a href="https://github.com/tyrantgit/ExplosionField">ExplosionField</a> by |
| 15 | + <a href="https://github.com/tyrantgit">@tyrantgit</a> |
| 16 | +</div> |
| 17 | + |
| 18 | +<br/> |
| 19 | + |
| 20 | +## 💻 Installation |
| 21 | + |
| 22 | +1. Add this to `build.gradle` of project gradle dependency |
| 23 | + |
| 24 | +```groovy |
| 25 | +allprojects { |
| 26 | + repositories { |
| 27 | + ... |
| 28 | + maven { url 'https://jitpack.io' } |
| 29 | + } |
| 30 | +} |
| 31 | +``` |
| 32 | + |
| 33 | +2. In `build.gradle` of `app` module, include this dependency |
| 34 | + |
| 35 | +```groovy |
| 36 | +implementation "com.github.omkar-tenkale:ExplodingComposable:1.0.0" |
| 37 | +``` |
| 38 | + |
| 39 | +You can find latest version and changelogs in the [releases](https://github.com/omkar-tenkale/ExplodingComposable/releases). |
| 40 | + |
| 41 | +<br/> |
| 42 | + |
| 43 | +## ❓ Usage |
| 44 | + |
| 45 | +Wrap the content to explode in [`Explodable`](https://github.com/omkar-tenkale/ExplodingComposable/blob/master/explodable/src/main/java/dev/omkartenkale/explodable/Explodable.kt) and trigger the explosion with `explosionController.explode()` |
| 46 | + |
| 47 | +```kotlin |
| 48 | +val explosionController = rememberExplosionController() |
| 49 | + |
| 50 | +Explodable(controller = explosionController) { |
| 51 | + //Content to explode |
| 52 | + Box(modifier = Modifier |
| 53 | + .size(100.dp) |
| 54 | + .background(Color.Black) |
| 55 | + .clickable { explosionController.explode() }) |
| 56 | +} |
| 57 | +``` |
| 58 | + |
| 59 | +<br/> |
| 60 | + |
| 61 | +## 🎨 Customization |
| 62 | +ExplodingComposable offers a variety of customizations |
| 63 | + |
| 64 | +```kotlin |
| 65 | +val explosionController = rememberExplosionController() |
| 66 | + |
| 67 | +Explodable( |
| 68 | + //Standard compose modifier |
| 69 | + modifier = Modifier, |
| 70 | + |
| 71 | + // Control the explosion state with an instance of ExplosionController |
| 72 | + // You can access it using rememberExplosionController() method |
| 73 | + // Provides methods controller.explode() and controller.reset() |
| 74 | + controller = explosionController, |
| 75 | + |
| 76 | + // Control the animation with these params |
| 77 | + animationSpec = ExplosionAnimationSpec( |
| 78 | + // The higher the number, the bigger the explosion |
| 79 | + explosionPower = 2f, |
| 80 | + // Duration for the particle explosion |
| 81 | + explosionDurationMs = 750, |
| 82 | + // Duration for the shake effect before explosion |
| 83 | + shakeDurationMs = 250 |
| 84 | + ), |
| 85 | + |
| 86 | + // Callback to fire when explosion is finished |
| 87 | + onExplode = { |
| 88 | + |
| 89 | + }, |
| 90 | + |
| 91 | + // To control the explosion manually, use this param [0f-1f] |
| 92 | + currentProgress = progress, |
| 93 | + |
| 94 | + // The composable to explode |
| 95 | + content = { |
| 96 | + |
| 97 | + } |
| 98 | +) |
| 99 | +``` |
| 100 | + |
| 101 | +## 📱 Demo |
| 102 | + |
| 103 | +Download the [sample app](https://github.com/omkar-tenkale/ExplodingComposable/releases/download/1.0.0/ExplodingComposableDemo.apk) |
| 104 | +or explore the [sample project](https://github.com/omkar-tenkale/ExplodingComposable/tree/master/app/src/main/java/dev/omkartenkale/explodable/sample) |
| 105 | + |
| 106 | +## 📃 License |
| 107 | +Licensed under Apache license 2.0 |
| 108 | + |
| 109 | +This work is derived from [ExplosionField](https://github.com/tyrantgit/ExplosionField) |
| 110 | + |
0 commit comments