├── .gitignore
├── README.md
├── app
├── .gitignore
├── build.gradle.kts
├── proguard-rules.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── java
│ └── tech
│ │ └── apter
│ │ └── parallaxcarouselcompose
│ │ ├── MainActivity.kt
│ │ └── ui
│ │ ├── ParallaxCarousel.kt
│ │ └── theme
│ │ ├── Color.kt
│ │ ├── Theme.kt
│ │ └── Type.kt
│ └── res
│ ├── drawable
│ ├── ic_launcher_background.xml
│ ├── ic_launcher_foreground.xml
│ ├── p1.jpg
│ ├── p2.jpg
│ ├── p3.jpg
│ ├── p4.jpg
│ ├── p5.jpg
│ ├── p6.jpg
│ └── p7.jpg
│ ├── mipmap-anydpi
│ ├── ic_launcher.xml
│ └── ic_launcher_round.xml
│ ├── mipmap-hdpi
│ ├── ic_launcher.webp
│ └── ic_launcher_round.webp
│ ├── mipmap-mdpi
│ ├── ic_launcher.webp
│ └── ic_launcher_round.webp
│ ├── mipmap-xhdpi
│ ├── ic_launcher.webp
│ └── ic_launcher_round.webp
│ ├── mipmap-xxhdpi
│ ├── ic_launcher.webp
│ └── ic_launcher_round.webp
│ ├── mipmap-xxxhdpi
│ ├── ic_launcher.webp
│ └── ic_launcher_round.webp
│ ├── values
│ ├── colors.xml
│ ├── strings.xml
│ └── themes.xml
│ └── xml
│ ├── backup_rules.xml
│ └── data_extraction_rules.xml
├── build.gradle.kts
├── gradle.properties
├── gradle
├── libs.versions.toml
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── screenshots
└── compose.gif
└── settings.gradle.kts
/.gitignore:
--------------------------------------------------------------------------------
1 | # Gradle files
2 | .gradle/
3 | build/
4 |
5 | # Local configuration file (sdk path, etc)
6 | local.properties
7 |
8 | # Log/OS Files
9 | *.log
10 |
11 | # Android Studio generated files and folders
12 | captures/
13 | .externalNativeBuild/
14 | .cxx/
15 | *.apk
16 | output.json
17 |
18 | # IntelliJ
19 | *.iml
20 | .idea/
21 | misc.xml
22 | deploymentTargetDropDown.xml
23 | render.experimental.xml
24 |
25 | # Keystore files
26 | *.jks
27 | *.keystore
28 |
29 | # Google Services (e.g. APIs or Firebase)
30 | google-services.json
31 |
32 | # Android Profiling
33 | *.hprof
34 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Jetpack Compose Parallax Carousel Example
2 |
3 |
4 |
5 | This is an example project that demonstrates how to create a parallax carousel with Jetpack Compose.
6 |
7 | ## Features
8 |
9 | - Parallax scrolling effect.
10 | - Jetpack Compose-based implementation.
11 | - Demonstrates how to create a visually appealing carousel.
12 |
13 | ## Usage
14 |
15 | To use this example project, follow these steps:
16 |
17 | 1. Clone this repository.
18 | 2. Open the project in Android Studio.
19 | 3. Build and run the app on an Android emulator or device.
20 |
21 | ## How it Works
22 |
23 | The project uses Jetpack Compose to create a parallax effect in a carousel of images. It demonstrates how to use Composable functions to build the user interface and apply the parallax effect to the images as the user scrolls.
24 |
25 | ## Requirements
26 |
27 | - Android Studio with Jetpack Compose support.
28 |
29 | ## Acknowledgments
30 |
31 | This project was inspired by the SwiftUI Parallax Carousel Scroll tutorial available at [KavSoft](https://github.com/kenfai/KavSoft-Tutorials-iOS/tree/main/ParallaxCarousel).
32 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/app/build.gradle.kts:
--------------------------------------------------------------------------------
1 | @Suppress("DSL_SCOPE_VIOLATION") // TODO: Remove once KTIJ-19369 is fixed
2 | plugins {
3 | alias(libs.plugins.androidApplication)
4 | alias(libs.plugins.kotlinAndroid)
5 | }
6 |
7 | android {
8 | namespace = "tech.apter.parallaxcarouselcompose"
9 | compileSdk = 34
10 |
11 | defaultConfig {
12 | applicationId = "tech.apter.parallaxcarouselcompose"
13 | minSdk = 26
14 | targetSdk = 34
15 | versionCode = 1
16 | versionName = "1.0"
17 |
18 | testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
19 | vectorDrawables {
20 | useSupportLibrary = true
21 | }
22 | }
23 |
24 | buildTypes {
25 | release {
26 | isMinifyEnabled = false
27 | proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
28 | }
29 | }
30 | compileOptions {
31 | sourceCompatibility = JavaVersion.VERSION_1_8
32 | targetCompatibility = JavaVersion.VERSION_1_8
33 | }
34 | kotlinOptions {
35 | jvmTarget = "1.8"
36 | }
37 | buildFeatures {
38 | compose = true
39 | }
40 | composeOptions {
41 | kotlinCompilerExtensionVersion = libs.versions.composeCompiler.get()
42 | }
43 | packaging {
44 | resources {
45 | excludes += "/META-INF/{AL2.0,LGPL2.1}"
46 | }
47 | }
48 | }
49 |
50 | dependencies {
51 | implementation(libs.core.ktx)
52 | implementation(libs.lifecycle.runtime.ktx)
53 | implementation(libs.activity.compose)
54 | implementation(platform(libs.compose.bom))
55 | implementation(libs.ui)
56 | implementation(libs.ui.graphics)
57 | implementation(libs.ui.tooling.preview)
58 | implementation(libs.material3)
59 | debugImplementation(libs.ui.tooling)
60 | debugImplementation(libs.ui.test.manifest)
61 | }
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
15 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/app/src/main/java/tech/apter/parallaxcarouselcompose/MainActivity.kt:
--------------------------------------------------------------------------------
1 | package tech.apter.parallaxcarouselcompose
2 |
3 | import android.os.Bundle
4 | import androidx.activity.ComponentActivity
5 | import androidx.activity.compose.setContent
6 | import androidx.compose.foundation.layout.Box
7 | import androidx.compose.foundation.layout.fillMaxSize
8 | import androidx.compose.material3.MaterialTheme
9 | import androidx.compose.material3.Surface
10 | import androidx.compose.material3.Text
11 | import androidx.compose.runtime.Composable
12 | import androidx.compose.ui.Alignment
13 | import androidx.compose.ui.Modifier
14 | import androidx.compose.ui.tooling.preview.Preview
15 | import tech.apter.parallaxcarouselcompose.ui.ParallaxCarousel
16 | import tech.apter.parallaxcarouselcompose.ui.theme.ParallaxCarouselComposeTheme
17 |
18 | class MainActivity : ComponentActivity() {
19 | override fun onCreate(savedInstanceState: Bundle?) {
20 | super.onCreate(savedInstanceState)
21 | setContent {
22 | ParallaxCarouselComposeTheme {
23 | Surface(
24 | modifier = Modifier.fillMaxSize(),
25 | ) {
26 | Box(Modifier.fillMaxSize(), contentAlignment = Alignment.Center) {
27 | ParallaxCarousel()
28 | }
29 | }
30 | }
31 | }
32 | }
33 | }
34 |
35 | @Preview(showBackground = true)
36 | @Composable
37 | fun ParallaxCarouselPreview() {
38 | ParallaxCarouselComposeTheme {
39 | Box(Modifier.fillMaxSize(), contentAlignment = Alignment.Center) {
40 | ParallaxCarousel()
41 | }
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/app/src/main/java/tech/apter/parallaxcarouselcompose/ui/ParallaxCarousel.kt:
--------------------------------------------------------------------------------
1 | package tech.apter.parallaxcarouselcompose.ui
2 |
3 | import androidx.compose.foundation.Canvas
4 | import androidx.compose.foundation.ExperimentalFoundationApi
5 | import androidx.compose.foundation.background
6 | import androidx.compose.foundation.layout.fillMaxSize
7 | import androidx.compose.foundation.layout.fillMaxWidth
8 | import androidx.compose.foundation.layout.height
9 | import androidx.compose.foundation.layout.padding
10 | import androidx.compose.foundation.pager.HorizontalPager
11 | import androidx.compose.foundation.pager.rememberPagerState
12 | import androidx.compose.foundation.shape.RoundedCornerShape
13 | import androidx.compose.material3.Card
14 | import androidx.compose.runtime.Composable
15 | import androidx.compose.ui.Modifier
16 | import androidx.compose.ui.draw.clip
17 | import androidx.compose.ui.draw.shadow
18 | import androidx.compose.ui.graphics.Color
19 | import androidx.compose.ui.graphics.ImageBitmap
20 | import androidx.compose.ui.graphics.drawscope.translate
21 | import androidx.compose.ui.platform.LocalConfiguration
22 | import androidx.compose.ui.platform.LocalDensity
23 | import androidx.compose.ui.res.imageResource
24 | import androidx.compose.ui.unit.Dp
25 | import androidx.compose.ui.unit.IntOffset
26 | import androidx.compose.ui.unit.IntSize
27 | import androidx.compose.ui.unit.dp
28 | import tech.apter.parallaxcarouselcompose.R
29 | import kotlin.math.roundToInt
30 |
31 | // Padding values
32 | private val cardPadding = 25.dp
33 | private val imagePadding = 10.dp
34 |
35 | // Shadow and shape values for the card
36 | private val shadowElevation = 15.dp
37 | private val borderRadius = 15.dp
38 | private val shape = RoundedCornerShape(borderRadius)
39 |
40 | // Offset for the parallax effect
41 | private val xOffset = cardPadding.value * 2
42 |
43 | @OptIn(ExperimentalFoundationApi::class)
44 | @Composable
45 | fun ParallaxCarousel() {
46 | // Get screen dimensions and density
47 | val screenWidth = LocalConfiguration.current.screenWidthDp.dp
48 | val screenHeight = LocalConfiguration.current.screenHeightDp.dp
49 | val density = LocalDensity.current.density
50 |
51 | // List of image resources
52 | val images = listOf(
53 | R.drawable.p1,
54 | R.drawable.p2,
55 | R.drawable.p3,
56 | R.drawable.p4,
57 | R.drawable.p5,
58 | R.drawable.p6,
59 | R.drawable.p7,
60 | )
61 |
62 | // Create a pager state
63 | val pagerState = rememberPagerState {
64 | images.size
65 | }
66 |
67 | // Calculate the height for the pager
68 | val pagerHeight = screenHeight / 1.5f
69 |
70 | // HorizontalPager composable: Swiping through images
71 | HorizontalPager(
72 | state = pagerState,
73 | modifier = Modifier
74 | .fillMaxWidth()
75 | .height(pagerHeight),
76 | ) { page ->
77 | // Calculate the parallax offset for the current page
78 | val parallaxOffset = pagerState.getOffsetFractionForPage(page) * screenWidth.value
79 |
80 | // Call ParallaxCarouselItem with image resource and parameters
81 | ParallaxCarouselItem(
82 | images[page],
83 | parallaxOffset,
84 | pagerHeight,
85 | screenWidth,
86 | density
87 | )
88 | }
89 | }
90 |
91 | @Composable
92 | fun ParallaxCarouselItem(
93 | imageResId: Int,
94 | parallaxOffset: Float,
95 | pagerHeight: Dp,
96 | screenWidth: Dp,
97 | density: Float,
98 | ) {
99 | // Load the image bitmap
100 | val imageBitmap = ImageBitmap.imageResource(id = imageResId)
101 |
102 | // Calculate the draw size for the image
103 | val drawSize = imageBitmap.calculateDrawSize(density, screenWidth, pagerHeight)
104 |
105 | // Card composable for the item
106 | Card(
107 | modifier = Modifier
108 | .fillMaxSize()
109 | .padding(cardPadding)
110 | .background(Color.White, shape)
111 | .shadow(elevation = shadowElevation, shape = shape)
112 | ) {
113 | // Canvas for drawing the image with parallax effect
114 | Canvas(
115 | modifier = Modifier
116 | .fillMaxSize()
117 | .padding(imagePadding)
118 | .clip(shape)
119 | ) {
120 | // Translate the canvas for parallax effect
121 | translate(left = parallaxOffset * density) {
122 | // Draw the image
123 | drawImage(
124 | image = imageBitmap,
125 | srcSize = IntSize(imageBitmap.width, imageBitmap.height),
126 | dstOffset = IntOffset(-xOffset.toIntPx(density), 0),
127 | dstSize = drawSize,
128 | )
129 | }
130 | }
131 | }
132 | }
133 |
134 | // Function to calculate draw size for the image
135 | private fun ImageBitmap.calculateDrawSize(density: Float, screenWidth: Dp, pagerHeight: Dp): IntSize {
136 | val originalImageWidth = width / density
137 | val originalImageHeight = height / density
138 |
139 | val frameAspectRatio = screenWidth / pagerHeight
140 | val imageAspectRatio = originalImageWidth / originalImageHeight
141 |
142 | val drawWidth = xOffset + if (frameAspectRatio > imageAspectRatio) {
143 | screenWidth.value
144 | } else {
145 | pagerHeight.value * imageAspectRatio
146 | }
147 |
148 | val drawHeight = if (frameAspectRatio > imageAspectRatio) {
149 | screenWidth.value / imageAspectRatio
150 | } else {
151 | pagerHeight.value
152 | }
153 |
154 | return IntSize(drawWidth.toIntPx(density), drawHeight.toIntPx(density))
155 | }
156 |
157 | // Extension function to convert Float to Int in pixels
158 | private fun Float.toIntPx(density: Float) = (this * density).roundToInt()
159 |
--------------------------------------------------------------------------------
/app/src/main/java/tech/apter/parallaxcarouselcompose/ui/theme/Color.kt:
--------------------------------------------------------------------------------
1 | package tech.apter.parallaxcarouselcompose.ui.theme
2 |
3 | import androidx.compose.ui.graphics.Color
4 |
5 | val Purple80 = Color(0xFFD0BCFF)
6 | val PurpleGrey80 = Color(0xFFCCC2DC)
7 | val Pink80 = Color(0xFFEFB8C8)
8 |
9 | val Purple40 = Color(0xFF6650a4)
10 | val PurpleGrey40 = Color(0xFF625b71)
11 | val Pink40 = Color(0xFF7D5260)
12 |
--------------------------------------------------------------------------------
/app/src/main/java/tech/apter/parallaxcarouselcompose/ui/theme/Theme.kt:
--------------------------------------------------------------------------------
1 | package tech.apter.parallaxcarouselcompose.ui.theme
2 |
3 | import android.app.Activity
4 | import android.os.Build
5 | import androidx.compose.foundation.isSystemInDarkTheme
6 | import androidx.compose.material3.MaterialTheme
7 | import androidx.compose.material3.darkColorScheme
8 | import androidx.compose.material3.dynamicDarkColorScheme
9 | import androidx.compose.material3.dynamicLightColorScheme
10 | import androidx.compose.material3.lightColorScheme
11 | import androidx.compose.runtime.Composable
12 | import androidx.compose.runtime.SideEffect
13 | import androidx.compose.ui.graphics.toArgb
14 | import androidx.compose.ui.platform.LocalContext
15 | import androidx.compose.ui.platform.LocalView
16 | import androidx.core.view.WindowCompat
17 |
18 | private val DarkColorScheme = darkColorScheme(
19 | primary = Purple80,
20 | secondary = PurpleGrey80,
21 | tertiary = Pink80
22 | )
23 |
24 | private val LightColorScheme = lightColorScheme(
25 | primary = Purple40,
26 | secondary = PurpleGrey40,
27 | tertiary = Pink40
28 |
29 | /* Other default colors to override
30 | background = Color(0xFFFFFBFE),
31 | surface = Color(0xFFFFFBFE),
32 | onPrimary = Color.White,
33 | onSecondary = Color.White,
34 | onTertiary = Color.White,
35 | onBackground = Color(0xFF1C1B1F),
36 | onSurface = Color(0xFF1C1B1F),
37 | */
38 | )
39 |
40 | @Composable
41 | fun ParallaxCarouselComposeTheme(
42 | darkTheme: Boolean = isSystemInDarkTheme(),
43 | // Dynamic color is available on Android 12+
44 | dynamicColor: Boolean = true,
45 | content: @Composable () -> Unit
46 | ) {
47 | val colorScheme = when {
48 | dynamicColor && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> {
49 | val context = LocalContext.current
50 | if (darkTheme) dynamicDarkColorScheme(context) else dynamicLightColorScheme(context)
51 | }
52 |
53 | darkTheme -> DarkColorScheme
54 | else -> LightColorScheme
55 | }
56 | val view = LocalView.current
57 | if (!view.isInEditMode) {
58 | SideEffect {
59 | val window = (view.context as Activity).window
60 | window.statusBarColor = colorScheme.primary.toArgb()
61 | WindowCompat.getInsetsController(window, view).isAppearanceLightStatusBars = darkTheme
62 | }
63 | }
64 |
65 | MaterialTheme(
66 | colorScheme = colorScheme,
67 | typography = Typography,
68 | content = content
69 | )
70 | }
71 |
--------------------------------------------------------------------------------
/app/src/main/java/tech/apter/parallaxcarouselcompose/ui/theme/Type.kt:
--------------------------------------------------------------------------------
1 | package tech.apter.parallaxcarouselcompose.ui.theme
2 |
3 | import androidx.compose.material3.Typography
4 | import androidx.compose.ui.text.TextStyle
5 | import androidx.compose.ui.text.font.FontFamily
6 | import androidx.compose.ui.text.font.FontWeight
7 | import androidx.compose.ui.unit.sp
8 |
9 | // Set of Material typography styles to start with
10 | val Typography = Typography(
11 | bodyLarge = TextStyle(
12 | fontFamily = FontFamily.Default,
13 | fontWeight = FontWeight.Normal,
14 | fontSize = 16.sp,
15 | lineHeight = 24.sp,
16 | letterSpacing = 0.5.sp
17 | )
18 | /* Other default text styles to override
19 | titleLarge = TextStyle(
20 | fontFamily = FontFamily.Default,
21 | fontWeight = FontWeight.Normal,
22 | fontSize = 22.sp,
23 | lineHeight = 28.sp,
24 | letterSpacing = 0.sp
25 | ),
26 | labelSmall = TextStyle(
27 | fontFamily = FontFamily.Default,
28 | fontWeight = FontWeight.Medium,
29 | fontSize = 11.sp,
30 | lineHeight = 16.sp,
31 | letterSpacing = 0.5.sp
32 | )
33 | */
34 | )
35 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
10 |
15 |
20 |
25 |
30 |
35 |
40 |
45 |
50 |
55 |
60 |
65 |
70 |
75 |
80 |
85 |
90 |
95 |
100 |
105 |
110 |
115 |
120 |
125 |
130 |
135 |
140 |
145 |
150 |
155 |
160 |
165 |
170 |
171 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
15 |
18 |
21 |
22 |
23 |
24 |
30 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/p1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/apter-tech/ParallaxCarouselCompose/b2e45f87dd4f82486db887625a4780b5fb0c89e8/app/src/main/res/drawable/p1.jpg
--------------------------------------------------------------------------------
/app/src/main/res/drawable/p2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/apter-tech/ParallaxCarouselCompose/b2e45f87dd4f82486db887625a4780b5fb0c89e8/app/src/main/res/drawable/p2.jpg
--------------------------------------------------------------------------------
/app/src/main/res/drawable/p3.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/apter-tech/ParallaxCarouselCompose/b2e45f87dd4f82486db887625a4780b5fb0c89e8/app/src/main/res/drawable/p3.jpg
--------------------------------------------------------------------------------
/app/src/main/res/drawable/p4.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/apter-tech/ParallaxCarouselCompose/b2e45f87dd4f82486db887625a4780b5fb0c89e8/app/src/main/res/drawable/p4.jpg
--------------------------------------------------------------------------------
/app/src/main/res/drawable/p5.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/apter-tech/ParallaxCarouselCompose/b2e45f87dd4f82486db887625a4780b5fb0c89e8/app/src/main/res/drawable/p5.jpg
--------------------------------------------------------------------------------
/app/src/main/res/drawable/p6.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/apter-tech/ParallaxCarouselCompose/b2e45f87dd4f82486db887625a4780b5fb0c89e8/app/src/main/res/drawable/p6.jpg
--------------------------------------------------------------------------------
/app/src/main/res/drawable/p7.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/apter-tech/ParallaxCarouselCompose/b2e45f87dd4f82486db887625a4780b5fb0c89e8/app/src/main/res/drawable/p7.jpg
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/apter-tech/ParallaxCarouselCompose/b2e45f87dd4f82486db887625a4780b5fb0c89e8/app/src/main/res/mipmap-hdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/apter-tech/ParallaxCarouselCompose/b2e45f87dd4f82486db887625a4780b5fb0c89e8/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/apter-tech/ParallaxCarouselCompose/b2e45f87dd4f82486db887625a4780b5fb0c89e8/app/src/main/res/mipmap-mdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/apter-tech/ParallaxCarouselCompose/b2e45f87dd4f82486db887625a4780b5fb0c89e8/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/apter-tech/ParallaxCarouselCompose/b2e45f87dd4f82486db887625a4780b5fb0c89e8/app/src/main/res/mipmap-xhdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/apter-tech/ParallaxCarouselCompose/b2e45f87dd4f82486db887625a4780b5fb0c89e8/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/apter-tech/ParallaxCarouselCompose/b2e45f87dd4f82486db887625a4780b5fb0c89e8/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/apter-tech/ParallaxCarouselCompose/b2e45f87dd4f82486db887625a4780b5fb0c89e8/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/apter-tech/ParallaxCarouselCompose/b2e45f87dd4f82486db887625a4780b5fb0c89e8/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/apter-tech/ParallaxCarouselCompose/b2e45f87dd4f82486db887625a4780b5fb0c89e8/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #FFBB86FC
4 | #FF6200EE
5 | #FF3700B3
6 | #FF03DAC5
7 | #FF018786
8 | #FF000000
9 | #FFFFFFFF
10 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | ParallaxCarouselCompose
3 |
--------------------------------------------------------------------------------
/app/src/main/res/values/themes.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/xml/backup_rules.xml:
--------------------------------------------------------------------------------
1 |
8 |
9 |
13 |
--------------------------------------------------------------------------------
/app/src/main/res/xml/data_extraction_rules.xml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
8 |
12 |
13 |
19 |
--------------------------------------------------------------------------------
/build.gradle.kts:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 | plugins {
3 | alias(libs.plugins.androidApplication) apply false
4 | alias(libs.plugins.kotlinAndroid) apply false
5 | }
6 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 | # IDE (e.g. Android Studio) users:
3 | # Gradle settings configured through the IDE *will override*
4 | # any settings specified in this file.
5 | # For more details on how to configure your build environment visit
6 | # http://www.gradle.org/docs/current/userguide/build_environment.html
7 | # Specifies the JVM arguments used for the daemon process.
8 | # The setting is particularly useful for tweaking memory settings.
9 | org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
10 | # When configured, Gradle will run in incubating parallel mode.
11 | # This option should only be used with decoupled projects. More details, visit
12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
13 | # org.gradle.parallel=true
14 | # AndroidX package structure to make it clearer which packages are bundled with the
15 | # Android operating system, and which are packaged with your app's APK
16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn
17 | android.useAndroidX=true
18 | # Kotlin code style for this project: "official" or "obsolete":
19 | kotlin.code.style=official
20 | # Enables namespacing of each library's R class so that its R class includes only the
21 | # resources declared in the library itself and none from the library's dependencies,
22 | # thereby reducing the size of the R class for that library
23 | android.nonTransitiveRClass=true
--------------------------------------------------------------------------------
/gradle/libs.versions.toml:
--------------------------------------------------------------------------------
1 | [versions]
2 | agp = "8.2.0-alpha15"
3 | kotlin = "1.9.0"
4 | core-ktx = "1.12.0"
5 | junit = "4.13.2"
6 | androidx-test-ext-junit = "1.1.5"
7 | espresso-core = "3.5.1"
8 | lifecycle-runtime-ktx = "2.6.2"
9 | activity-compose = "1.7.2"
10 | compose-bom = "2023.09.01"
11 | composeCompiler = "1.5.1"
12 |
13 | [libraries]
14 | core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "core-ktx" }
15 | junit = { group = "junit", name = "junit", version.ref = "junit" }
16 | androidx-test-ext-junit = { group = "androidx.test.ext", name = "junit", version.ref = "androidx-test-ext-junit" }
17 | espresso-core = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "espresso-core" }
18 | lifecycle-runtime-ktx = { group = "androidx.lifecycle", name = "lifecycle-runtime-ktx", version.ref = "lifecycle-runtime-ktx" }
19 | activity-compose = { group = "androidx.activity", name = "activity-compose", version.ref = "activity-compose" }
20 | compose-bom = { group = "androidx.compose", name = "compose-bom", version.ref = "compose-bom" }
21 | ui = { group = "androidx.compose.ui", name = "ui" }
22 | ui-graphics = { group = "androidx.compose.ui", name = "ui-graphics" }
23 | ui-tooling = { group = "androidx.compose.ui", name = "ui-tooling" }
24 | ui-tooling-preview = { group = "androidx.compose.ui", name = "ui-tooling-preview" }
25 | ui-test-manifest = { group = "androidx.compose.ui", name = "ui-test-manifest" }
26 | ui-test-junit4 = { group = "androidx.compose.ui", name = "ui-test-junit4" }
27 | material3 = { group = "androidx.compose.material3", name = "material3" }
28 |
29 | [plugins]
30 | androidApplication = { id = "com.android.application", version.ref = "agp" }
31 | kotlinAndroid = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
32 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/apter-tech/ParallaxCarouselCompose/b2e45f87dd4f82486db887625a4780b5fb0c89e8/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionBase=GRADLE_USER_HOME
2 | distributionPath=wrapper/dists
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip
4 | networkTimeout=10000
5 | validateDistributionUrl=true
6 | zipStoreBase=GRADLE_USER_HOME
7 | zipStorePath=wrapper/dists
8 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | #
4 | # Copyright © 2015-2021 the original authors.
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # https://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | #
18 |
19 | ##############################################################################
20 | #
21 | # Gradle start up script for POSIX generated by Gradle.
22 | #
23 | # Important for running:
24 | #
25 | # (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
26 | # noncompliant, but you have some other compliant shell such as ksh or
27 | # bash, then to run this script, type that shell name before the whole
28 | # command line, like:
29 | #
30 | # ksh Gradle
31 | #
32 | # Busybox and similar reduced shells will NOT work, because this script
33 | # requires all of these POSIX shell features:
34 | # * functions;
35 | # * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
36 | # «${var#prefix}», «${var%suffix}», and «$( cmd )»;
37 | # * compound commands having a testable exit status, especially «case»;
38 | # * various built-in commands including «command», «set», and «ulimit».
39 | #
40 | # Important for patching:
41 | #
42 | # (2) This script targets any POSIX shell, so it avoids extensions provided
43 | # by Bash, Ksh, etc; in particular arrays are avoided.
44 | #
45 | # The "traditional" practice of packing multiple parameters into a
46 | # space-separated string is a well documented source of bugs and security
47 | # problems, so this is (mostly) avoided, by progressively accumulating
48 | # options in "$@", and eventually passing that to Java.
49 | #
50 | # Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
51 | # and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
52 | # see the in-line comments for details.
53 | #
54 | # There are tweaks for specific operating systems such as AIX, CygWin,
55 | # Darwin, MinGW, and NonStop.
56 | #
57 | # (3) This script is generated from the Groovy template
58 | # https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
59 | # within the Gradle project.
60 | #
61 | # You can find Gradle at https://github.com/gradle/gradle/.
62 | #
63 | ##############################################################################
64 |
65 | # Attempt to set APP_HOME
66 |
67 | # Resolve links: $0 may be a link
68 | app_path=$0
69 |
70 | # Need this for daisy-chained symlinks.
71 | while
72 | APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
73 | [ -h "$app_path" ]
74 | do
75 | ls=$( ls -ld "$app_path" )
76 | link=${ls#*' -> '}
77 | case $link in #(
78 | /*) app_path=$link ;; #(
79 | *) app_path=$APP_HOME$link ;;
80 | esac
81 | done
82 |
83 | # This is normally unused
84 | # shellcheck disable=SC2034
85 | APP_BASE_NAME=${0##*/}
86 | APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
87 |
88 | # Use the maximum available, or set MAX_FD != -1 to use that value.
89 | MAX_FD=maximum
90 |
91 | warn () {
92 | echo "$*"
93 | } >&2
94 |
95 | die () {
96 | echo
97 | echo "$*"
98 | echo
99 | exit 1
100 | } >&2
101 |
102 | # OS specific support (must be 'true' or 'false').
103 | cygwin=false
104 | msys=false
105 | darwin=false
106 | nonstop=false
107 | case "$( uname )" in #(
108 | CYGWIN* ) cygwin=true ;; #(
109 | Darwin* ) darwin=true ;; #(
110 | MSYS* | MINGW* ) msys=true ;; #(
111 | NONSTOP* ) nonstop=true ;;
112 | esac
113 |
114 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
115 |
116 |
117 | # Determine the Java command to use to start the JVM.
118 | if [ -n "$JAVA_HOME" ] ; then
119 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
120 | # IBM's JDK on AIX uses strange locations for the executables
121 | JAVACMD=$JAVA_HOME/jre/sh/java
122 | else
123 | JAVACMD=$JAVA_HOME/bin/java
124 | fi
125 | if [ ! -x "$JAVACMD" ] ; then
126 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
127 |
128 | Please set the JAVA_HOME variable in your environment to match the
129 | location of your Java installation."
130 | fi
131 | else
132 | JAVACMD=java
133 | if ! command -v java >/dev/null 2>&1
134 | then
135 | die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
136 |
137 | Please set the JAVA_HOME variable in your environment to match the
138 | location of your Java installation."
139 | fi
140 | fi
141 |
142 | # Increase the maximum file descriptors if we can.
143 | if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
144 | case $MAX_FD in #(
145 | max*)
146 | # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
147 | # shellcheck disable=SC3045
148 | MAX_FD=$( ulimit -H -n ) ||
149 | warn "Could not query maximum file descriptor limit"
150 | esac
151 | case $MAX_FD in #(
152 | '' | soft) :;; #(
153 | *)
154 | # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
155 | # shellcheck disable=SC3045
156 | ulimit -n "$MAX_FD" ||
157 | warn "Could not set maximum file descriptor limit to $MAX_FD"
158 | esac
159 | fi
160 |
161 | # Collect all arguments for the java command, stacking in reverse order:
162 | # * args from the command line
163 | # * the main class name
164 | # * -classpath
165 | # * -D...appname settings
166 | # * --module-path (only if needed)
167 | # * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
168 |
169 | # For Cygwin or MSYS, switch paths to Windows format before running java
170 | if "$cygwin" || "$msys" ; then
171 | APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
172 | CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
173 |
174 | JAVACMD=$( cygpath --unix "$JAVACMD" )
175 |
176 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
177 | for arg do
178 | if
179 | case $arg in #(
180 | -*) false ;; # don't mess with options #(
181 | /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
182 | [ -e "$t" ] ;; #(
183 | *) false ;;
184 | esac
185 | then
186 | arg=$( cygpath --path --ignore --mixed "$arg" )
187 | fi
188 | # Roll the args list around exactly as many times as the number of
189 | # args, so each arg winds up back in the position where it started, but
190 | # possibly modified.
191 | #
192 | # NB: a `for` loop captures its iteration list before it begins, so
193 | # changing the positional parameters here affects neither the number of
194 | # iterations, nor the values presented in `arg`.
195 | shift # remove old arg
196 | set -- "$@" "$arg" # push replacement arg
197 | done
198 | fi
199 |
200 |
201 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
202 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
203 |
204 | # Collect all arguments for the java command;
205 | # * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
206 | # shell script including quotes and variable substitutions, so put them in
207 | # double quotes to make sure that they get re-expanded; and
208 | # * put everything else in single quotes, so that it's not re-expanded.
209 |
210 | set -- \
211 | "-Dorg.gradle.appname=$APP_BASE_NAME" \
212 | -classpath "$CLASSPATH" \
213 | org.gradle.wrapper.GradleWrapperMain \
214 | "$@"
215 |
216 | # Stop when "xargs" is not available.
217 | if ! command -v xargs >/dev/null 2>&1
218 | then
219 | die "xargs is not available"
220 | fi
221 |
222 | # Use "xargs" to parse quoted args.
223 | #
224 | # With -n1 it outputs one arg per line, with the quotes and backslashes removed.
225 | #
226 | # In Bash we could simply go:
227 | #
228 | # readarray ARGS < <( xargs -n1 <<<"$var" ) &&
229 | # set -- "${ARGS[@]}" "$@"
230 | #
231 | # but POSIX shell has neither arrays nor command substitution, so instead we
232 | # post-process each arg (as a line of input to sed) to backslash-escape any
233 | # character that might be a shell metacharacter, then use eval to reverse
234 | # that process (while maintaining the separation between arguments), and wrap
235 | # the whole thing up as a single "set" statement.
236 | #
237 | # This will of course break if any of these variables contains a newline or
238 | # an unmatched quote.
239 | #
240 |
241 | eval "set -- $(
242 | printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
243 | xargs -n1 |
244 | sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
245 | tr '\n' ' '
246 | )" '"$@"'
247 |
248 | exec "$JAVACMD" "$@"
249 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @rem
2 | @rem Copyright 2015 the original author or authors.
3 | @rem
4 | @rem Licensed under the Apache License, Version 2.0 (the "License");
5 | @rem you may not use this file except in compliance with the License.
6 | @rem You may obtain a copy of the License at
7 | @rem
8 | @rem https://www.apache.org/licenses/LICENSE-2.0
9 | @rem
10 | @rem Unless required by applicable law or agreed to in writing, software
11 | @rem distributed under the License is distributed on an "AS IS" BASIS,
12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | @rem See the License for the specific language governing permissions and
14 | @rem limitations under the License.
15 | @rem
16 |
17 | @if "%DEBUG%"=="" @echo off
18 | @rem ##########################################################################
19 | @rem
20 | @rem Gradle startup script for Windows
21 | @rem
22 | @rem ##########################################################################
23 |
24 | @rem Set local scope for the variables with windows NT shell
25 | if "%OS%"=="Windows_NT" setlocal
26 |
27 | set DIRNAME=%~dp0
28 | if "%DIRNAME%"=="" set DIRNAME=.
29 | @rem This is normally unused
30 | set APP_BASE_NAME=%~n0
31 | set APP_HOME=%DIRNAME%
32 |
33 | @rem Resolve any "." and ".." in APP_HOME to make it shorter.
34 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
35 |
36 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
37 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
38 |
39 | @rem Find java.exe
40 | if defined JAVA_HOME goto findJavaFromJavaHome
41 |
42 | set JAVA_EXE=java.exe
43 | %JAVA_EXE% -version >NUL 2>&1
44 | if %ERRORLEVEL% equ 0 goto execute
45 |
46 | echo.
47 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
48 | echo.
49 | echo Please set the JAVA_HOME variable in your environment to match the
50 | echo location of your Java installation.
51 |
52 | goto fail
53 |
54 | :findJavaFromJavaHome
55 | set JAVA_HOME=%JAVA_HOME:"=%
56 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
57 |
58 | if exist "%JAVA_EXE%" goto execute
59 |
60 | echo.
61 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
62 | echo.
63 | echo Please set the JAVA_HOME variable in your environment to match the
64 | echo location of your Java installation.
65 |
66 | goto fail
67 |
68 | :execute
69 | @rem Setup the command line
70 |
71 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
72 |
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if %ERRORLEVEL% equ 0 goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | set EXIT_CODE=%ERRORLEVEL%
85 | if %EXIT_CODE% equ 0 set EXIT_CODE=1
86 | if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
87 | exit /b %EXIT_CODE%
88 |
89 | :mainEnd
90 | if "%OS%"=="Windows_NT" endlocal
91 |
92 | :omega
93 |
--------------------------------------------------------------------------------
/screenshots/compose.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/apter-tech/ParallaxCarouselCompose/b2e45f87dd4f82486db887625a4780b5fb0c89e8/screenshots/compose.gif
--------------------------------------------------------------------------------
/settings.gradle.kts:
--------------------------------------------------------------------------------
1 | pluginManagement {
2 | repositories {
3 | google()
4 | mavenCentral()
5 | gradlePluginPortal()
6 | }
7 | }
8 | dependencyResolutionManagement {
9 | repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
10 | repositories {
11 | google()
12 | mavenCentral()
13 | }
14 | }
15 |
16 | rootProject.name = "ParallaxCarouselCompose"
17 | include(":app")
18 |
--------------------------------------------------------------------------------