Skip to content

Commit

Permalink
Added condition.
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanvorobei committed Oct 12, 2023
1 parent e005014 commit 9941ab8
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions Sources/SwiftUIExtension/Extensions/ViewExtension.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
import SwiftUI

extension View {

@ViewBuilder func `if`<Content: View>(_ 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 {
Expand Down

0 comments on commit 9941ab8

Please sign in to comment.