Cobadge

🗻 Unopinionated, easy-to-use, and customizable Badge component for Jetpack Compose

Getting started

In this section I will walk you through the steps to add Cobadge to your Android app.

Add the JitPack repository to your build file

Add this line at the end of repositories:

maven { url 'https://jitpack.io' }

If your project is set to fail on project repositories, then add that line to settings.gradle file in repositories field, so that it looks approximately like this

dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        google()
        mavenCentral()
        maven { url 'https://jitpack.io' }
    }
}
rootProject.name = "Your application"

Add the dependency and replace Tag with the latest version.

Latest version is indicated below:

Groovy

implementation 'com.github.michaelgrigoryan25:cobadge:Tag'

Kotlin DSL

implementation("com.github.michaelgrigoryan25:cobadge:Tag")

Usage

Using Cobadge is really easy! Here's an example:

Badge(
    color = Color200,
    text = "Hello World"
)

Here are all the options that Cobadge takes. Fortunately, most of them are optional.

// Badge text
text: String,
// Badge background color
color: Color,
// Badge size (calculated automatically)
size: Size = Size.MD,
// Outer badge padding
paddingSelf: Dp = 4.dp,
// Supports clicking
isClickable: Boolean = true,
// Badge rounding (calculated automatically)
rounded: Rounding = Rounding.XL,
// Badge background color transparency
backgroundColorOpacity: Float = 1f,
// Badge text color
textColor: Color = Color.Unspecified,
// Action that is going to get triggered on click
onClickAction: () -> Unit = {},
// Badge text font weight
fontWeight: FontWeight = FontWeight.Bold

Contributions

Contributions to Cobadge are welcome! Saw a bug? Create a pull request! Have a suggestion? Create an issue or start a discussion!

Author: Michael Grigoryan

https://github.com/michaelgrigoryan25/cobadge