From 9941ab8c6238d96f832a20e4c6610b0c37d656ca Mon Sep 17 00:00:00 2001 From: Ivan Vorobei Date: Fri, 13 Oct 2023 01:42:10 +0300 Subject: [PATCH] Added condition. --- .../SwiftUIExtension/Extensions/ViewExtension.swift | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Sources/SwiftUIExtension/Extensions/ViewExtension.swift b/Sources/SwiftUIExtension/Extensions/ViewExtension.swift index 6945505..57a429b 100644 --- a/Sources/SwiftUIExtension/Extensions/ViewExtension.swift +++ b/Sources/SwiftUIExtension/Extensions/ViewExtension.swift @@ -1,5 +1,16 @@ import SwiftUI +extension View { + + @ViewBuilder func `if`(_ condition: Bool, transform: (Self) -> Content) -> some View { + if condition { + transform(self) + } else { + self + } + } +} + extension View { public func onReceive(notification name: Notification.Name, perform action: @escaping (NotificationCenter.Publisher.Output) -> Void) -> some View {