mirror of
https://github.com/EmergeTools/Pow.git
synced 2026-03-25 08:55:50 +00:00
Co-authored-by: Robert Böhnke <robb@robb.is> Co-authored-by: Kasper Lahti <kasper@lahti.email>
27 lines
663 B
Swift
27 lines
663 B
Swift
import SwiftUI
|
|
|
|
protocol Simulative {
|
|
var impulseCount: Int { get set }
|
|
|
|
var initialVelocity: CGFloat { get set }
|
|
}
|
|
|
|
internal struct AnySimulativeViewModifier: ViewModifier {
|
|
private var _body: (AnyView) -> AnyView
|
|
|
|
init<Modifier: ViewModifier & Simulative>(_ modifier: Modifier) {
|
|
self._body = { content in
|
|
AnyView(content.modifier(modifier))
|
|
}
|
|
}
|
|
|
|
func body(content: Content) -> AnyView {
|
|
_body(AnyView(content))
|
|
}
|
|
}
|
|
|
|
internal extension ViewModifier where Self: Simulative {
|
|
func eraseToAnySimulativeViewModifier() -> AnySimulativeViewModifier {
|
|
AnySimulativeViewModifier(self)
|
|
}
|
|
}
|