Skip to content

Commit

Permalink
Merge pull request #11 from canopas/megh/fix-deployment-phase-2
Browse files Browse the repository at this point in the history
Fix deployment - phase 2
  • Loading branch information
cp-megh-l authored Jan 3, 2024
2 parents c5d72ec + e889844 commit 9c0eb11
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 38 deletions.
9 changes: 4 additions & 5 deletions bottombar/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ apply{
}

android {
namespace = "com.example.bottombar"
namespace = "com.canopas.lib.bottombar"
compileSdk = 34

defaultConfig {
Expand All @@ -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
Expand All @@ -56,7 +56,6 @@ android {

publishing {
singleVariant("release") {
withJavadocJar()
withSourcesJar()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.example.bottombar.R
import com.canopas.lib.bottombar.R
import com.example.bottombar.utils.customWormTransition

@Composable
internal fun LineIndicator(
Expand Down Expand Up @@ -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)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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)
}
}
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down

0 comments on commit 9c0eb11

Please sign in to comment.