πŸš€πŸ“±πŸ’–Animated LazyColumn/Row changes scale/color with animation and have a current selected item like a Pager. An elegant alternative for selecting from a list

Overview

Compose AnimatedList

Animated infinite and finite LazyRow and LazyColumn with scale and color animations on scroll change based on how far they are to selector items

animated_list.mp4

Gradle Setup

To get a Git project into your build:

  • Step 1. Add the JitPack repository to your build file Add it in your root build.gradle at the end of repositories:
allprojects {
  repositories {
      ...
      maven { url 'https://jitpack.io' }
  }
}
  • Step 2. Add the dependency
dependencies {
    implementation 'com.github.SmartToolFactory:Compose-AnimatedList:Tag'
}

AnimatedInfiniteLazyRow/Column

Declaration

@Composable
fun <T> AnimatedInfiniteLazyColumn(
  modifier: Modifier = Modifier,
  items: List<T>,
  initialFistVisibleIndex: Int = 0,
  visibleItemCount: Int = 5,
  inactiveItemPercent: Int = 85,
  spaceBetweenItems: Dp = 4.dp,
  selectorIndex: Int = -1,
  itemScaleRange: Int = 1,
  showPartialItem: Boolean = false,
  activeColor: Color = Color.Cyan,
  inactiveColor: Color = Color.Gray,
  key: ((index: Int) -> Any)? = null,
  contentType: (index: Int) -> Any? = { null },
  itemContent: @Composable LazyItemScope.(
    animationProgress: AnimationProgress, index: Int, item: T, height: Dp
  ) -> Unit
) {
  AnimatedInfiniteList(
    modifier = modifier,
    items = items,
    initialFirstVisibleIndex = initialFistVisibleIndex,
    visibleItemCount = visibleItemCount,
    inactiveItemPercent = inactiveItemPercent,
    spaceBetweenItems = spaceBetweenItems,
    selectorIndex = selectorIndex,
    itemScaleRange = itemScaleRange,
    showPartialItem = showPartialItem,
    activeColor = activeColor,
    inactiveColor = inactiveColor,
    orientation = Orientation.Vertical,
    key = key,
    contentType = contentType,
    itemContent = itemContent
  )
}
@Composable
fun <T> AnimatedInfiniteLazyRow(
  modifier: Modifier = Modifier,
  items: List<T>,
  initialFistVisibleIndex: Int = 0,
  activeItemWidth: Dp,
  inactiveItemWidth: Dp,
  visibleItemCount: Int = 5,
  spaceBetweenItems: Dp = 4.dp,
  selectorIndex: Int = -1,
  itemScaleRange: Int = 1,
  showPartialItem: Boolean = false,
  activeColor: Color = ActiveColor,
  inactiveColor: Color = InactiveColor,
  key: ((index: Int) -> Any)? = null,
  contentType: (index: Int) -> Any? = { null },
  itemContent: @Composable LazyItemScope.(
    animationProgress: AnimationProgress, index: Int, item: T, width: Dp
  ) -> Unit
) 

Params

  • items the data list
  • visibleItemCount count of items that are visible at any time
  • inactiveItemPercent percentage of scale that items inside itemScaleRange
  • can be scaled down to. This is a number between 0 and 100
  • spaceBetweenItems padding between 2 items
  • selectorIndex index of selector. When itemScaleRange is odd number it's center of selected item, when itemScaleRange is even number it's center of item with selector index and the one next to it
  • itemScaleRange range of area of scaling. When this value is odd any item that enters half of item size range subject to being scaled. When this value is even any item in 2 item size range is subject to being scaled
  • showPartialItem show items partially that are at the start and end
  • activeColor color of selected item
  • inactiveColor color of items are not selected
  • key a factory of stable and unique keys representing the item. Using the same key for multiple items in the list is not allowed. Type of the key should be saveable via Bundle on Android. If null is passed the position in the list will represent the key. When you specify the key the scroll position will be maintained based on the key, which means if you add/remove items before the current visible item the item with the given key will be kept as the first visible one.
  • contentType a factory of the content types for the item. The item compositions of the same type could be reused more efficiently. Note that null is a valid type and items of such type will be considered compatible.
  • itemContent the content displayed by a single item
You might also like...
Formula 1 app to show current Standings from a REST API.Built using jetpack compose and kotlin.
Formula 1 app to show current Standings from a REST API.Built using jetpack compose and kotlin.

Formula1 Formula 1 app to show Standings fetching data from REST API πŸ“Έ Screenshots Tech Stack. Kotlin - Kotlin is a programming language that can run

PexWallpapers is one of my current projects in Jetpack Compose.

Welcome to PexWallpapers! Hi! PexWallpapers is one of my current projects in Jetpack Compose. The app use Pexels.com image library to showpictures/wal

Sample project to demonstrate how to have clear and better interactions between composables and viewmodels.

Form Validation Sample project to demonstrate how to have clear and better interactions between composables and viewmodels. Concepts used uiState conc

Dynamic Badge with customizable features as max number before displaying with +, color, shadow, border, corner radius, font properties and more written with Jetpack Compose
Dynamic Badge with customizable features as max number before displaying with +, color, shadow, border, corner radius, font properties and more written with Jetpack Compose

βœοΈπŸ“Œ Dynamic Badge with customizable features as max number before displaying with +, color, shadow, border, corner radius, font properties and more written with Jetpack Compose. Displays numbers either in circle or rounded rectangle shape based on badge count and selected threshold to transform from circle to rounded rectangle.

🎨 Jetpack Compose canvas library that helps you draw paths, images on canvas with color pickers and palettes
🎨 Jetpack Compose canvas library that helps you draw paths, images on canvas with color pickers and palettes

🎨 Jetpack Compose canvas library that helps you draw paths and images on canvas with color pickers and palettes. Sketchbook also provides useful components and functions that can easily interact with canvas.

🌈 Palette - A color picker library made in Jetpack Compose
🌈 Palette - A color picker library made in Jetpack Compose

🌈 Palette A color picker library made in Jetpack Compose. Including in your project Gradle Add it in your root build.gradle at the end of repositorie

Simple example how you can use dynamic color image vector in your app.
Simple example how you can use dynamic color image vector in your app.

Dynamic Color ImageVector Simple example how you can use dynamic color image vector in your app. How to use 1. Create a xml image vector The content o

πŸ“   Note List app based on MVVM architecture (ViewModel, LiveData, Coroutines, Room and Jetpack Compose)
πŸ“ Note List app based on MVVM architecture (ViewModel, LiveData, Coroutines, Room and Jetpack Compose)

Note list app built with Jetpack Compose Download Go to the releases page to download the latest available apk. Screenshots Architecture Features Home

Jetpack Compose animations including Loading/progress, Looping, On-off, Enter, Exit, Fade, Spin and Background animation

Compose Animation Examples. Useful Jetpack Compose animations including Loading/progress, Looping, On-off, Enter, Exit, Fade, Spin and Background animations that you can take inspiration from.

Releases(0.5.1)
Owner
Smart Tool Factory
πŸš€ Building colorful and shiny things with Compose(Jetpack Compose Artist🎨)
Smart Tool Factory
Row Coloumn Box Compose Constraint Layout Modifier.xyz Animator Tween animation MutableState Creating custom composable Corners Canvas LaunchedEffect

Row Coloumn Box Compose Constraint Layout Modifier.xyz Animator Tween animation MutableState Creating custom composable Corners Canvas LaunchedEffect

Shivaraj M Patil 1 Apr 13, 2022
A Weather Mobile or Android Native App, in Kotlin built to see the current weather of suggested countries of Europe and in my current position. In this case, Maputo/Mozambique #WitChallenge #Asked #Option1

Witweather_android This is a challenge assigned by Wit, which aimed to build an Android App to visualize the temperature in my current location, in th

Kelton M. Cumbe 1 Nov 22, 2021
πŸš€πŸ“’πŸ“ Indicators for Horizontal or Vertical Pager with different orientation, color, size options and optional touch feature.

Compose Pager Indicator Indicators for Horizontal or Vertical pager with different orientation, color, size options and optional touch feature. indica

Smart Tool Factory 5 Oct 7, 2022
Flexible Chat Row and Resizable SubcomposeLayout

Flexible chat row written with Jetpack Compose that positions message and message status based on number of message lines, message width and parent width. And resizeble Sucomposelayout that remasures sibling composables to match their widths' to longest composable. This is for matching quote and message width to each other.

Smart Tool Factory 21 Jan 1, 2023
A Jetpack compose library that auto-syncs a TabRow with a LazyColumn.

SmartTabs A simple library that helps us to sync a TabRow with a LazyColumn. The motives behind creating it can be found in this post. Installation In

Vaios Tsitsonis 10 Dec 26, 2022
Partial port of https://github.com/davemorrissey/subsampling-scale-image-view library to Jetpack Compose.

ComposeSubsamplingScaleImage Early preview (expect bugs) dependencies { implementation 'com.github.K1rakishou:ComposeSubsamplingScaleImage:fab4ae38c

Dmitry 13 Dec 21, 2022
Zoom Modifiers, zoomable image and layouts with limit pan bounds, fling and moving back to valid bounds and callbacks that return current transformation or visible image section

Zoom Modifiers, zoomable image and layouts with limit pan bounds, fling and moving back to valid bounds and callbacks that return current transformation or visible image section

Smart Tool Factory 20 Dec 13, 2022
A flexible theme provider for Jetpack Compose. Supports dynamic theme changes and saving theme preference.

JetTheme JetTheme is a flexible theme provider for Jetpack Compose. Change the theme and recompose the UI dynamically. Save theme preference to local

Mao Yufeng 48 Oct 19, 2022
Movies App represent a list of movies, list of categories, search about movie and Save movie in Room Database

What is this project? Movies App represent a list of movies, list of categories, search about movie and Save movie in Room Database Main Features Kotl

Ahmed Omara 23 Dec 13, 2022
Undo snapshot state changes in Compose.

compose-undo Track changes to any snapshot state object and restore state from any point in the past. Usage implementation 'com.zachklipp.compose-undo

Zach Klippenstein 135 Jan 1, 2023