Skip to content

Commit 6e7528a

Browse files
committed
Re-adds scrollState after merge
1 parent a051cbe commit 6e7528a

File tree

1 file changed

+8
-6
lines changed
  • JetNews/app/src/main/java/com/example/jetnews/ui/home

1 file changed

+8
-6
lines changed

JetNews/app/src/main/java/com/example/jetnews/ui/home/HomeScreen.kt

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -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
297299
private 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

Comments
 (0)