• Stars
    star
    147
  • Rank 251,347 (Top 5 %)
  • Language
    Kotlin
  • License
    Apache License 2.0
  • Created about 2 years ago
  • Updated 4 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Allows to display a text which wraps around an image (or any other Composable).

Maven Central

Text Flow

Text Flow library for Jetpack Compose.

Allows to display a text which wraps around an image (or any other Composable).

Examples

See Demo application and examples.

Simple text around image

Text wrapping a letter to create a Drop Cap

Animating image size and changing the alignment

Annotated string support

Usage

Get a dependency

Step 1. Add the MavenCentral repository to your build file. Add it in your root build.gradle at the end of repositories:

allprojects {
    repositories {
        ...
        mavenCentral()
    }
}

Or in settings.gradle:

dependencyResolutionManagement {
    repositories {
        ...
        mavenCentral()
    }
}

Step 2. Add the dependency. Check latest version on the releases page.

dependencies {
    implementation "io.github.oleksandrbalan:textflow:$version"
}

Use in Composable

The TextFlow behaves as a regular Text, but has 2 more arguments:

  • obstacleContent - The content lambda to provide the obstacle composable which will be wrapped by the text. Could be used as trailing lambda.
  • obstacleAlignment - The alignment of the obstacleContent. Text flow supports TopStart (default) and TopEnd alignments.
TextFlow(
    text = "Text Flow allows to display a text which wraps around an image (or any other Composable)",
    modifier = Modifier.width(220.dp),
    obstacleAlignment = TextFlowObstacleAlignment.TopStart,
    obstacleContent = {
        Icon(
            imageVector = Icons.Default.Done,
            contentDescription = null,
            modifier = Modifier.padding(4.dp)
        )
    }
)