Repository: canopas/compose-animated-navigationbar Branch: master Commit: e0b00e9eaccd Files: 67 Total size: 123.7 KB Directory structure: gitextract_0gaodgeh/ ├── .github/ │ └── workflows/ │ ├── build.yaml │ └── publish.yml ├── .gitignore ├── .idea/ │ ├── .gitignore │ ├── .name │ ├── compiler.xml │ ├── deploymentTargetDropDown.xml │ ├── deploymentTargetSelector.xml │ ├── gradle.xml │ ├── inspectionProfiles/ │ │ └── Project_Default.xml │ ├── kotlinc.xml │ ├── migrations.xml │ ├── misc.xml │ └── vcs.xml ├── License ├── README.md ├── app/ │ ├── .gitignore │ ├── build.gradle.kts │ ├── proguard-rules.pro │ └── src/ │ ├── androidTest/ │ │ └── java/ │ │ └── com/ │ │ └── example/ │ │ └── animatedbottombarcompose/ │ │ └── ExampleInstrumentedTest.kt │ ├── main/ │ │ ├── AndroidManifest.xml │ │ ├── java/ │ │ │ └── com/ │ │ │ └── example/ │ │ │ └── animatedbottombarcompose/ │ │ │ ├── MainActivity.kt │ │ │ ├── composables/ │ │ │ │ ├── Screen1.kt │ │ │ │ ├── Screen2.kt │ │ │ │ └── Screen3.kt │ │ │ ├── model/ │ │ │ │ └── MainNavigation.kt │ │ │ └── ui/ │ │ │ └── theme/ │ │ │ ├── Color.kt │ │ │ ├── Theme.kt │ │ │ └── Type.kt │ │ └── res/ │ │ ├── drawable/ │ │ │ ├── ic_launcher_background.xml │ │ │ └── ic_launcher_foreground.xml │ │ ├── mipmap-anydpi-v26/ │ │ │ ├── ic_launcher.xml │ │ │ └── ic_launcher_round.xml │ │ ├── values/ │ │ │ ├── colors.xml │ │ │ ├── strings.xml │ │ │ └── themes.xml │ │ └── xml/ │ │ ├── backup_rules.xml │ │ └── data_extraction_rules.xml │ └── test/ │ └── java/ │ └── com/ │ └── example/ │ └── animatedbottombarcompose/ │ └── ExampleUnitTest.kt ├── bottombar/ │ ├── .gitignore │ ├── build.gradle.kts │ ├── consumer-rules.pro │ ├── proguard-rules.pro │ └── src/ │ ├── androidTest/ │ │ └── java/ │ │ └── com/ │ │ └── example/ │ │ └── bottombar/ │ │ └── ExampleInstrumentedTest.kt │ ├── main/ │ │ ├── AndroidManifest.xml │ │ ├── java/ │ │ │ └── com/ │ │ │ └── example/ │ │ │ └── bottombar/ │ │ │ ├── AnimatedBottomBar.kt │ │ │ ├── components/ │ │ │ │ ├── BottomBarItem.kt │ │ │ │ ├── Indicators.kt │ │ │ │ └── NavigationBarItem.kt │ │ │ ├── model/ │ │ │ │ ├── AnimationState.kt │ │ │ │ ├── IndicatorDirection.kt │ │ │ │ ├── IndicatorStyle.kt │ │ │ │ ├── ItemStyle.kt │ │ │ │ └── VisibleItem.kt │ │ │ └── utils/ │ │ │ ├── Constants.kt │ │ │ └── ModifierExtensions.kt │ │ └── res/ │ │ └── drawable/ │ │ └── ic_dot_indicator.xml │ └── test/ │ └── java/ │ └── com/ │ └── example/ │ └── bottombar/ │ └── ExampleUnitTest.kt ├── build.gradle.kts ├── gradle/ │ └── wrapper/ │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradle.properties ├── gradlew ├── gradlew.bat ├── scripts/ │ ├── publish-module.gradle │ └── publish-root.gradle └── settings.gradle.kts ================================================ FILE CONTENTS ================================================ ================================================ FILE: .github/workflows/build.yaml ================================================ name: Android Build on: [ push ] jobs: build: runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v2 - name: Set up JDK 17 uses: actions/setup-java@v2 with: java-version: 17 cache: 'gradle' distribution: adopt - name: Build with Gradle run: ./gradlew build ================================================ FILE: .github/workflows/publish.yml ================================================ name: Publish on: push: tags: - '*' jobs: publish: name: Release build and publish runs-on: ubuntu-latest steps: - name: Check out code uses: actions/checkout@v2 - name: Set up JDK 17 uses: actions/setup-java@v2 with: distribution: adopt java-version: 17 - name: Publish to MavenCentral run: ./gradlew bottombar:publishReleasePublicationToSonatypeRepository --max-workers 1 closeAndReleaseSonatypeStagingRepository env: OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }} OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }} SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }} SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }} SIGNING_KEY: ${{ secrets.SIGNING_KEY }} SONATYPE_STAGING_PROFILE_ID: ${{ secrets.SONATYPE_STAGING_PROFILE_ID }} PUBLISH_VERSION: ${{ secrets.PUBLISH_VERSION }} ================================================ FILE: .gitignore ================================================ *.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 ================================================ FILE: .idea/.gitignore ================================================ # Default ignored files /shelf/ /workspace.xml ================================================ FILE: .idea/.name ================================================ AnimatedBottomBarCompose ================================================ FILE: .idea/compiler.xml ================================================ ================================================ FILE: .idea/deploymentTargetDropDown.xml ================================================ ================================================ FILE: .idea/deploymentTargetSelector.xml ================================================ ================================================ FILE: .idea/gradle.xml ================================================ ================================================ FILE: .idea/inspectionProfiles/Project_Default.xml ================================================ ================================================ FILE: .idea/kotlinc.xml ================================================ ================================================ FILE: .idea/migrations.xml ================================================ ================================================ FILE: .idea/misc.xml ================================================ ================================================ FILE: .idea/vcs.xml ================================================ ================================================ FILE: License ================================================ Copyright 2022 Canopas Software LLP 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. ================================================ FILE: README.md ================================================

cta_banner

# AnimatedBottomBarCompose **AnimatedBottomBarCompose** is a Jetpack Compose library that simplifies the creation of stylish Bottom Navigation Bars with customizable animations. It allows you to easily integrate attractive navigation bars into your Android app, enhancing the user experience.
LINE INDICATOR

FILLED INDICATOR

DOT INDICATOR

WORM INDICATOR

## Features - **Multiple Styles:** Choose from a variety of pre-defined styles for your Bottom Navigation Bar or create your custom style. - **Animation Options:** Choose from variety of eye-catching animations for your navigation bar elements, making your app more engaging. - **Customization:** Customize colors, icons, and animations to match your app's branding and design. ## Configuration Available on [Maven Central](https://central.sonatype.com/artifact/com.canopas.compose-animated-navigationbar/bottombar). Add the dependency ```gradle implementation 'com.canopas.compose-animated-navigationbar:bottombar:1.0.1' ``` ## Sample Usage Integrating **AnimatedBottomBarCompose** into your Android app is a breeze! Follow these simple steps to get started: 1. First, set up your navigation controller: ``` val navController = rememberNavController() val navBackStackEntry by navController.currentBackStackEntryAsState() val currentRoute = navBackStackEntry?.destination?.route val navigationItems = MainNavigation::class.nestedClasses.map { it.objectInstance as MainNavigation } var selectedItem by remember { mutableIntStateOf(0) } ``` 2. Next, add **AnimatedBottomBarCompose** to your app's Scaffold as the bottom bar: ``` Scaffold( bottomBar = { AnimatedBottomBar( selectedItem = selectedItem, itemSize = navigationItems.take(3).size, containerColor = Color.LightGray, indicatorStyle = IndicatorStyle.LINE ) { navigationItems.forEachIndexed { index, navigationItem -> BottomBarItem( selected = currentRoute == navigationItem.route, onClick = { if (currentRoute != navigationItem.route) { selectedItem = index // ... Navigation Stuff } }, imageVector = navigationItem.icon, label = navigationItem.title, containerColor = Color.Transparent ) } } } ) { // ... (rest of your app content) } ``` ## Demo To see **AnimatedBottomBarCompose** in action, check out our [Sample](https://github.com/canopas/AnimatedBottomBarCompose/tree/master/app) app where you can explore various styles and animation options. ## Bugs and Feedback For bugs, questions and discussions please use the [Github Issues](https://github.com/canopas/AnimatedBottomBarCompose/issues) ## Credits **AnimatedBottomBarCompose** is owned and maintained by the [Canopas team](https://canopas.com/). For project updates and releases, you can follow them on X at [@canopassoftware](https://x.com/canopassoftware). # Licence ``` Copyright 2023 Canopas Software LLP Licensed under the Apache License, Version 2.0 (the "License"); You won't be using 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. ``` ================================================ FILE: app/.gitignore ================================================ /build ================================================ FILE: app/build.gradle.kts ================================================ plugins { id("com.android.application") id("org.jetbrains.kotlin.android") } android { namespace = "com.example.animatedbottombarcompose" compileSdk = 34 defaultConfig { applicationId = "com.example.animatedbottombarcompose" minSdk = 24 versionCode = 1 versionName = "1.0" testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" vectorDrawables { useSupportLibrary = true } } buildTypes { release { isMinifyEnabled = false proguardFiles( getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro", ) } } compileOptions { sourceCompatibility = JavaVersion.VERSION_11 targetCompatibility = JavaVersion.VERSION_11 } kotlinOptions { jvmTarget = "11" } buildFeatures { compose = true } composeOptions { kotlinCompilerExtensionVersion = "1.5.3" } packaging { resources { excludes += "/META-INF/{AL2.0,LGPL2.1}" } } } dependencies { implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.8.1") implementation("androidx.activity:activity-compose:1.9.0") implementation(platform("androidx.compose:compose-bom:2024.05.00")) implementation("androidx.compose.ui:ui") implementation("androidx.compose.ui:ui-graphics") implementation("androidx.navigation:navigation-compose:2.7.7") 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:2024.05.00")) androidTestImplementation("androidx.compose.ui:ui-test-junit4") debugImplementation("androidx.compose.ui:ui-tooling") debugImplementation("androidx.compose.ui:ui-test-manifest") implementation(project(":bottombar")) implementation(kotlin("reflect")) } ================================================ FILE: app/proguard-rules.pro ================================================ # 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 ================================================ FILE: app/src/androidTest/java/com/example/animatedbottombarcompose/ExampleInstrumentedTest.kt ================================================ package com.example.animatedbottombarcompose import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.platform.app.InstrumentationRegistry import org.junit.Assert.* import org.junit.Test import org.junit.runner.RunWith /** * 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.example.animatedbottombarcompose", appContext.packageName) } } ================================================ FILE: app/src/main/AndroidManifest.xml ================================================ ================================================ FILE: app/src/main/java/com/example/animatedbottombarcompose/MainActivity.kt ================================================ package com.example.animatedbottombarcompose import android.annotation.SuppressLint import android.os.Bundle import androidx.activity.ComponentActivity import androidx.activity.compose.setContent import androidx.compose.material3.Scaffold import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableIntStateOf import androidx.compose.runtime.remember import androidx.compose.runtime.setValue import androidx.compose.ui.graphics.Color import androidx.navigation.compose.NavHost import androidx.navigation.compose.composable import androidx.navigation.compose.currentBackStackEntryAsState import androidx.navigation.compose.rememberNavController import com.example.animatedbottombarcompose.composables.Screen1 import com.example.animatedbottombarcompose.composables.Screen2 import com.example.animatedbottombarcompose.composables.Screen3 import com.example.animatedbottombarcompose.model.MainNavigation import com.example.animatedbottombarcompose.ui.theme.AnimatedBottomBarComposeTheme import com.example.bottombar.AnimatedBottomBar import com.example.bottombar.components.BottomBarItem import com.example.bottombar.model.IndicatorStyle class MainActivity : ComponentActivity() { @SuppressLint("UnusedMaterial3ScaffoldPaddingParameter") override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContent { AnimatedBottomBarComposeTheme { val navController = rememberNavController() val navBackStackEntry by navController.currentBackStackEntryAsState() val currentRoute = navBackStackEntry?.destination?.route val navigationItems = MainNavigation::class.nestedClasses.map { it.objectInstance as MainNavigation } var selectedItem by remember { mutableIntStateOf(0) } Scaffold( bottomBar = { AnimatedBottomBar( selectedItem = selectedItem, itemSize = navigationItems.take(3).size, containerColor = Color.LightGray, indicatorStyle = IndicatorStyle.DOT, ) { navigationItems.take(3).forEachIndexed { index, navigationItem -> BottomBarItem( selected = currentRoute == navigationItem.route, onClick = { if (currentRoute != navigationItem.route) { selectedItem = index navController.popBackStack() navController.navigate(navigationItem.route) { navController.graph.startDestinationRoute?.let { route -> popUpTo(route) { saveState = true } } launchSingleTop = true restoreState = true } } }, imageVector = navigationItem.icon, label = navigationItem.title, containerColor = Color.Transparent, ) } } }, ) { NavHost( navController = navController, startDestination = MainNavigation.ScreenA.route, ) { composable(MainNavigation.ScreenA.route) { Screen1(navigationItems) } composable(MainNavigation.ScreenB.route) { Screen2(navigationItems) } composable(MainNavigation.ScreenC.route) { Screen3(navigationItems) } } } } } } } ================================================ FILE: app/src/main/java/com/example/animatedbottombarcompose/composables/Screen1.kt ================================================ package com.example.animatedbottombarcompose.composables import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.foundation.verticalScroll import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableIntStateOf import androidx.compose.runtime.remember import androidx.compose.runtime.setValue import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Brush import androidx.compose.ui.graphics.Color import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.unit.dp import com.example.animatedbottombarcompose.model.MainNavigation import com.example.bottombar.AnimatedBottomBar import com.example.bottombar.components.BottomBarItem import com.example.bottombar.model.IndicatorDirection import com.example.bottombar.model.IndicatorStyle import com.example.bottombar.model.ItemStyle import com.example.bottombar.model.VisibleItem @Composable fun Screen1(navigationItems: List) { var selectedItem by remember { mutableIntStateOf(0) } Column( modifier = Modifier .fillMaxSize() .verticalScroll(rememberScrollState()), verticalArrangement = Arrangement.Top, ) { Text( text = "**Checkout INDICATORS with different STYLES(animations)**", style = MaterialTheme.typography.titleMedium, modifier = Modifier .fillMaxWidth() .padding(top = 20.dp), textAlign = TextAlign.Center, ) Spacer(modifier = Modifier.height(50.dp)) Text( text = "LINE INDICATOR", style = MaterialTheme.typography.headlineSmall, modifier = Modifier.fillMaxWidth(), textAlign = TextAlign.Center, ) Spacer(modifier = Modifier.height(25.dp)) AnimatedBottomBar( selectedItem = selectedItem, itemSize = navigationItems.size, indicatorStyle = IndicatorStyle.LINE, containerShape = RoundedCornerShape(topStart = 10.dp, topEnd = 10.dp), containerColor = MaterialTheme.colorScheme.secondaryContainer, ) { navigationItems.forEachIndexed { index, navigationItem -> val selected = index == selectedItem BottomBarItem( selected = selected, onClick = { selectedItem = index }, imageVector = navigationItem.icon, label = navigationItem.title, visibleItem = VisibleItem.ICON, itemStyle = ItemStyle.STYLE1, ) } } Spacer(modifier = Modifier.height(25.dp)) AnimatedBottomBar( selectedItem = selectedItem, itemSize = navigationItems.size, indicatorStyle = IndicatorStyle.LINE, containerShape = RoundedCornerShape(topStart = 10.dp, topEnd = 10.dp), containerColor = MaterialTheme.colorScheme.secondaryContainer, ) { navigationItems.forEachIndexed { index, navigationItem -> val selected = index == selectedItem BottomBarItem( selected = selected, onClick = { selectedItem = index }, imageVector = navigationItem.icon, label = navigationItem.title, visibleItem = VisibleItem.LABEL, itemStyle = ItemStyle.STYLE1, ) } } Spacer(modifier = Modifier.height(25.dp)) AnimatedBottomBar( selectedItem = selectedItem, itemSize = navigationItems.size, indicatorStyle = IndicatorStyle.LINE, containerShape = RoundedCornerShape(topStart = 10.dp, topEnd = 10.dp), containerColor = MaterialTheme.colorScheme.secondaryContainer, ) { navigationItems.forEachIndexed { index, navigationItem -> val selected = index == selectedItem BottomBarItem( selected = selected, onClick = { selectedItem = index }, imageVector = navigationItem.icon, label = navigationItem.title, visibleItem = VisibleItem.BOTH, itemStyle = ItemStyle.STYLE1, ) } } Spacer(modifier = Modifier.height(25.dp)) AnimatedBottomBar( selectedItem = selectedItem, itemSize = navigationItems.size, indicatorStyle = IndicatorStyle.LINE, containerShape = RoundedCornerShape(topStart = 10.dp, topEnd = 10.dp), indicatorDirection = IndicatorDirection.BOTTOM, containerColor = MaterialTheme.colorScheme.secondaryContainer, ) { navigationItems.forEachIndexed { index, navigationItem -> val selected = index == selectedItem BottomBarItem( selected = selected, onClick = { selectedItem = index }, imageVector = navigationItem.icon, label = navigationItem.title, visibleItem = VisibleItem.ICON, itemStyle = ItemStyle.STYLE3, ) } } Spacer(modifier = Modifier.height(25.dp)) AnimatedBottomBar( selectedItem = selectedItem, itemSize = navigationItems.size, indicatorStyle = IndicatorStyle.LINE, containerShape = RoundedCornerShape(topStart = 10.dp, topEnd = 10.dp), indicatorDirection = IndicatorDirection.BOTTOM, containerColor = MaterialTheme.colorScheme.secondaryContainer, ) { navigationItems.forEachIndexed { index, navigationItem -> val selected = index == selectedItem BottomBarItem( selected = selected, onClick = { selectedItem = index }, imageVector = navigationItem.icon, label = navigationItem.title, visibleItem = VisibleItem.LABEL, itemStyle = ItemStyle.STYLE4, ) } } Spacer(modifier = Modifier.height(25.dp)) AnimatedBottomBar( selectedItem = selectedItem, itemSize = navigationItems.size, indicatorStyle = IndicatorStyle.LINE, containerShape = RoundedCornerShape(topStart = 10.dp, topEnd = 10.dp), indicatorDirection = IndicatorDirection.BOTTOM, containerColor = MaterialTheme.colorScheme.secondaryContainer, ) { navigationItems.forEachIndexed { index, navigationItem -> val selected = index == selectedItem BottomBarItem( selected = selected, onClick = { selectedItem = index }, imageVector = navigationItem.icon, label = navigationItem.title, visibleItem = VisibleItem.BOTH, itemStyle = ItemStyle.STYLE5, ) } } Spacer(modifier = Modifier.height(50.dp)) Text( text = "DOT INDICATOR", style = MaterialTheme.typography.headlineSmall, modifier = Modifier.fillMaxWidth(), textAlign = TextAlign.Center, ) Spacer(modifier = Modifier.height(25.dp)) AnimatedBottomBar( selectedItem = selectedItem, itemSize = navigationItems.size, containerColor = MaterialTheme.colorScheme.errorContainer, indicatorStyle = IndicatorStyle.DOT, ) { navigationItems.forEachIndexed { index, navigationItem -> val selected = index == selectedItem BottomBarItem( selected = selected, onClick = { selectedItem = index }, imageVector = navigationItem.icon, label = navigationItem.title, itemStyle = ItemStyle.STYLE1, ) } } Spacer(modifier = Modifier.height(25.dp)) AnimatedBottomBar( selectedItem = selectedItem, itemSize = navigationItems.size, containerColor = MaterialTheme.colorScheme.errorContainer, indicatorStyle = IndicatorStyle.DOT, ) { navigationItems.forEachIndexed { index, navigationItem -> val selected = index == selectedItem BottomBarItem( selected = selected, onClick = { selectedItem = index }, imageVector = navigationItem.icon, label = navigationItem.title, iconColor = if (selected) Color.Black else Color.Black.copy(0.8f), textColor = if (selected) Color.Black else Color.Black.copy(0.8f), itemStyle = ItemStyle.STYLE3, ) } } Spacer(modifier = Modifier.height(25.dp)) AnimatedBottomBar( selectedItem = selectedItem, itemSize = navigationItems.size, containerColor = MaterialTheme.colorScheme.errorContainer, indicatorStyle = IndicatorStyle.DOT, ) { navigationItems.forEachIndexed { index, navigationItem -> val selected = index == selectedItem BottomBarItem( selected = selected, onClick = { selectedItem = index }, imageVector = navigationItem.icon, label = navigationItem.title, iconColor = if (selected) Color.Black else Color.Black.copy(0.8f), textColor = if (selected) Color.Black else Color.Black.copy(0.8f), itemStyle = ItemStyle.STYLE4, activeIndicatorColor = Color.White, ) } } Spacer(modifier = Modifier.height(25.dp)) AnimatedBottomBar( selectedItem = selectedItem, itemSize = navigationItems.size, containerColor = MaterialTheme.colorScheme.errorContainer, indicatorStyle = IndicatorStyle.DOT, ) { navigationItems.forEachIndexed { index, navigationItem -> val selected = index == selectedItem BottomBarItem( selected = selected, onClick = { selectedItem = index }, imageVector = navigationItem.icon, label = navigationItem.title, iconColor = if (selected) Color.Black else Color.Black.copy(0.8f), textColor = if (selected) Color.Black else Color.Black.copy(0.8f), itemStyle = ItemStyle.STYLE5, activeIndicatorColor = Color.White, ) } } Spacer(modifier = Modifier.height(50.dp)) Text( text = "WORM INDICATOR", style = MaterialTheme.typography.headlineSmall, modifier = Modifier.fillMaxWidth(), textAlign = TextAlign.Center, ) Spacer(modifier = Modifier.height(25.dp)) AnimatedBottomBar( selectedItem = selectedItem, itemSize = navigationItems.size, containerColor = MaterialTheme.colorScheme.tertiaryContainer, indicatorStyle = IndicatorStyle.WORM, ) { navigationItems.forEachIndexed { index, navigationItem -> val selected = index == selectedItem BottomBarItem( selected = selected, onClick = { selectedItem = index }, imageVector = navigationItem.icon, label = navigationItem.title, iconColor = if (selected) Color.Black else Color.Black.copy(0.8f), textColor = if (selected) Color.Black else Color.Black.copy(0.8f), itemStyle = ItemStyle.STYLE1, ) } } Spacer(modifier = Modifier.height(25.dp)) AnimatedBottomBar( selectedItem = selectedItem, itemSize = navigationItems.size, containerColor = MaterialTheme.colorScheme.tertiaryContainer, indicatorStyle = IndicatorStyle.WORM, ) { navigationItems.forEachIndexed { index, navigationItem -> val selected = index == selectedItem BottomBarItem( selected = selected, onClick = { selectedItem = index }, imageVector = navigationItem.icon, label = navigationItem.title, iconColor = if (selected) Color.Black else Color.Black.copy(0.8f), textColor = if (selected) Color.Black else Color.Black.copy(0.8f), itemStyle = ItemStyle.STYLE3, ) } } Spacer(modifier = Modifier.height(25.dp)) AnimatedBottomBar( selectedItem = selectedItem, itemSize = navigationItems.size, containerColor = MaterialTheme.colorScheme.tertiaryContainer, indicatorStyle = IndicatorStyle.WORM, ) { navigationItems.forEachIndexed { index, navigationItem -> val selected = index == selectedItem BottomBarItem( selected = selected, onClick = { selectedItem = index }, imageVector = navigationItem.icon, label = navigationItem.title, iconColor = if (selected) Color.Black else Color.Black.copy(0.8f), textColor = if (selected) Color.Black else Color.Black.copy(0.8f), itemStyle = ItemStyle.STYLE4, ) } } Spacer(modifier = Modifier.height(25.dp)) AnimatedBottomBar( selectedItem = selectedItem, itemSize = navigationItems.size, containerColor = MaterialTheme.colorScheme.tertiaryContainer, indicatorStyle = IndicatorStyle.WORM, ) { navigationItems.forEachIndexed { index, navigationItem -> val selected = index == selectedItem BottomBarItem( selected = selected, onClick = { selectedItem = index }, imageVector = navigationItem.icon, label = navigationItem.title, iconColor = if (selected) Color.Black else Color.Black.copy(0.8f), textColor = if (selected) Color.Black else Color.Black.copy(0.8f), itemStyle = ItemStyle.STYLE5, activeIndicatorColor = Color.White, ) } } Spacer(modifier = Modifier.height(50.dp)) Text( text = "FILLED INDICATOR", style = MaterialTheme.typography.headlineSmall, modifier = Modifier.fillMaxWidth(), textAlign = TextAlign.Center, ) Spacer(modifier = Modifier.height(25.dp)) AnimatedBottomBar( selectedItem = selectedItem, itemSize = navigationItems.size, containerColor = MaterialTheme.colorScheme.secondaryContainer, indicatorStyle = IndicatorStyle.FILLED, indicatorColor = MaterialTheme.colorScheme.background, ) { navigationItems.forEachIndexed { index, navigationItem -> val selected = index == selectedItem BottomBarItem( selected = selected, onClick = { selectedItem = index }, imageVector = navigationItem.icon, label = navigationItem.title, itemStyle = ItemStyle.STYLE1, ) } } Spacer(modifier = Modifier.height(25.dp)) AnimatedBottomBar( selectedItem = selectedItem, itemSize = navigationItems.size, containerColor = MaterialTheme.colorScheme.secondaryContainer, indicatorStyle = IndicatorStyle.FILLED, indicatorColor = MaterialTheme.colorScheme.background, ) { navigationItems.forEachIndexed { index, navigationItem -> val selected = index == selectedItem BottomBarItem( selected = selected, onClick = { selectedItem = index }, imageVector = navigationItem.icon, label = navigationItem.title, itemStyle = ItemStyle.STYLE3, ) } } Spacer(modifier = Modifier.height(25.dp)) AnimatedBottomBar( selectedItem = selectedItem, itemSize = navigationItems.size, containerColor = MaterialTheme.colorScheme.secondaryContainer, indicatorStyle = IndicatorStyle.FILLED, indicatorColor = MaterialTheme.colorScheme.background, ) { navigationItems.forEachIndexed { index, navigationItem -> val selected = index == selectedItem BottomBarItem( selected = selected, onClick = { selectedItem = index }, imageVector = navigationItem.icon, label = navigationItem.title, itemStyle = ItemStyle.STYLE4, ) } } Spacer(modifier = Modifier.height(25.dp)) AnimatedBottomBar( selectedItem = selectedItem, itemSize = navigationItems.size, containerColor = MaterialTheme.colorScheme.secondaryContainer, indicatorStyle = IndicatorStyle.FILLED, indicatorColor = MaterialTheme.colorScheme.background, ) { navigationItems.forEachIndexed { index, navigationItem -> val selected = index == selectedItem BottomBarItem( selected = selected, onClick = { selectedItem = index }, imageVector = navigationItem.icon, label = navigationItem.title, itemStyle = ItemStyle.STYLE5, iconColor = if (selected) Color.White else Color.Black, glowingBackground = Brush.radialGradient( listOf( Color.Black, Color.Transparent, Color.Transparent, ), ), ) } } Spacer(modifier = Modifier.height(25.dp)) AnimatedBottomBar( selectedItem = selectedItem, itemSize = navigationItems.size, containerColor = MaterialTheme.colorScheme.secondaryContainer, ) { navigationItems.forEachIndexed { index, navigationItem -> val selected = index == selectedItem BottomBarItem( selected = selected, onClick = { selectedItem = index }, imageVector = navigationItem.icon, label = navigationItem.title, itemStyle = ItemStyle.STYLE2, iconColor = if (selected) Color.Black else Color.White, textColor = if (selected) Color.Black else Color.White, activeIndicatorColor = Color.White, ) } } Spacer(modifier = Modifier.height(150.dp)) } } ================================================ FILE: app/src/main/java/com/example/animatedbottombarcompose/composables/Screen2.kt ================================================ package com.example.animatedbottombarcompose.composables import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.verticalScroll import androidx.compose.material3.MaterialTheme import androidx.compose.material3.RadioButton import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableIntStateOf import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Brush import androidx.compose.ui.graphics.Color import androidx.compose.ui.unit.dp import com.example.animatedbottombarcompose.model.MainNavigation import com.example.bottombar.AnimatedBottomBar import com.example.bottombar.components.BottomBarItem import com.example.bottombar.model.IndicatorStyle import com.example.bottombar.model.ItemStyle @Composable fun Screen2(navigationItems: List) { var selectedItem by remember { mutableIntStateOf(0) } var itemStyle: ItemStyle by remember { mutableStateOf(ItemStyle.STYLE3) } var indicatorStyle: IndicatorStyle by remember { mutableStateOf(IndicatorStyle.WORM) } val itemStyles = listOf( ItemStyle.STYLE1, ItemStyle.STYLE2, ItemStyle.STYLE3, ItemStyle.STYLE4, ItemStyle.STYLE5, ) val indicatorStyles = listOf( IndicatorStyle.NONE, IndicatorStyle.LINE, IndicatorStyle.DOT, IndicatorStyle.WORM, ) Column( modifier = Modifier .fillMaxSize() .verticalScroll(rememberScrollState()), ) { Spacer(modifier = Modifier.height(50.dp)) Text( text = "Item Style:", style = MaterialTheme.typography.titleMedium, modifier = Modifier.padding(horizontal = 8.dp), ) Column( modifier = Modifier .fillMaxWidth() .padding(horizontal = 8.dp), ) { Row(verticalAlignment = Alignment.CenterVertically) { itemStyles.take(3).forEach { RadioButton(selected = it == itemStyle, onClick = { itemStyle = it }) Text(text = it.name) } } Row(verticalAlignment = Alignment.CenterVertically) { itemStyles.takeLast(2).forEach { RadioButton(selected = it == itemStyle, onClick = { itemStyle = it }) Text(text = it.name) } } } Text( text = "Indicator Style:", style = MaterialTheme.typography.titleMedium, modifier = Modifier.padding(horizontal = 8.dp), ) Column( modifier = Modifier .fillMaxWidth() .padding(horizontal = 8.dp), ) { Row(verticalAlignment = Alignment.CenterVertically) { indicatorStyles.take(2).forEach { RadioButton(selected = it == indicatorStyle, onClick = { indicatorStyle = it }) Text(text = it.name) } } Row(verticalAlignment = Alignment.CenterVertically) { indicatorStyles.takeLast(2).forEach { RadioButton(selected = it == indicatorStyle, onClick = { indicatorStyle = it }) Text(text = it.name) } } } Spacer(modifier = Modifier.height(100.dp)) AnimatedBottomBar( selectedItem = selectedItem, itemSize = navigationItems.size, indicatorStyle = if (itemStyle != ItemStyle.STYLE2) indicatorStyle else IndicatorStyle.NONE, containerColor = Color.Transparent, indicatorColor = Color.Red, ) { navigationItems.forEachIndexed { index, navigationItem -> val selected = index == selectedItem BottomBarItem( selected = selected, onClick = { selectedItem = index }, imageVector = navigationItem.icon, label = navigationItem.title, iconColor = if (selected) Color.Red else Color.Black, textColor = if (selected) Color.Red else Color.Black, itemStyle = itemStyle, glowingBackground = Brush.radialGradient( listOf( Color.Red.copy(0.5f), Color.Transparent, Color.Transparent, ), ), ) } } Spacer(modifier = Modifier.height(50.dp)) AnimatedBottomBar( selectedItem = selectedItem, itemSize = navigationItems.size, indicatorStyle = if (itemStyle != ItemStyle.STYLE2) indicatorStyle else IndicatorStyle.NONE, indicatorColor = Color.White, ) { navigationItems.forEachIndexed { index, navigationItem -> val selected = index == selectedItem BottomBarItem( selected = selected, onClick = { selectedItem = index }, imageVector = navigationItem.icon, label = navigationItem.title, iconColor = if (selected) Color.White else Color.Black, textColor = if (selected) Color.White else Color.Black, itemStyle = itemStyle, glowingBackground = Brush.radialGradient( listOf( Color.Black, Color.Transparent, Color.Transparent, ), ), ) } } Spacer(modifier = Modifier.height(150.dp)) } } ================================================ FILE: app/src/main/java/com/example/animatedbottombarcompose/composables/Screen3.kt ================================================ package com.example.animatedbottombarcompose.composables import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.verticalScroll import androidx.compose.material3.MaterialTheme import androidx.compose.material3.RadioButton import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableIntStateOf import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color import androidx.compose.ui.unit.dp import com.example.animatedbottombarcompose.model.MainNavigation import com.example.bottombar.AnimatedBottomBar import com.example.bottombar.components.BottomBarItem import com.example.bottombar.model.IndicatorStyle import com.example.bottombar.model.ItemStyle @Composable fun Screen3(navigationItems: List) { var selectedItem by remember { mutableIntStateOf(0) } var itemStyle: ItemStyle by remember { mutableStateOf(ItemStyle.STYLE3) } val itemStyles = listOf( ItemStyle.STYLE1, ItemStyle.STYLE2, ItemStyle.STYLE3, ItemStyle.STYLE4, ItemStyle.STYLE5, ) Column( modifier = Modifier .fillMaxSize() .verticalScroll(rememberScrollState()), ) { Spacer(modifier = Modifier.height(50.dp)) Text( text = "Item Style:", style = MaterialTheme.typography.titleMedium, modifier = Modifier.padding(horizontal = 8.dp), ) Column( modifier = Modifier .fillMaxWidth() .padding(horizontal = 8.dp), ) { Row(verticalAlignment = Alignment.CenterVertically) { itemStyles.take(3).forEach { RadioButton(selected = it == itemStyle, onClick = { itemStyle = it }) Text(text = it.name) } } Row(verticalAlignment = Alignment.CenterVertically) { itemStyles.takeLast(2).forEach { RadioButton(selected = it == itemStyle, onClick = { itemStyle = it }) Text(text = it.name) } } } Spacer(modifier = Modifier.height(100.dp)) AnimatedBottomBar( selectedItem = selectedItem, itemSize = navigationItems.size, indicatorStyle = if (itemStyle != ItemStyle.STYLE2) IndicatorStyle.FILLED else IndicatorStyle.NONE, containerColor = Color.Transparent, indicatorColor = Color.Red.copy(0.5f), ) { navigationItems.forEachIndexed { index, navigationItem -> val selected = index == selectedItem BottomBarItem( selected = selected, onClick = { selectedItem = index }, imageVector = navigationItem.icon, label = navigationItem.title, iconColor = if (selected) Color.White else Color.Black, textColor = if (selected) Color.White else Color.Black, itemStyle = itemStyle, activeIndicatorColor = Color.Red.copy(0.5f), ) } } Spacer(modifier = Modifier.height(50.dp)) AnimatedBottomBar( selectedItem = selectedItem, itemSize = navigationItems.size, indicatorStyle = if (itemStyle != ItemStyle.STYLE2) IndicatorStyle.FILLED else IndicatorStyle.NONE, indicatorColor = Color.White, ) { navigationItems.forEachIndexed { index, navigationItem -> val selected = index == selectedItem BottomBarItem( selected = selected, onClick = { selectedItem = index }, imageVector = navigationItem.icon, label = navigationItem.title, iconColor = if (selected) Color.Black else Color.White, textColor = if (selected) Color.Black else Color.White, itemStyle = itemStyle, activeIndicatorColor = Color.White, ) } } Spacer(modifier = Modifier.height(150.dp)) } } ================================================ FILE: app/src/main/java/com/example/animatedbottombarcompose/model/MainNavigation.kt ================================================ package com.example.animatedbottombarcompose.model import androidx.compose.material.icons.Icons import androidx.compose.material.icons.outlined.Email import androidx.compose.material.icons.outlined.FavoriteBorder import androidx.compose.material.icons.outlined.Home import androidx.compose.material.icons.outlined.Notifications import androidx.compose.ui.graphics.vector.ImageVector sealed class MainNavigation( val title: String, val route: String, val icon: ImageVector, ) { data object ScreenA : MainNavigation( title = "Screen1", route = "Screen1", icon = Icons.Outlined.Home, ) data object ScreenB : MainNavigation( title = "Screen2", route = "Screen2", icon = Icons.Outlined.Notifications, ) data object ScreenC : MainNavigation( title = "Screen3", route = "Screen3", icon = Icons.Outlined.FavoriteBorder, ) data object ScreenD : MainNavigation( title = "Screen4", route = "Screen4", icon = Icons.Outlined.Email, ) } ================================================ FILE: app/src/main/java/com/example/animatedbottombarcompose/ui/theme/Color.kt ================================================ package com.example.animatedbottombarcompose.ui.theme import androidx.compose.ui.graphics.Color val Purple80 = Color(0xFFD0BCFF) val PurpleGrey80 = Color(0xFFCCC2DC) val Pink80 = Color(0xFFEFB8C8) val Purple40 = Color(0xFF6650a4) val PurpleGrey40 = Color(0xFF625b71) val Pink40 = Color(0xFF7D5260) ================================================ FILE: app/src/main/java/com/example/animatedbottombarcompose/ui/theme/Theme.kt ================================================ package com.example.animatedbottombarcompose.ui.theme import android.app.Activity import android.os.Build import androidx.compose.foundation.isSystemInDarkTheme import androidx.compose.material3.MaterialTheme import androidx.compose.material3.darkColorScheme import androidx.compose.material3.dynamicDarkColorScheme import androidx.compose.material3.dynamicLightColorScheme import androidx.compose.material3.lightColorScheme import androidx.compose.runtime.Composable import androidx.compose.runtime.SideEffect import androidx.compose.ui.graphics.toArgb import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.platform.LocalView import androidx.core.view.WindowCompat private val DarkColorScheme = darkColorScheme( primary = Purple80, secondary = PurpleGrey80, tertiary = Pink80, ) private val LightColorScheme = lightColorScheme( primary = Purple40, secondary = PurpleGrey40, tertiary = Pink40, /* Other default colors to override background = Color(0xFFFFFBFE), surface = Color(0xFFFFFBFE), onPrimary = Color.White, onSecondary = Color.White, onTertiary = Color.White, onBackground = Color(0xFF1C1B1F), onSurface = Color(0xFF1C1B1F), */ ) @Composable fun AnimatedBottomBarComposeTheme( darkTheme: Boolean = isSystemInDarkTheme(), // Dynamic color is available on Android 12+ dynamicColor: Boolean = true, content: @Composable () -> Unit, ) { val colorScheme = when { dynamicColor && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> { val context = LocalContext.current if (darkTheme) dynamicDarkColorScheme(context) else dynamicLightColorScheme(context) } darkTheme -> DarkColorScheme else -> LightColorScheme } val view = LocalView.current if (!view.isInEditMode) { SideEffect { val window = (view.context as Activity).window window.statusBarColor = colorScheme.primary.toArgb() WindowCompat.getInsetsController(window, view).isAppearanceLightStatusBars = darkTheme } } MaterialTheme( colorScheme = colorScheme, typography = Typography, content = content, ) } ================================================ FILE: app/src/main/java/com/example/animatedbottombarcompose/ui/theme/Type.kt ================================================ package com.example.animatedbottombarcompose.ui.theme import androidx.compose.material3.Typography import androidx.compose.ui.text.TextStyle import androidx.compose.ui.text.font.FontFamily import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.unit.sp // Set of Material typography styles to start with val Typography = Typography( bodyLarge = TextStyle( fontFamily = FontFamily.Default, fontWeight = FontWeight.Normal, fontSize = 16.sp, lineHeight = 24.sp, letterSpacing = 0.5.sp, ), /* Other default text styles to override titleLarge = TextStyle( fontFamily = FontFamily.Default, fontWeight = FontWeight.Normal, fontSize = 22.sp, lineHeight = 28.sp, letterSpacing = 0.sp ), labelSmall = TextStyle( fontFamily = FontFamily.Default, fontWeight = FontWeight.Medium, fontSize = 11.sp, lineHeight = 16.sp, letterSpacing = 0.5.sp ) */ ) ================================================ FILE: app/src/main/res/drawable/ic_launcher_background.xml ================================================ ================================================ FILE: app/src/main/res/drawable/ic_launcher_foreground.xml ================================================ ================================================ FILE: app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml ================================================ ================================================ FILE: app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml ================================================ ================================================ FILE: app/src/main/res/values/colors.xml ================================================ #FFBB86FC #FF6200EE #FF3700B3 #FF03DAC5 #FF018786 #FF000000 #FFFFFFFF ================================================ FILE: app/src/main/res/values/strings.xml ================================================ AnimatedBottomBarCompose ================================================ FILE: app/src/main/res/values/themes.xml ================================================