-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 23f1b75
Showing
67 changed files
with
1,970 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
*.iml | ||
.gradle | ||
/local.properties | ||
/.idea/caches | ||
/.idea/libraries | ||
/.idea/modules.xml | ||
/.idea/workspace.xml | ||
/.idea/navEditor.xml | ||
/.idea/assetWizardSettings.xml | ||
.DS_Store | ||
/build | ||
/captures | ||
.externalNativeBuild | ||
.cxx | ||
local.properties |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
![Logo](https://github.com/msusman1/compose-card-stack/blob/master/images/home_banner.png) | ||
|
||
# Compose Card Stack | ||
|
||
![Platform](http://img.shields.io/badge/platform-android-blue.svg?style=flat) | ||
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) | ||
![API](https://img.shields.io/badge/API-24%2B-blue.svg?style=flat) | ||
|
||
# Overview | ||
Timber like card stack library for Compose, motivation from CardStackView for android view(imperative UI). | ||
[CardStackView](https://github.com/yuyakaido/CardStackView) | ||
|
||
![Overview](https://github.com/msusman1/compose-card-stack/blob/master/images/overview.gif) | ||
|
||
# Installation | ||
|
||
```groovy | ||
dependencies { | ||
implementation "com.github.msusman1:compose-cardstack:1.0.0" | ||
} | ||
``` | ||
|
||
#Setup | ||
|
||
```kotlin | ||
CardStack( | ||
modifier = Modifier.padding(16.dp), | ||
stackState = rememberStackState(), | ||
cardElevation = 10.dp, | ||
scaleRatio = 0.95f, | ||
rotationMaxDegree = 15, | ||
displacementThreshold = 60.dp, | ||
animationDuration = Duration.NORMAL, | ||
visibleCount = 3, | ||
stackDirection = Direction.BottomAndRight, | ||
swipeDirection = SwipeDirection.FREEDOM, | ||
swipeMethod = SwipeMethod.AUTOMATIC_AND_MANUAL, | ||
items = items, | ||
onSwiped = { index -> | ||
Log.d(TAG, "onSwiped index:$index ") | ||
} | ||
) { | ||
MyImageCard(item = it) // your card Composable | ||
} | ||
|
||
``` | ||
|
||
# Features | ||
|
||
## Stack Direction | ||
Card stack direction [Default: Direction.Bottom] | ||
|
||
![Stack Direction](https://github.com/msusman1/compose-card-stack/blob/master/images/stack_direction.png) | ||
|
||
## Visibility Count | ||
No of cards to be visible below the top card Range:(from = 0, to = items size ) [Default: 3] | ||
|
||
![Visibility Count](https://github.com/msusman1/compose-card-stack/blob/master/images/visibility_count.png) | ||
|
||
## Card Elevation | ||
Determine how much portion of underline cards will be displayed [Default: 10] | ||
|
||
![Visibility Count](https://github.com/msusman1/compose-card-stack/blob/master/images/elevation.png) | ||
|
||
## Card Scale Ratio | ||
Determine how much underline cards be scale down(from 0.0 to 1.0) value fo 0.95f means 90% of original size, [Default: 0.95] | ||
|
||
![Visibility Count](https://github.com/msusman1/compose-card-stack/blob/master/images/scale.png) | ||
|
||
## Displacement Thresh hold | ||
Displacement thresh hold value in Dp to make the card swipe, [Default: 60.dp] | ||
|
||
|
||
## Animation Duration | ||
Duration of the card animation [Default: Duration.NORMAL] | ||
|
||
## Maximum Rotation degree | ||
Maximum Degree at which card can rotate [Default: 20] | ||
|
||
## Swipe Direction | ||
Direction at which card can move [Default: SwipeDirection.FREEDOM] | ||
|
||
## Swipe Method | ||
Set swipe method either manual(through code) or automatic(through swipe) [Default: SwipeMethod.AUTOMATIC_AND_MANUAL] | ||
|
||
|
||
<br/> | ||
|
||
## 👍 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 | ||
|
||
<br/> | ||
|
||
# License | ||
|
||
``` | ||
Copyright 2023 yuyakaido | ||
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 at | ||
http://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. | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
plugins { | ||
id 'com.android.application' | ||
id 'org.jetbrains.kotlin.android' | ||
} | ||
|
||
android { | ||
namespace 'com.msusman.compose.cardstack.sample' | ||
compileSdk 34 | ||
|
||
defaultConfig { | ||
applicationId "com.msusman.compose.cardstack.sample" | ||
minSdk 23 | ||
targetSdk 34 | ||
versionCode 1 | ||
versionName "1.0" | ||
|
||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" | ||
vectorDrawables { | ||
useSupportLibrary true | ||
} | ||
} | ||
|
||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' | ||
} | ||
} | ||
compileOptions { | ||
sourceCompatibility JavaVersion.VERSION_1_8 | ||
targetCompatibility JavaVersion.VERSION_1_8 | ||
} | ||
kotlinOptions { | ||
jvmTarget = '1.8' | ||
} | ||
buildFeatures { | ||
compose true | ||
} | ||
composeOptions { | ||
kotlinCompilerExtensionVersion '1.4.8' | ||
} | ||
packagingOptions { | ||
resources { | ||
excludes += '/META-INF/{AL2.0,LGPL2.1}' | ||
} | ||
} | ||
} | ||
|
||
dependencies { | ||
|
||
implementation 'androidx.core:core-ktx:1.10.1' | ||
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.6.1' | ||
implementation 'androidx.activity:activity-compose:1.7.2' | ||
implementation platform('androidx.compose:compose-bom:2022.10.00') | ||
implementation 'androidx.compose.ui:ui' | ||
implementation 'androidx.compose.ui:ui-graphics' | ||
implementation 'androidx.compose.ui:ui-tooling-preview' | ||
implementation 'androidx.compose.material3:material3' | ||
testImplementation 'junit:junit:4.13.2' | ||
androidTestImplementation 'androidx.test.ext:junit:1.1.5' | ||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' | ||
androidTestImplementation platform('androidx.compose:compose-bom:2022.10.00') | ||
androidTestImplementation 'androidx.compose.ui:ui-test-junit4' | ||
debugImplementation 'androidx.compose.ui:ui-tooling' | ||
debugImplementation 'androidx.compose.ui:ui-test-manifest' | ||
implementation(project(":compose-cardstack")) | ||
implementation "io.coil-kt:coil-compose:2.2.2" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Add project specific ProGuard rules here. | ||
# You can control the set of applied configuration files using the | ||
# proguardFiles setting in build.gradle. | ||
# | ||
# For more details, see | ||
# http://developer.android.com/guide/developing/tools/proguard.html | ||
|
||
# If your project uses WebView with JS, uncomment the following | ||
# and specify the fully qualified class name to the JavaScript interface | ||
# class: | ||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview { | ||
# public *; | ||
#} | ||
|
||
# Uncomment this to preserve the line number information for | ||
# debugging stack traces. | ||
#-keepattributes SourceFile,LineNumberTable | ||
|
||
# If you keep the line number information, uncomment this to | ||
# hide the original source file name. | ||
#-renamesourcefileattribute SourceFile |
24 changes: 24 additions & 0 deletions
24
app/src/androidTest/java/com/msusman/compose/cardstack/sample/ExampleInstrumentedTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.msusman.compose.cardstack.sample | ||
|
||
import androidx.test.platform.app.InstrumentationRegistry | ||
import androidx.test.ext.junit.runners.AndroidJUnit4 | ||
|
||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
|
||
import org.junit.Assert.* | ||
|
||
/** | ||
* Instrumented test, which will execute on an Android device. | ||
* | ||
* See [testing documentation](http://d.android.com/tools/testing). | ||
*/ | ||
@RunWith(AndroidJUnit4::class) | ||
class ExampleInstrumentedTest { | ||
@Test | ||
fun useAppContext() { | ||
// Context of the app under test. | ||
val appContext = InstrumentationRegistry.getInstrumentation().targetContext | ||
assertEquals("com.msusman.compose.cardstack.sample", appContext.packageName) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools"> | ||
|
||
<application | ||
android:allowBackup="true" | ||
android:dataExtractionRules="@xml/data_extraction_rules" | ||
android:fullBackupContent="@xml/backup_rules" | ||
android:icon="@mipmap/ic_launcher" | ||
android:label="@string/app_name" | ||
android:roundIcon="@mipmap/ic_launcher_round" | ||
android:supportsRtl="true" | ||
android:theme="@style/Theme.ComposeCardStack" | ||
tools:targetApi="31"> | ||
<activity | ||
android:name=".MainActivity" | ||
android:exported="true" | ||
android:label="@string/app_name" | ||
android:theme="@style/Theme.ComposeCardStack"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
|
||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
</application> | ||
|
||
</manifest> |
33 changes: 33 additions & 0 deletions
33
app/src/main/java/com/msusman/compose/cardstack/sample/ItemsData.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package com.msusman.compose.cardstack.sample | ||
|
||
/** | ||
* Created by Muhammad Usman : [email protected] on 7/20/2023. | ||
*/ | ||
val item1 = Item( | ||
"https://images.unsplash.com/photo-1521668576204-57ae3afee860?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=687&q=80", | ||
"Rakotzbrücke, Gablenz, Germany", | ||
"March 22, 2018" | ||
) | ||
val item2 = Item( | ||
"https://images.unsplash.com/photo-1454391304352-2bf4678b1a7a?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=687&q=80", | ||
"Palm tree and plant", | ||
"February 2, 2016" | ||
) | ||
val item3 = Item( | ||
"https://images.unsplash.com/photo-1568323993144-20d546ba585d?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=687&q=80", | ||
"Airplane flying during the sunset", | ||
"September 13, 2019" | ||
) | ||
val item4 = Item( | ||
"https://images.unsplash.com/photo-1614094082869-cd4e4b2905c7?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=687&q=80", | ||
"Winter in San Martino di Castrozza, Italia", | ||
"February 23, 2021" | ||
) | ||
|
||
data class Item( | ||
val url: String? = null, | ||
val text: String = "", | ||
val subText: String = "" | ||
) | ||
|
||
val items = listOf(item1, item2, item3, item4, item1, item2, item3, item4) |
Oops, something went wrong.