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

Improve navigation icon logic for better readability and efficiency #20

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

nascriptone
Copy link

@nascriptone nascriptone commented May 21, 2024

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.

@nascriptone
Copy link
Author

nascriptone commented May 21, 2024

@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