Skip to content

A fully functional Android app built entirely with Kotlin and Jetpack Compose

Use animateItemPlacement() on feed

dahunsi77451779cd96
diff --git a/core/ui/src/main/kotlin/com/google/samples/apps/nowinandroid/core/ui/NewsFeed.kt b/core/ui/src/main/kotlin/com/google/samples/apps/nowinandroid/core/ui/NewsFeed.kt
index 85f9951b8..e2904afc3 100644
--- a/core/ui/src/main/kotlin/com/google/samples/apps/nowinandroid/core/ui/NewsFeed.kt
+++ b/core/ui/src/main/kotlin/com/google/samples/apps/nowinandroid/core/ui/NewsFeed.kt
@@ -21,6 +21,7 @@ import android.net.Uri
import androidx.annotation.ColorInt
import androidx.browser.customtabs.CustomTabColorSchemeParams
import androidx.browser.customtabs.CustomTabsIntent
+import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.LazyListScope
import androidx.compose.foundation.lazy.staggeredgrid.LazyStaggeredGridScope
@@ -47,6 +48,7 @@ import com.google.samples.apps.nowinandroid.core.model.data.UserNewsResource
* An extension on [LazyListScope] defining a feed with news resources.
* Depending on the [feedState], this might emit no items.
*/
+@OptIn(ExperimentalFoundationApi::class)
fun LazyStaggeredGridScope.newsFeed(
feedState: NewsFeedUiState,
onNewsResourcesCheckedChanged: (String, Boolean) -> Unit,
@@ -88,7 +90,9 @@ fun LazyStaggeredGridScope.newsFeed(
)
},
onTopicClick = onTopicClick,
- modifier = Modifier.padding(horizontal = 8.dp),
+ modifier = Modifier
+ .padding(horizontal = 8.dp)
+ .animateItemPlacement(),
)
}
}