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

[Feature] Add Modifier.applyIf Functionality #4

Closed jeongmin closed 2 months ago

jeongmin commented 2 months ago

Description:

We need to add a new extension function Modifier.applyIf that conditionally applies a modifier based on a boolean condition. This will help streamline the code where conditional modifiers are needed.

Goals:

1.  Implement the applyIf extension function for the Modifier class.
2.  Ensure the function conditionally applies the given modifier when the condition is true.
3.  Add unit tests to verify the functionality.

Steps:

1.  Define the applyIf Function:
•   Create an extension function Modifier.applyIf(condition: Boolean, modifierWhenTrue: Modifier.() -> Modifier).
2.  Implement Conditional Logic:
•   Apply the given modifier only if the condition is true.
•   Return the original modifier if the condition is false.
3.  Add Unit Tests:
•   Write tests to ensure the modifier is correctly applied when the condition is true.
•   Verify that the original modifier remains unchanged when the condition is false.
4.  Update Documentation:
•   Provide usage examples and update the relevant documentation to include this new function.

Acceptance Criteria:

•   applyIf function is implemented and added to the Modifier class.
•   Unit tests are written and all tests pass successfully.
•   Documentation is updated with usage examples.

Additional Information:

This feature will simplify the use of conditional modifiers in Compose, making the code cleaner and more readable.