Tusker/Tusker/Extensions/View+ConditionalModifier.swift

23 lines
416 B
Swift
Raw Normal View History

2020-08-31 23:28:50 +00:00
//
// View+ConditionalModifier.swift
// Tusker
//
// Created by Shadowfacts on 8/31/20.
// Copyright © 2020 Shadowfacts. All rights reserved.
//
import SwiftUI
extension View {
@ViewBuilder
func conditionally<Modified: View>(_ condition: Bool, modifier: (Self) -> Modified) -> some View {
if condition {
modifier(self)
} else {
self
}
}
}