Skip to content

Instantly share code, notes, and snippets.

@alexvanyo
Last active January 14, 2022 20:35
Show Gist options
  • Save alexvanyo/80f8ccaf185c9734e559b4be8a5f0bd1 to your computer and use it in GitHub Desktop.
Save alexvanyo/80f8ccaf185c9734e559b4be8a5f0bd1 to your computer and use it in GitHub Desktop.
The primary structure of the HomeRoute
// Copyright 2022 Google LLC.
// SPDX-License-Identifier: Apache-2.0
@Composable
fun HomeRoute(
isExpandedScreen: Boolean,
isArticleOpen: Boolean,
selectedArticleId: String,
onSelectArticle: (String) -> Unit,
onArticleBackPress: () -> Unit,
// ...
) {
// ...
if (isExpandedScreen) {
HomeListWithArticleDetailsScreen(
selectedArticleId = selectedArticleId,
onSelectArticle = onSelectArticle,
// ...
)
} else {
// if we don't have room for both the list and article details,
// show one of them based on the user's focus
if (isArticleOpen) {
ArticleScreen(
selectedArticleId = selectedArticleId,
// ...
)
BackHandler {
onArticleBackPress()
}
} else {
HomeListScreen(
onSelectArticle = onSelectArticle,
// ...
)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment