Snowfall

Snowfall animation for Android compose

snowfall-base.webm

Setup

Please, add to repositories jitpack:

repositories {
  mavenCentral()
  ...
  maven { url 'https://jitpack.io' }
}

Add to your module next dependency:

dependencies {
  implementation 'com.github.idapgroup:Snowfall:0.7.1'
}

Note: Do not forget to add compose dependencies ?

Usage sample

Library has 2 base functions to use as an extension function for Modifier.

Snowfall

It is pretty simple to use. Just add .snowfall() to any modifier where you want to see the animation

        Box(
            modifier = Modifier
                .padding(16.dp)
                .fillMaxSize()
                .snowfall()
        )

It also allows you to put any painter list to make your own anyflakes animation.

        val data = listOf(
            rememberVectorPainter(image = Icons.Rounded.Add),
            rememberVectorPainter(image = Icons.Rounded.AccountBox),
            rememberVectorPainter(image = Icons.Rounded.Abc),
            rememberVectorPainter(image = Icons.Rounded.Alarm),
        )
        Box(
            modifier = Modifier
                .padding(16.dp)
                .fillMaxWidth()
                .height(400.dp)
                .background(Color.Black, shape = RoundedCornerShape(8.dp))
                .snowfall(FlakeType.Custom(data))
        )

icon-falling.webm

Snowmelt

Melting has the same usage as a falling.

        Box(
            modifier = Modifier
                .padding(16.dp)
                .fillMaxWidth()
                .height(400.dp)
                .background(Color.DarkGray, shape = RoundedCornerShape(16.dp))
                .snowmelt()
        )

snowmelting.webm

And also allows you to customize flakes:

        Box(
            modifier = Modifier
                .padding(16.dp)
                .fillMaxWidth()
                .height(400.dp)
                .background(Color.Gray, shape = RoundedCornerShape(8.dp))
                .snowmelt(FlakeType.Custom(data))
        )

melting-custom.webm

Combining

You can also combine as many options as you want:

        Box(
            modifier = Modifier
                .padding(16.dp)
                .fillMaxWidth()
                .height(350.dp)
                .background(Color.DarkGray, shape = RoundedCornerShape(8.dp))
                .snowfall()
                .snowmelt()
        )

combining.webm

GitHub

View Github