From e3d2a3744bf8db819040c7c4796d3b3326e4a836 Mon Sep 17 00:00:00 2001 From: cp-megh Date: Wed, 3 Jan 2024 18:29:14 +0530 Subject: [PATCH 1/3] Fix deployment - phase 2 --- bottombar/build.gradle.kts | 9 ++++----- build.gradle.kts | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/bottombar/build.gradle.kts b/bottombar/build.gradle.kts index 1c71dc2..a3a801e 100644 --- a/bottombar/build.gradle.kts +++ b/bottombar/build.gradle.kts @@ -13,7 +13,7 @@ apply{ } android { - namespace = "com.example.bottombar" + namespace = "com.canopas.lib.bottombar" compileSdk = 34 defaultConfig { @@ -36,11 +36,11 @@ android { } } compileOptions { - sourceCompatibility = JavaVersion.VERSION_11 - targetCompatibility = JavaVersion.VERSION_11 + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 } kotlinOptions { - jvmTarget = "11" + jvmTarget = "17" } buildFeatures { compose = true @@ -56,7 +56,6 @@ android { publishing { singleVariant("release") { - withJavadocJar() withSourcesJar() } } diff --git a/build.gradle.kts b/build.gradle.kts index 0d9eb12..3146f48 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -3,7 +3,7 @@ plugins { id("com.android.application") version "8.1.1" apply false id("org.jetbrains.kotlin.android") version "1.9.10" apply false id("com.android.library") version "8.1.1" apply false - id ("io.github.gradle-nexus.publish-plugin") version "1.1.0" + id ("io.github.gradle-nexus.publish-plugin") version "1.3.0" } apply{ From e95cbdf4917b433c96cb73a33e3c5472e9cd3991 Mon Sep 17 00:00:00 2001 From: cp-megh Date: Wed, 3 Jan 2024 18:31:51 +0530 Subject: [PATCH 2/3] Fix build --- .../main/java/com/example/bottombar/components/Indicators.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bottombar/src/main/java/com/example/bottombar/components/Indicators.kt b/bottombar/src/main/java/com/example/bottombar/components/Indicators.kt index f009a2d..b898b3e 100644 --- a/bottombar/src/main/java/com/example/bottombar/components/Indicators.kt +++ b/bottombar/src/main/java/com/example/bottombar/components/Indicators.kt @@ -25,7 +25,7 @@ import androidx.compose.ui.graphics.Path import androidx.compose.ui.res.painterResource import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp -import com.example.bottombar.R +import com.canopas.lib.bottombar.R @Composable internal fun LineIndicator( From e88984454398c38633cd1c30cb998456500b85b5 Mon Sep 17 00:00:00 2001 From: cp-megh Date: Wed, 3 Jan 2024 18:37:34 +0530 Subject: [PATCH 3/3] Make worm indicator internal --- .../bottombar/components/Indicators.kt | 32 +------------------ .../bottombar/utils/ModifierExtensions.kt | 32 +++++++++++++++++++ 2 files changed, 33 insertions(+), 31 deletions(-) diff --git a/bottombar/src/main/java/com/example/bottombar/components/Indicators.kt b/bottombar/src/main/java/com/example/bottombar/components/Indicators.kt index b898b3e..e5c165a 100644 --- a/bottombar/src/main/java/com/example/bottombar/components/Indicators.kt +++ b/bottombar/src/main/java/com/example/bottombar/components/Indicators.kt @@ -15,17 +15,13 @@ import androidx.compose.material3.Icon import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier -import androidx.compose.ui.composed import androidx.compose.ui.draw.clip -import androidx.compose.ui.draw.drawWithContent -import androidx.compose.ui.geometry.CornerRadius -import androidx.compose.ui.geometry.RoundRect import androidx.compose.ui.graphics.Color -import androidx.compose.ui.graphics.Path import androidx.compose.ui.res.painterResource import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp import com.canopas.lib.bottombar.R +import com.example.bottombar.utils.customWormTransition @Composable internal fun LineIndicator( @@ -114,30 +110,4 @@ internal fun FilledIndicator( .clip(indicatorShape) .background(indicatorColor, shape = indicatorShape) ) -} - -fun Modifier.customWormTransition( - offset: Dp, - indicatorColor: Color, - itemWidth: Dp -) = composed { - drawWithContent { - val distance = itemWidth.roundToPx() - val scrollPosition = (offset.toPx().div(distance)) - val wormOffset = (scrollPosition % 1) * 2 - - val xPos = scrollPosition.toInt() * distance - val head = xPos + distance * 0f.coerceAtLeast(wormOffset - 1) - val tail = xPos + size.width + distance * 1f.coerceAtMost(wormOffset) - - val worm = RoundRect( - head, 0f, tail, size.height, - CornerRadius(50f) - ) - - val path = Path().apply { addRoundRect(worm) } - - // Draw the worm shape on top of the content - drawPath(path = path, color = indicatorColor) - } } \ No newline at end of file diff --git a/bottombar/src/main/java/com/example/bottombar/utils/ModifierExtensions.kt b/bottombar/src/main/java/com/example/bottombar/utils/ModifierExtensions.kt index 88279d4..21d5d87 100644 --- a/bottombar/src/main/java/com/example/bottombar/utils/ModifierExtensions.kt +++ b/bottombar/src/main/java/com/example/bottombar/utils/ModifierExtensions.kt @@ -3,6 +3,12 @@ package com.example.bottombar.utils import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.composed +import androidx.compose.ui.draw.drawWithContent +import androidx.compose.ui.geometry.CornerRadius +import androidx.compose.ui.geometry.RoundRect +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.graphics.Path +import androidx.compose.ui.unit.Dp internal fun Modifier.conditional( condition: Boolean, @@ -14,4 +20,30 @@ internal fun Modifier.conditional( } else { orElse?.invoke(this) ?: this } +} + +internal fun Modifier.customWormTransition( + offset: Dp, + indicatorColor: Color, + itemWidth: Dp +) = composed { + drawWithContent { + val distance = itemWidth.roundToPx() + val scrollPosition = (offset.toPx().div(distance)) + val wormOffset = (scrollPosition % 1) * 2 + + val xPos = scrollPosition.toInt() * distance + val head = xPos + distance * 0f.coerceAtLeast(wormOffset - 1) + val tail = xPos + size.width + distance * 1f.coerceAtMost(wormOffset) + + val worm = RoundRect( + head, 0f, tail, size.height, + CornerRadius(50f) + ) + + val path = Path().apply { addRoundRect(worm) } + + // Draw the worm shape on top of the content + drawPath(path = path, color = indicatorColor) + } } \ No newline at end of file