Jetpack Compose version of FlipperControl for UWP and FlipperView for Android.

Overview

FlipperLayout for Jetpack Compose

Jetpack Compose version of FlipperControl for UWP and FlipperView for Android.

A composable that uses flip transition to change two states: front and back.

How to use

Currently you have to copy the source file FlipperLayout.kt to your project and make it work. Since it's quite simple I have no plan to publish to maven.

It's as simple as Jetpack Compose is:

First, define your composable function with your own content. Here we hoist event so this composable function is for displaying the right state.

@Composable
fun FlipperContent(
    flipperSide: FlipperLayoutSide,
    onFlipperSideChanged: () -> Unit
) {
    FlipperLayout(
        modifier = Modifier.clickable {
            onFlipperSideChanged()
        },
        flipperSide = flipperSide,
        animationSpec = tween(300)
    ) {
        val text = if (it == FlipperLayoutSide.Front) "Front" else "Back"
        Box(
            Modifier
                .fillMaxWidth(0.5f)
                .aspectRatio(1f)
        ) {
            Image(
                painter = painterResource(
                    if (it == FlipperLayoutSide.Front) {
                        R.drawable.image0
                    } else {
                        R.drawable.image1
                    }
                ),
                contentDescription = text,
                contentScale = ContentScale.Crop
            )
            Text(
                text.uppercase(),
                modifier = Modifier.padding(12.dp),
                fontWeight = FontWeight.Bold,
                color = Color.White
            )
        }
    }
}

Then we remember and control the state:

var flipperSide by remember {
    mutableStateOf(FlipperLayoutSide.Front)
}

FlipperContent(flipperSide) {
    flipperSide = flipperSide.flip()
}

And that's it!

You might also like...
A Kotlin library to use Jetpack Compose in Android and iOS. Allow to write UI for both in Kotin. Still experimental as many compose features are not yet available.
A Kotlin library to use Jetpack Compose in Android and iOS. Allow to write UI for both in Kotin. Still experimental as many compose features are not yet available.

Multiplatform Compose A Kotlin library to use Jetpack Compose in Android and iOS. Allow to write UI for both in Kotin. Still experimental as many comp

📱 WhatsApp clone project demonstrates modern Android development built with Jetpack Compose and Stream Chat SDK for Compose.
📱 WhatsApp clone project demonstrates modern Android development built with Jetpack Compose and Stream Chat SDK for Compose.

This is a WhatsApp clone app built with Jetpack Compose and Stream Chat SDK for Compose. The purpose of this repository is to demonstrate below: Imple

Jetpack Compose based project, used to stress-testing compose features / integrations and explore non-trivial functionality

Project containing Jetpack Compose samples For pagination & network images it uses CATAAS. Known issues Navigation-Compose Issue with fast tapping on

List-programminglanguage-compose - Simple implementation of a list of programming languages using LazyColumn and Coil in Jetpack Compose A Simple Blog App using Jetpack Compose, Flow, Navigation Compose, Room and Firebase
A Simple Blog App using Jetpack Compose, Flow, Navigation Compose, Room and Firebase

BlogCompose A Simple Blog App using Jetpack Compose, Flow, Navigation Compose, Room and Firebase Instructions Download your Firebase configuration fil

Android.compose.squircle - Android LightWeight Squircle Library for JetPack Compose

Android LightWeight Squircle Library for JetPack Compose Usage Based on Compose

Compose-Instagram-Profile-UI - Instagram profile screen UI using android jetpack compose
Compose-Instagram-Profile-UI - Instagram profile screen UI using android jetpack compose

Compose-Intsgram-Profile-UI Instagram profile screen UI using android jetpack co

Compose Curved-Scroll is an Android Jetpack Compose library made with ❤️
Compose Curved-Scroll is an Android Jetpack Compose library made with ❤️

Compose-Curved-Scroll-library Compose Curved-Scroll is an Android Jetpack Compos

Compose-html - An Android library which provides HTML support for Jetpack Compose texts
Compose-html - An Android library which provides HTML support for Jetpack Compose texts

HtmlCompose An Android library which provides HTML support for Jetpack Compose t

Owner
JuniperPhoton
Android developer.
JuniperPhoton
Compose-navigation - Set of utils to help with integrating Jetpack Compose and Jetpack's Navigation

Jetpack Compose Navigation Set of utils to help with integrating Jetpack Compose

Adam Kobus 5 Apr 5, 2022
Learn Jetpack Compose for Android by Examples. Learn how to use Jetpack Compose for Android App Development. Android’s modern toolkit for building native UI.

Learn Jetpack Compose for Android by Examples. Learn how to use Jetpack Compose for Android App Development. Android’s modern toolkit for building native UI.

MindOrks 382 Jan 5, 2023
Jetpack Compose Boids | Flocking Insect 🐜. bird or Fish simulation using Jetpack Compose Desktop 🚀, using Canvas API 🎨

?? ?? ?? Compose flocking Ants(boids) ?? ?? ?? Jetpack compose Boids | Flocking Insect. bird or Fish simulation using Jetpack Compose Desktop ?? , usi

Chetan Gupta 38 Sep 25, 2022
A collection of animations, compositions, UIs using Jetpack Compose. You can say Jetpack Compose cookbook or play-ground if you want!

Why Not Compose! A collection of animations, compositions, UIs using Jetpack Compose. You can say Jetpack Compose cookbook or play-ground if you want!

Md. Mahmudul Hasan Shohag 186 Jan 1, 2023
This is a sample app(For beginners - App #2) built using Jetpack Compose. It demonstrates the concept of State Hoisting in Jetpack Compose.

JetBMICalculator This is a sample app(For beginners - App #2) built using Jetpack Compose. It demonstrates the concept of State Hoisting in Jetpack Co

BHAVNA THACKER 3 Dec 31, 2022
Jetpack-Compose-Demo - Instagram Profile UI using Jetpack Compose

Jetpack-Compose-Demo Instagram Profile UI using Jetpack Compose

omar 1 Aug 11, 2022
Jetpack-compose-animations-examples - Cool animations implemented with Jetpack compose

Jetpack-compose-animations-examples This repository consists of 4 animations: St

Canopas Software 180 Jan 2, 2023
Jetpack-compose-uis - A collection of some UIs using Jetpack Compose. built using Katalog

Jetpack Compose UIs This is a collection of some UIs using Jetpack Compose. It i

Mori Atsushi 3 Dec 15, 2022
Kotlin Multiplaform version of this app can be found here: Thinkrchive-Mutliplatform

?? ThinkRchive Light Dark An app showing all details for various Lenovo Thinkpad models. Made to try out Jepack Compose for Android. Kotlin Multiplafo

Thinkrchive 81 Dec 16, 2022
An application that i developed with a aim of learning Jetpack compose and many other jetpack libraries

An application that i developed with a aim of learning Jetpack compose and many other jetpack libraries, The application make use of jikan Api which displays a list of animations,there more details and even trailers of the animations.

Odhiambo Brandy 10 Nov 23, 2022