import SwiftUI
// โโโโโโโโโโโโโโโโโโ
// โ ShapeStyleView โ
// โโโโโโโโโโโโโโโโโโ
// wrap a shape style in a view
struct ShapeStyleView<S: ShapeStyle>: View {
let style: S
init(_ shapeStyle: S) {
self.style = shapeStyle
}
// `View` protocol requirement
var body: some View {
Rectangle().fill(style)
}
}
// โโโโโโโโโโโโโโโโโโโ
// โ Gradient + View โ
// โโโโโโโโโโโโโโโโโโโ
// now `Gradient` is a view.
extension Gradient: View {
public var body: some View {
Rectangle().fill(self)
}
}
// โโโโโโโโโโโโโโโโโโโโโโ
// โ AnyGradient + View โ
// โโโโโโโโโโโโโโโโโโโโโโ
// now `AnyGradient` is a view.
extension AnyGradient: View {
public var body: some View {
Rectangle().fill(self)
}
}