Jetpack Compose: LottieSwipeRefreshIndicator

Simplest way to use Lottie Files as a SwipeRefreshLayout

Just a quick note, here is how to use CustomSwipeRefresh in accompanist using LottieRefreshIndicator

Use it in coordination with accompanist swipe refresh

Be sure to add this library in the build.gralde

implementation “com.google.accompanist:accompanist-swiperefresh:0.10.0”

var loading by viewModel.loading.collectAsState() //observerAsState for livedata

SwipeRefresh(
state = rememberSwipeRefreshState(isRefreshing = !loading),
onRefresh = {
//Refresh
},
indicator = { state, trigger ->
LottieRefreshIndicator(state = state, refreshTriggerDistance = trigger, animation = R.raw.monitor_progress)
},
) {
//Content
}

Here is the LottieRefreshIndicator file:

https://raw.githubusercontent.com/nabil6391/LottieSwipeRefreshLayout/master/LottieSwipeRefreshLayout/src/main/java/com/nabilmh/lottieswiperefreshlayout/LottieRefreshIndicator.kt

Visit the example here at

https://github.com/nabil6391/LottieSwipeRefreshLayout

--

--

--

Lead Android Developer, Flutter Lover

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Day36 of #100DaysOfCode

How To Create an Android App with Dark Mode

Android Messages App Codenames

Handling OnBackPressed() in Fragments

Reduce, Reuse & Recycle your thread pools ♻️

Using MySQL Database in Android Apps

Day72 of #100DaysOfCode

JvmSuppressWildcards: The secret sauce to your sandwich-style generics

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Nabil Mosharraf Hossain

Nabil Mosharraf Hossain

Lead Android Developer, Flutter Lover

More from Medium

Fundamentals of Jetpack Compose

Compose Destinations: A simpler way for compose navigation.

Routes & Arguments In Jetpack Compose Navigation

Jetpack compose custom rating bar in android 2022