Skip to content

Commit 9941ab8

Browse files
committed
Added condition.
1 parent e005014 commit 9941ab8

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

Sources/SwiftUIExtension/Extensions/ViewExtension.swift

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
import SwiftUI
22

3+
extension View {
4+
5+
@ViewBuilder func `if`<Content: View>(_ condition: Bool, transform: (Self) -> Content) -> some View {
6+
if condition {
7+
transform(self)
8+
} else {
9+
self
10+
}
11+
}
12+
}
13+
314
extension View {
415

516
public func onReceive(notification name: Notification.Name, perform action: @escaping (NotificationCenter.Publisher.Output) -> Void) -> some View {

0 commit comments

Comments
 (0)