Skip to content

Instantly share code, notes, and snippets.

@syntialai
Last active January 10, 2023 02:52
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
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