30 lines
848 B
Swift
30 lines
848 B
Swift
//
|
|
// View + Extensions.swift
|
|
// PyLeap
|
|
//
|
|
// Created by Trevor Beaton on 3/14/22.
|
|
//
|
|
import SwiftUI
|
|
import Foundation
|
|
|
|
extension View {
|
|
|
|
func navigationBarColor(_ backgroundColor: UIColor?) -> some View {
|
|
self.modifier(NavigationBarModifier(backgroundColor: backgroundColor))
|
|
}
|
|
}
|
|
|
|
extension View {
|
|
/// Applies the given transform if the given condition evaluates to `true`.
|
|
/// - Parameters:
|
|
/// - condition: The condition to evaluate.
|
|
/// - transform: The transform to apply to the source `View`.
|
|
/// - Returns: Either the original `View` or the modified `View` if the condition is `true`.
|
|
@ViewBuilder func `if`<Content: View>(_ condition: Bool, transform: (Self) -> Content) -> some View {
|
|
if condition {
|
|
transform(self)
|
|
} else {
|
|
self
|
|
}
|
|
}
|
|
}
|