-
-
Save KatieBarnett/40f0ec95bc8116c760c79d2beb3f28bd to your computer and use it in GitHub Desktop.
Conditional Modifier
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun Modifier.conditional( | |
condition: Boolean, | |
ifTrue: Modifier.() -> Modifier, | |
ifFalse: (Modifier.() -> Modifier)? = null, | |
): Modifier { | |
return if (condition) { | |
then(ifTrue(Modifier)) | |
} else if (ifFalse != null) { | |
then(ifFalse(Modifier)) | |
} else { | |
this | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment