Created
May 9, 2021 13:47
-
-
Save tera-ny/f69e6538910ea2d8b2a1f0fb4624f5fb to your computer and use it in GitHub Desktop.
Controlling which methods are enabled by starting with the bool flag in SwiftUI Component
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
// | |
// Ex+View.swift | |
// OrangeJuice | |
// | |
// Created by tera_ny on 2021/05/09. | |
// | |
import SwiftUI | |
extension View { | |
@ViewBuilder func apply<Content: View>(_ active: Bool, _ content: (Self) -> Content) -> some View { | |
if (active) { | |
content(self) | |
} else { | |
self | |
} | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment