import SwiftUI

public extension View {
    /// Applies a modifier to a view conditionally.
    ///
    ///     someView
    ///         .modifier(if: model == nil) {
    ///             $0.redacted(reason: .placeholder )
    ///         }
    ///
    /// - Warning: The view will re-render when the condition is changed.
    ///
    /// - Parameters:
    ///   - condition: The condition to determine if the content should be applied.
    ///   - content: The modifier to apply to the view.
    /// - Returns: The modified view.
    @ViewBuilder func modifier<T: View>(
        if condition: Bool,
        @ViewBuilder then content: (Self) -> T
    ) -> some View {
        if condition {
            content(self)
        } else {
            self
        }
    }
}
