mirror of
https://github.com/yattee/yattee.git
synced 2026-10-23 13:12:53 +00:00
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.
38 lines
823 B
Swift
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)
|
|
}
|
|
}
|
|
}
|