This PR implements the applyIf extension function for the Modifier class in the Jetpack Compose UI toolkit. The function allows a Modifier to be conditionally applied based on a boolean condition.
The PR includes the following changes:
Addition of the applyIf extension function in ComposeExtensions.kt.
Addition of unit tests for the applyIf function in ComposeExtensionsTest.kt.
The applyIf function checks a given condition and if the condition is true, it applies a specified modifier to the current Modifier. If the condition is false, it returns the current Modifier without any changes.
The unit tests ensure that the applyIf function correctly applies a modification to a Modifier based on a boolean condition. The tests cover two scenarios: when the condition is true and when it is false.
Description:
This PR implements the
applyIf
extension function for theModifier
class in the Jetpack Compose UI toolkit. The function allows aModifier
to be conditionally applied based on a boolean condition.The PR includes the following changes:
applyIf
extension function inComposeExtensions.kt
.applyIf
function inComposeExtensionsTest.kt
.The
applyIf
function checks a given condition and if the condition is true, it applies a specified modifier to the currentModifier
. If the condition is false, it returns the currentModifier
without any changes.The unit tests ensure that the
applyIf
function correctly applies a modification to aModifier
based on a boolean condition. The tests cover two scenarios: when the condition istrue
and when it isfalse
.This PR is in response to Issue #4.
Files changed:
kotlin/com/codingboy/composely/ui/extensions/ComposeExtensions.kt
app/src/test/kotlin/com/codingboy/composely/ui/extensions/ComposeExtensionsTest.kt
How to test:
feature/modifier/applyIf/#4
.ComposeExtensionsTest.kt
.