Skip to content

Improve navigation icon logic for better readability and efficiency#20

Open
nxzef wants to merge 3 commits into
google-developer-training:mainfrom
nxzef:improve-navigation-icon
Open

Improve navigation icon logic for better readability and efficiency#20
nxzef wants to merge 3 commits into
google-developer-training:mainfrom
nxzef:improve-navigation-icon

Conversation

@nxzef

@nxzef nxzef commented May 21, 2024

Copy link
Copy Markdown

This pull request refactors the navigationIcon logic to improve code readability and efficiency.

Changes Made

  • Simplified the conditional logic for setting the navigationIcon.
  • Combined nested blocks to reduce redundancy.

Before

navigationIcon = if (isShowingDetailPage) {
    {
        IconButton(onClick = onBackButtonClick) {
            Icon(
                imageVector = Icons.Filled.ArrowBack,
                contentDescription = stringResource(R.string.back_button)
            )
        }
    }
} else {
    { Box {} }
}

After

navigationIcon = {
    if (isShowingDetailPage) {
        IconButton(onClick = onBackButtonClick) {
            Icon(
                imageVector = Icons.Filled.ArrowBack,
                contentDescription = stringResource(R.string.back_button)
            )
        }
    }
}

Benefits

  • Readability: The new code is easier to read and understand.
  • Efficiency: Reduces unnecessary nested blocks and simplifies the conditional check.

I have tested the changes to ensure the navigation icon behaves as expected. Please let me know if there are any further adjustments needed.

@nxzef

nxzef commented May 21, 2024

Copy link
Copy Markdown
Author

@android-dev-lxl, @OwenScott-GDS, @osuleymanova Could you please review the changes and provide any feedback or suggestions? Your input would be greatly appreciated.

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant