// // ViewExtensions.swift // Jel // // Created by zerocool on 12/25/23. // import SwiftUI extension View { /// Applies the given transform if the given condition evaluates to `true`. @ViewBuilder func `if`(_ condition: @autoclosure () -> Bool, transform: (Self) -> Content) -> some View { if condition() { transform(self) } else { self } } } extension View { /// Applies an inverse mask to the given view public func inverseMask(_ mask: Content) -> some View { let inverseMask = mask .foregroundStyle(.black) .background(.white) .compositingGroup() .luminanceToAlpha() return self.mask(inverseMask) } }