Skip to content

Instantly share code, notes, and snippets.

@syntialai
Last active March 22, 2024 10:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save syntialai/fa94ce5577083044544f135c6ce965b9 to your computer and use it in GitHub Desktop.
Save syntialai/fa94ce5577083044544f135c6ce965b9 to your computer and use it in GitHub Desktop.
Instagram home screen example - compose
@Composable
fun HomeScreen(modifier: Modifier = Modifier) {
val scrollState = rememberScrollState()
val context = LocalContext.current
Surface(modifier = modifier.fillMaxWidth()) {
LazyColumn(modifier = Modifier.verticalScroll(scrollState)) {
// LazyRow still able to be use, since it has different orientation with parent LazyColumn
item {
LazyRow(modifier = modifier.fillMaxWidth()) {
items(getStories()) { story ->
StoryThumbnail(story = story)
}
}
}
items(getPosts()) { post ->
PostCard(
post = post,
postCardListener = getPostCardListener(context),
modifier = Modifier.padding(vertical = 8.dp))
}
}
}
}
@stefan-stankovic
Copy link

I'm facing issue with the LazyColumn vertical scroll. My app crashes when I get to the screen where it is supposed to be rendered.
Here is the code: https://pastebin.com/ZKzZ9NFT
Do you know what can cause the problem?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment