Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/wajahatkarim3/flippable
A Jetpack Compose library for animating a flip transition between the front and back of something, such as a card.
https://github.com/wajahatkarim3/flippable
android android-development android-library android-ui android-ui-widgets flip-animation flipper flipview jetpack-android jetpack-compose kotlin kotlin-android kotlin-coroutines kotlin-library library
Last synced: 3 days ago
JSON representation
A Jetpack Compose library for animating a flip transition between the front and back of something, such as a card.
- Host: GitHub
- URL: https://github.com/wajahatkarim3/flippable
- Owner: wajahatkarim3
- License: apache-2.0
- Created: 2022-02-13T15:59:31.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2024-01-27T10:08:31.000Z (12 months ago)
- Last Synced: 2025-01-18T15:14:03.800Z (3 days ago)
- Topics: android, android-development, android-library, android-ui, android-ui-widgets, flip-animation, flipper, flipview, jetpack-android, jetpack-compose, kotlin, kotlin-android, kotlin-coroutines, kotlin-library, library
- Language: Kotlin
- Homepage: https://wajahatkarim3.github.io/Flippable
- Size: 5.15 MB
- Stars: 481
- Watchers: 3
- Forks: 34
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
💳 Flippable
A Jetpack Compose utility library to create flipping Composable views with 2 sides.
## Demo
https://user-images.githubusercontent.com/8867121/154115910-8e2d2661-97c0-4b5a-b27e-76857533afe6.mp4
## 💻 Installation
In `build.gradle` of `app` module, include this dependency
```groovy
implementation "com.wajahatkarim:flippable:x.y.z"
```
Please replace x, y and z with the latest version numbers ![](https://img.shields.io/maven-central/v/com.wajahatkarim/flippable).
Or you can find latest version and changelogs in the [releases](https://github.com/wajahatkarim3/Flippable/releases).
## ❓ UsageAdd the [`Flippable`](https://github.com/wajahatkarim3/Flippable/blob/main/flippable/src/main/java/com/wajahatkarim/flippable/Flippable.kt) composable and define the front and back side composable methods inside. That's it.
```kotlin
Flippable(
frontSide = {
// Composable content for the front side
},backSide = {
// Composable content for the back side
},flipController = rememberFlipController(),
// Other optional parameters
)
```The `FlippableController` allows you to programatically flip the view from any event or button click or any method call etc. There's a method `rememberFlipController()` to get an instance of `FlippableController`. If you want to use any key for the `remember`, you can do so by directly creating `FlippableController` yourself like the code below:
```kotlin
val flipController = remember { FlippableController() }val flipController1 = remember(key = "2") { FlippableController() }
```
## 🎨 Customization Parameters
If you'd like to discover what `Flippable` offers, here is an exhaustive description of customizable parameters.
```kotlin
val controller = rememberFlipController()
Flippable(
frontSide = {
// Composable content for the front side
},
backSide = {
// Composable content for the back side
},
// To manually controll the flipping, you would need an instance of FlippableController.
// You can access it using rememberFlipController() method.
// This provides methods like controller.flip(), controller.flipToFront(), controller.flipToBack() etc.
flipController = controller,
// The obvious one - if you have done Jetpack Compose before.
modifier = Modifier,
// The duration it takes for the flip transition in Milliseconds. Default is 400
flipDurationMs = 400,
// If true, this will flip the view when touched.
// If you want to programatically flip the view without touching, use FlippableController.
flipOnTouch = flipOnTouchEnabled,
// If false, flipping will be disabled completely.
// The flipping will not be triggered with either touch or with controller methods.
flipEnabled = flipEnabled,
// The Flippable is contained in a Box, so this tells
// the alignment to organize both Front and Back side composable.
contentAlignment = Alignment.TopCenter,
//If true, the Flippable will automatically flip back after
//duration defined in autoFlipDurationMs. By default, this is false..
autoFlip = false,
//The duration in Milliseconds after which auto-flip back animation will start. Default is 1 second.
autoFlipDurationMs = 1000,
// The animation type of flipping effect. Currently there are 4 animations.
// Horizontal Clockwise and Anti-Clockwise, Vertical Clockwise and Anti-Clockwise
// See animation types section below.
flipAnimationType = FlipAnimationType.HORIZONTAL_CLOCKWISE,
// The [GraphicsLayerScope.cameraDistance] for the flip animation.
// Sets the distance along the Z axis (orthogonal to the X/Y plane
// on which layers are drawn) from the camera to this layer.
cameraDistance = 30.0F,
// The listener which is triggered when flipping animation is finished.
onFlippedListener = { currentSide ->
// This is called when any flip animation is finished.
// This gives the current side which is visible now in Flippable.
}
)
```I encourage you to play around with the [sample app](https://github.com/wajahatkarim3/Flippable/blob/main/app/src/main/java/com/wajahatkarim/flippable_demo/MainActivity.kt) to get a better look and feel. It showcases advanced usage with customized parameters.
## 📄 API Documentation
Visit the [API documentation](https://wajahatkarim3.github.io/Flippable) of this library to get more information in detail.
## ⚙️ Animation Types### Horizontal Clockwise
![Kapture 2022-02-15 at 23 20 11](https://user-images.githubusercontent.com/8867121/154124561-2f6d6d2d-1f7a-4d85-92cd-c91f54b6f245.gif)### Horizontal Anti-Clockwise
![Kapture 2022-02-15 at 23 24 05](https://user-images.githubusercontent.com/8867121/154125061-f40fed57-d1d3-42ee-94cf-f0597ce12fee.gif)### Vertical Clockwise
![Kapture 2022-02-15 at 23 26 00](https://user-images.githubusercontent.com/8867121/154125376-496d2577-1c65-49bf-a1e1-0ba0aefcd0b0.gif)### Vertical Anti-Clockwise
![Kapture 2022-02-15 at 23 26 33](https://user-images.githubusercontent.com/8867121/154125464-f89f3196-466a-4be9-9874-cf78ba4729ac.gif)
## 👨 Developed By**Wajahat Karim**
[![Twitter](https://img.shields.io/badge/-twitter-grey?logo=twitter)](https://twitter.com/WajahatKarim)
[![Web](https://img.shields.io/badge/-web-grey?logo=appveyor)](https://wajahatkarim.com/)
[![Medium](https://img.shields.io/badge/-medium-grey?logo=medium)](https://medium.com/@wajahatkarim3)
[![Linkedin](https://img.shields.io/badge/-linkedin-grey?logo=linkedin)](https://www.linkedin.com/in/wajahatkarim/)
## 👍 How to Contribute
1. Fork it
2. Create your feature branch (git checkout -b my-new-feature)
3. Commit your changes (git commit -am 'Add some feature')
4. Push to the branch (git push origin my-new-feature)
5. Create new Pull Request
## 📃 LicenseCopyright 2022 Wajahat Karim
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License athttp://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.