LottieSwipeRefresh

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”

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
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

comments powered by Disqus