Skip to content

Instantly share code, notes, and snippets.

@tera-ny
Created May 9, 2021 13:47
Show Gist options
  • Save tera-ny/f69e6538910ea2d8b2a1f0fb4624f5fb to your computer and use it in GitHub Desktop.
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
//
// 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