Skip to content

Instantly share code, notes, and snippets.

@syntialai
Last active Jan 10, 2023
Embed
What would you like to do?
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))
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment