A hobby project of mine needed Jetpack Compose Cards stacked on top of another.

Related tags

CardView CardStack
Overview

CardStack

A hobby project of mine needed Jetpack Compose Cards stacked on top of another. As I finished up the code, I decided to polish and release it as a library so here it is.

Usage

You can define a composable and create as many cards as you want by giving a card count.

val drawables = listOf(R.drawable.first, R.drawable.second, R.drawable.third, R.drawable.fourth)

CardStack(
    { index ->
        Image(
            painterResource(id = drawables[index]),
            contentDescription = "Same Card Type with Different Image",
            contentScale = ContentScale.Crop,
            modifier = Modifier.size(196.dp, 196.dp)
        )
    },
    cardCount = drawables.size
)

Alt Text

You can also define list of composables and create different card layouts.

CardStack(
    listOf(
        {
            Text(
                text = "First Card",
                textAlign = TextAlign.Center,
                modifier = Modifier.size(196.dp)
            )
        },
        {
            Image(
                painterResource(id = R.drawable.second),
                contentDescription = "Second Card Image",
                contentScale = ContentScale.Crop,
                modifier = Modifier.size(196.dp)
            )
        },
        {
            Column(
                horizontalAlignment = Alignment.CenterHorizontally,
                modifier = Modifier.size(196.dp)
            ) {
                Text(
                    text = "Third Card With Button",
                    textAlign = TextAlign.Center
                )
                Button(onClick = {}) { Text(text = "Button Text") }
            }
        },
        {
            Image(
                painterResource(id = R.drawable.fourth),
                contentDescription = "Fourth Card Image",
                contentScale = ContentScale.Crop,
                modifier = Modifier.size(196.dp)
            )
        })
)

Alt Text

Customization

You can define;

  • Card shape
  • Card border
  • Card elevation
  • Padding between cards
  • Animation duration
  • Orientation
CardStack(
	..,
	cardCount = drawables.size,
	cardShape = CircleShape,
	cardBorder = BorderStroke(2.dp, Color.White),
	cardElevation = 10.dp,
	paddingBetweenCards = 10.dp,
	animationDuration = 250,
	orientation = Orientation.Horizontal(
	    alignment = HorizontalAlignment.EndToStart,
	    animationStyle = HorizontalAnimationStyle.FromBottom
	)
)

Alt Text

Get the Library


allprojects {
	repositories {
		maven { url 'https://jitpack.io' }
	}
}
	

implementation 'com.github.omercemcicekli:CardStack:0.0.6'
	

License


The MIT License (MIT)
	
Copyright (c) 2022 Omer Cem Cicekli
	
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
	
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
	
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
	
You might also like...
Another-read-more-lib - Another read more library for android

another-read-more-lib 📖 Another read more library. Add it in your root build.gr

Library containing common animations needed for transforming ViewPager scrolling for Android v13+.
Library containing common animations needed for transforming ViewPager scrolling for Android v13+.

ViewPagerTransforms Library containing common animations needed for transforming ViewPager scrolling on Android v13+. This library is a rewrite of the

Renderers is an Android library created to avoid all the boilerplate needed to use a RecyclerView/ListView with adapters.
Renderers is an Android library created to avoid all the boilerplate needed to use a RecyclerView/ListView with adapters.

Renderers Renderers is an Android library created to avoid all the RecyclerView/Adapter boilerplate needed to create a list/grid of data in your app a

Library containing common animations needed for transforming ViewPager scrolling for Android v13+.
Library containing common animations needed for transforming ViewPager scrolling for Android v13+.

ViewPagerTransforms Library containing common animations needed for transforming ViewPager scrolling on Android v13+. This library is a rewrite of the

Force clear delaying & no longer needed Gradle tasks.
Force clear delaying & no longer needed Gradle tasks.

gradle-cleaner-intellij-plugin Force clear delaying & no longer needed Gradle tasks. Description Plugin for Intellij IDEA which performs simple comman

Generate Qr Code using ZXING with a logo if needed

QrGeneratorWithLogo Generate Qr Code using ZXING with a logo if needed Download the Helper file and use it 1- add zxing lib into your project implem

simple-flank is a Gradle plugin to use Flank in Android projects with no configuration needed

simple-flank simple-flank is a new gradle plugin with a clear focus: make the setup as simple as possible. Applied to any application or library modul

This project created just for help developer who want to and ability of read VISA, UNION PAY, HUMO, ATTO and some other cards data read.

If you enjoy my content, please consider supporting what I do. Thank you. By me a Coffee To get a Git project into your build: Step 1. Add the JitPack

Minimal example of how to safely share a file produced by a task in one project, with a task in another project.

How to share files across Gradle subprojects: A minimal example This is the Gradle project: . ├── producer │ └── build.gradle.kts ├── consumer │ └

A Tinder-like Android library to create the swipe cards effect. You can swipe left or right to like or dislike the content.

Swipecards Travis master: A Tinder-like cards effect as of August 2014. You can swipe left or right to like or dislike the content. The library create

ScratchView 7.0 0.0 L4 Java  repo is UX Design involving scratch cards like views which are scratched to reveal the information they conceal.
ScratchView 7.0 0.0 L4 Java repo is UX Design involving scratch cards like views which are scratched to reveal the information they conceal.

ScratchView Intro ScratchView repo is UX Design involving scratch cards like views which are scratched to reveal the information they conceal. There a

Sliding cards with pretty gallery effects.
Sliding cards with pretty gallery effects.

SlidingCard Sliding cards with pretty gallery effects. Download Include the following dependency in your build.gradle file. Gradle: repositories {

Accept PayPal and credit cards in your Android app

Important: PayPal Mobile SDKs are Deprecated. The APIs powering them will remain operational long enough for merchants to migrate, but the SDKs themse

ViewPager cards inspired by Duolingo
ViewPager cards inspired by Duolingo

ViewPagerCards ViewPager cards inspired by Duolingo From my blog post: https://rubensousa.github.io/2016/08/viewpagercards This is just a sample proje

ScratchView repo is UX Design involving scratch cards like views which are scratched to reveal the information they conceal.
ScratchView repo is UX Design involving scratch cards like views which are scratched to reveal the information they conceal.

ScratchView Intro ScratchView repo is UX Design involving scratch cards like views which are scratched to reveal the information they conceal. There a

A secure, opensource android app to store your bank accounts, cards, and credentials. Locally and securely.
A secure, opensource android app to store your bank accounts, cards, and credentials. Locally and securely.

Digital Tijori 🔒 Digital Tijori app lets you store your bank accounts, cards and credentials. You can link cards and credentials to a particular bank

Yet another ToDo app, but the UI completely written in Jetpack Compose!
Yet another ToDo app, but the UI completely written in Jetpack Compose!

Yet another ToDo app, but the UI completely written in Jetpack Compose!

Yet another ToDo app, but the UI completely written in Jetpack Compose!
Yet another ToDo app, but the UI completely written in Jetpack Compose!

Yet another ToDo app, but the UI completely written in Jetpack Compose!

Android multi-module navigation built on top of Jetpack Navigation Compose
Android multi-module navigation built on top of Jetpack Navigation Compose

MultiNavCompose Android library for multi-module navigation built on top of Jetpack Navigation Compose. The goal of this library is to simplify the se

Comments
  • Add max visible back stack

    Add max visible back stack

    I am using cardstack as a gallery viewer of sorts. When there is a large number of cards in the backstack, it would be nice to have the option to limit to a specific number of visible cards, for appearances, as well as not having the composable in memory

    opened by CarlosEsco 0
  • Later cards get smaller when list is large enough

    Later cards get smaller when list is large enough

    Once you get past 3/4 cards the size of later cards gets smaller and smaller. Here is an example I did the orientation horizontal because its even more noticeable but happens with both orientations.

         val images = remember {
                mutableStateListOf(
                    "https://mangadex.org/covers/a96676e5-8ae2-425e-b549-7f15dd34a6d8/dfcaab7a-2c3c-4ea5-8641-abffd2a95b5f.jpg",
                    "https://mangadex.org/covers/a96676e5-8ae2-425e-b549-7f15dd34a6d8/512496fb-6e57-483f-9380-aa6027d4f157.jpg",
                    "https://mangadex.org/covers/a96676e5-8ae2-425e-b549-7f15dd34a6d8/d9497f0d-3bd7-42d9-832c-696ff39a6a28.jpg",
                     "https://mangadex.org/covers/a96676e5-8ae2-425e-b549-7f15dd34a6d8/bb38cabc-769b-4b6c-b7c1-dc3a933cd3c9.jpg",
                     "https://mangadex.org/covers/a96676e5-8ae2-425e-b549-7f15dd34a6d8/e393ec1a-320d-4ef7-92de-ca84b0d20309.jpg",
                     "https://mangadex.org/covers/a96676e5-8ae2-425e-b549-7f15dd34a6d8/17acc2b0-2cab-46f2-954d-91b1174db67e.jpg",
                     "https://mangadex.org/covers/a96676e5-8ae2-425e-b549-7f15dd34a6d8/5a2e4c1d-696e-4983-ad9c-67eba37c0daa.jpg",
                     "https://mangadex.org/covers/a96676e5-8ae2-425e-b549-7f15dd34a6d8/1b266184-eb7a-4801-9ad6-8f53ac8acb47.jpg",
                     "https://mangadex.org/covers/a96676e5-8ae2-425e-b549-7f15dd34a6d8/67cc4435-16cc-4d32-8163-a82a681b826e.jpg",
                     "https://mangadex.org/covers/a96676e5-8ae2-425e-b549-7f15dd34a6d8/8b4b0dec-d3f9-4471-be67-46ea386164a1.jpg",
                     
                )
            }
    Box(
                modifier = Modifier
                    .fillMaxWidth()
                    .fillMaxHeight(),
            ) {
                CardStack(
                    cardContent = {
                        AsyncImage(
                            model = ImageRequest.Builder(LocalContext.current)
                                .data(images[it])
                                .build(),
                            contentDescription = null,
                            contentScale = ContentScale.Fit,
                            modifier = Modifier.clip(
                                RoundedCornerShape(Shapes.coverRadius),
                            ),
                        )
                    },
                    cardCount = images.size,
                    cardShape = RoundedCornerShape(Shapes.coverRadius),
                    cardElevation = 4.dp,
                    paddingBetweenCards = 4.dp,
                    orientation = Orientation.Horizontal(alignment = HorizontalAlignment.StartToEnd, animationStyle = HorizontalAnimationStyle.FromTop),
                )
    }
    
    opened by CarlosEsco 2
Releases(0.0.6)
Owner
null
A simple utility Compose to add customizable buttons when swiping the card in an easy way.

Swipeable-Card A simple utility Compose to add customizable buttons when swiping the card in an easy way. Import: This library is available as a gradl

Amr algnyat 17 Nov 1, 2022
Map-vs-list-comparator - The project compares the time needed to find a given element in a map vs the time needed to find a given element in a list.

Map vs List Comparator The project compares the time needed to find a given element in a map vs the time needed to find a given element in a list. To

null 0 Jan 4, 2022
💳 A quick and easy flip view through which you can create views with two sides like credit cards, poker cards etc.

The article on how this library was created is now published. You can read it on this link here. →. ?? EasyFlipView Built with ❤︎ by Wajahat Karim and

Wajahat Karim 1.3k Dec 14, 2022
💳 A quick and easy flip view through which you can create views with two sides like credit cards, poker cards etc.

The article on how this library was created is now published. You can read it on this link here. →. ?? EasyFlipView Built with ❤︎ by Wajahat Karim and

Wajahat Karim 1.3k Dec 14, 2022
Persons cards list viewpager - Persons cards list viewpager using kotlin

persons_cards_list_viewpager Дизайн и условие взяты из https://github.com/appKOD

Mironov Ury 1 Mar 1, 2022
🔥 Yet another Tinder like swipeable cards, built for Jetpack Compose

twyper Yet another Tinder like swipeable card library, built for Jetpack Compose ✨ Demo Screen.Recording.2022-02-20.at.10.46.59.PM.mov ⌨️ Usage 1. Add

theapache64 88 Dec 24, 2022
Add IndustrialTNT like from old IC2 mod which keeps items after explosion and helps to mine resources

IndustrialTNT Add IndustrialTNT like from old IC2 mod which keeps items after ex

null 0 Jan 9, 2022
Hobby-keeping - Platform to record books that you read and games you played! Made with Kotlin and Spring Framework

Hobby Keeping API to record books that you read and games you played! Made with

William Barom Mingardi 1 Jan 29, 2022
:barber: [Android Library] Stacked dual progress indicator progress-bar

StackedHorizontalProgressBar Specs Featured in Show some ❤️ Android library with ability to show two progress indicators in one horizontal progress ba

Nishant Srivastava 98 Nov 11, 2022