Last active
January 14, 2022 20:35
-
-
Save alexvanyo/80f8ccaf185c9734e559b4be8a5f0bd1 to your computer and use it in GitHub Desktop.
The primary structure of the HomeRoute
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
// 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