Files
yattee/Yattee/Extensions/View+Conditional.swift
Arkadiusz Fal 4770bbe3b9 Remove dead code found by Periphery on all platforms
Delete declarations that Periphery reports unused on every platform that
compiles them (iOS, macOS, tvOS), including nine views used only by their
own previews. Platform-gated code still used on another platform, device-
only MPV render paths, migration models, CloudKit record names, App
Intents metadata and unused parameters are kept.
2026-10-08 23:57:56 +02:00

38 lines
823 B
Swift

//
// View+Conditional.swift
// Yattee
//
// Conditional view modifier extension.
//
import SwiftUI
extension View {
/// Conditionally applies a transformation to the view.
@ViewBuilder
func `if`<Transform: View>(
_ condition: Bool,
transform: (Self) -> Transform
) -> some View {
if condition {
transform(self)
} else {
self
}
}
/// Conditionally applies one of two transformations.
@ViewBuilder
func `if`<TrueContent: View, FalseContent: View>(
_ condition: Bool,
then trueTransform: (Self) -> TrueContent,
else falseTransform: (Self) -> FalseContent
) -> some View {
if condition {
trueTransform(self)
} else {
falseTransform(self)
}
}
}