@@ -184,7 +184,8 @@ fun HomeScreen(
184184 navigateToArticle = navigateToArticle,
185185 favorites = uiState.favorites,
186186 onToggleFavorite = onToggleFavorite,
187- modifier = modifier.supportWideScreen()
187+ modifier = modifier.supportWideScreen(),
188+ scrollState = scrollState
188189 )
189190 }
190191 )
@@ -268,10 +269,11 @@ private fun HomeScreenErrorAndContent(
268269 onRefresh : () -> Unit ,
269270 navigateToArticle : (String ) -> Unit ,
270271 onToggleFavorite : (String ) -> Unit ,
271- modifier : Modifier = Modifier
272+ modifier : Modifier = Modifier ,
273+ scrollState : LazyListState
272274) {
273275 if (posts.isNotEmpty()) {
274- PostList (posts, navigateToArticle, favorites, onToggleFavorite, modifier)
276+ PostList (posts, navigateToArticle, favorites, onToggleFavorite, modifier, scrollState )
275277 } else if (! isShowingErrors) {
276278 // if there are no posts, and no error, let the user refresh manually
277279 TextButton (onClick = onRefresh, modifier.fillMaxSize()) {
@@ -296,11 +298,11 @@ private fun HomeScreenErrorAndContent(
296298@Composable
297299private fun PostList (
298300 posts : List <Post >,
299- state : LazyListState = rememberLazyListState(),
300301 navigateToArticle : (postId: String ) -> Unit ,
301302 favorites : Set <String >,
302303 onToggleFavorite : (String ) -> Unit ,
303- modifier : Modifier = Modifier
304+ modifier : Modifier = Modifier ,
305+ scrollState : LazyListState = rememberLazyListState(),
304306) {
305307 val postTop = posts[3 ]
306308 val postsSimple = posts.subList(0 , 2 )
@@ -309,7 +311,7 @@ private fun PostList(
309311
310312 LazyColumn (
311313 modifier = modifier,
312- state = state ,
314+ state = scrollState ,
313315 contentPadding = rememberInsetsPaddingValues(
314316 insets = LocalWindowInsets .current.systemBars,
315317 applyTop = false
0 commit comments