jeongmin / Composely

A collection of Compose UI widgets and functionalities to simplify and enhance your Android app development.
Apache License 2.0
4 stars 0 forks source link

[#4] Modifier extension function 'applyIf' and corresponding unit tests #5

Closed jeongmin closed 3 months ago

jeongmin commented 3 months ago

Description:

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:

  1. Addition of the applyIf extension function in ComposeExtensions.kt.
  2. 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.

This PR is in response to Issue #4.

Files changed:

  1. kotlin/com/codingboy/composely/ui/extensions/ComposeExtensions.kt
  2. app/src/test/kotlin/com/codingboy/composely/ui/extensions/ComposeExtensionsTest.kt

How to test:

  1. Check out to the branch feature/modifier/applyIf/#4.
  2. Run the unit tests in ComposeExtensionsTest.kt.