Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#352] [Sample] 1/2: Setup the nav graph and navigation logic #367

Merged

Conversation

luongvo
Copy link
Member

@luongvo luongvo commented Dec 9, 2022

#352

What happened 👀

Insight 📝

Following what we introduced in https://docs.google.com/presentation/d/1xJYi25WrYOdMxigM0LTCIVX5zLozccCFGvq_ulyeTd8/edit#slide=id.p, we will have AppDestination class. AppDestination is designed to provide the route and arguments config for each composable screen. It's also a navigation command which contains a built destination for navigating.

  • For nav graph config 🔨
composable(
    route = AppDestination.Home.route,
    arguments = AppDestination.Home.arguments
) {
    HomeScreen(
        navigator = { destination -> navController.navigate(destination) }
    )
}
  • For navigation command sending 🚀
override fun onMyCoinsItemClick(coin: CoinItemUiModel) {
    execute {
        _navigator.emit(AppDestination.CoinDetail.buildDestination(coin.id))
    }
}
  • For navigation command callback executing 💁‍♂️
private fun NavHostController.navigate(destination: AppDestination) {
    when (destination) {
        is AppDestination.Up -> popBackStack()
        else -> navigate(route = destination.destination)
    }
}

Proof Of Work 📹

The existing navigation from the Home to the Second screen should work properly as it is.

@luongvo luongvo added this to the 3.15.0 milestone Dec 9, 2022
@luongvo luongvo self-assigned this Dec 9, 2022
@github-actions
Copy link

github-actions bot commented Dec 9, 2022

6 Warnings
⚠️ Big PR
⚠️ Uh oh! BaseViewModel.kt is under 95% coverage!
⚠️ Uh oh! MainActivity.kt is under 95% coverage!
⚠️ Uh oh! MainViewModel.kt is under 95% coverage!
⚠️ Uh oh! Your project is under 80% coverage!
⚠️ Uh oh! Theme.kt is under 95% coverage!

Kover report for template-xml:

🧛 Template - XML Unit Tests Code Coverage: 29.95%

Coverage of Modified Files:

File Coverage
BaseViewModel.kt 0.00%
MainActivity.kt 0.00%
MainViewModel.kt 0.00%

Modified Files Not Found In Coverage Report:

AppBar.kt
AppDestination.kt
AppNavigation.kt
Configurations.kt
HomeComposeScreen.kt
HomeComposeViewModel.kt
Item.kt
ItemList.kt
SecondScreen.kt
Theme.kt
Versions.kt
build.gradle.kts
build.gradle.kts
detekt-config.yml
detekt-config.yml

Codebase cunningly covered by count Shroud 🧛

Kover report for template-compose:

🧛 Template - Compose Unit Tests Code Coverage: 13.05%

Coverage of Modified Files:

File Coverage
BaseViewModel.kt 0.00%
MainActivity.kt 0.00%
MainViewModel.kt 0.00%
Theme.kt 0.00%

Modified Files Not Found In Coverage Report:

AppBar.kt
AppDestination.kt
AppNavigation.kt
Configurations.kt
HomeComposeScreen.kt
HomeComposeViewModel.kt
Item.kt
ItemList.kt
SecondScreen.kt
Versions.kt
build.gradle.kts
build.gradle.kts
detekt-config.yml
detekt-config.yml

Codebase cunningly covered by count Shroud 🧛

Generated by 🚫 Danger

@luongvo luongvo force-pushed the feature/352-set-up-nav-graph-and-navigation-logic branch 3 times, most recently from 6ad224d to ea451e9 Compare December 12, 2022 10:22
@luongvo luongvo changed the title [#352] Setup the nav graph and navigation logic [#352] [Sample] 1/3: Setup the nav graph and navigation logic Dec 12, 2022
@luongvo luongvo marked this pull request as ready for review December 12, 2022 10:47
@luongvo luongvo linked an issue Dec 12, 2022 that may be closed by this pull request
@luongvo luongvo changed the title [#352] [Sample] 1/3: Setup the nav graph and navigation logic [#352] [Sample] 1/2: Setup the nav graph and navigation logic Dec 13, 2022
@luongvo luongvo force-pushed the feature/352-set-up-nav-graph-and-navigation-logic branch from ea451e9 to a6143ba Compare December 13, 2022 03:53
@luongvo luongvo requested a review from Wadeewee December 13, 2022 09:21
Copy link
Contributor

@thiennguyen0196 thiennguyen0196 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, strong implementation with the nav graph set up for Jetpack Compose @luongvo 👏

Copy link
Contributor

@Wadeewee Wadeewee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM Now🚀

Base automatically changed from chore/303-update-detekt-rules-for-jetpack-compose to develop December 20, 2022 05:18
@luongvo luongvo force-pushed the feature/352-set-up-nav-graph-and-navigation-logic branch from d709212 to 519a711 Compare December 20, 2022 07:29
@luongvo luongvo requested a review from lydiasama December 22, 2022 02:44
Copy link
Contributor

@toby-thanathip toby-thanathip left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@luongvo Cool! 🥇

@lydiasama lydiasama self-requested a review December 23, 2022 05:09
@lydiasama
Copy link
Contributor

@luongvo Would you mind updating the collectAsState to collectAsStateWithLifecycle in this PR? 😁

@luongvo
Copy link
Member Author

luongvo commented Dec 26, 2022

@luongvo Would you mind updating the collectAsState to collectAsStateWithLifecycle in this PR? 😁

@lydiasama I think it's out of this PR's scope and needs to verify & vote on. Can we go through an RFC and contribute to improve it later cc @Tuubz?

Copy link
Contributor

@lydiasama lydiasama left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Except for the detekt rule updating.

@toby-thanathip toby-thanathip merged commit 8f22340 into develop Dec 28, 2022
@toby-thanathip toby-thanathip deleted the feature/352-set-up-nav-graph-and-navigation-logic branch December 28, 2022 03:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Compose] Setup the nav graph and navigation logic
5 participants