Last active
March 22, 2024 10:56
-
-
Save syntialai/fa94ce5577083044544f135c6ce965b9 to your computer and use it in GitHub Desktop.
Instagram home screen example - compose
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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)) | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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?