Created
September 10, 2020 22:21
-
-
Save darrarski/a534f4ea3c530cb2e1963217af188c34 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
extension View { | |
@ViewBuilder func modify<Modified: View>( | |
if condition: @autoclosure () -> Bool, | |
then transform: (Self) -> Modified | |
) -> some View { | |
if condition() { | |
transform(self) | |
} else { | |
self | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment