iOS/Sources/Shared/Extensions/View+ConditionalModifier.swift

14 lines
287 B
Swift

import Foundation
import SwiftUI
public extension View {
@ViewBuilder
func modify(@ViewBuilder _ transform: (Self) -> (some View)?) -> some View {
if let view = transform(self), !(view is EmptyView) {
view
} else {
self
}
}
}