Add spi to _EnvironmentReader
This commit is contained in:
parent
8d41fcf7a6
commit
ca8f757fe8
|
@ -19,6 +19,7 @@
|
|||
/// 1. `View.makeMountedView`
|
||||
/// 2. `MountedHostView.update` when reconciling
|
||||
///
|
||||
@_spi(TokamakCore)
|
||||
public protocol _EnvironmentReader {
|
||||
mutating func _setContent(from values: EnvironmentValues)
|
||||
}
|
||||
|
@ -52,4 +53,5 @@ public struct Environment<Value>: DynamicProperty {
|
|||
}
|
||||
}
|
||||
|
||||
@_spi(TokamakCore)
|
||||
extension Environment: _EnvironmentReader {}
|
||||
|
|
|
@ -65,7 +65,10 @@ public struct EnvironmentObject<ObjectType>: DynamicProperty
|
|||
public init() {}
|
||||
}
|
||||
|
||||
extension EnvironmentObject: ObservedProperty, _EnvironmentReader {}
|
||||
extension EnvironmentObject: ObservedProperty {}
|
||||
|
||||
@_spi(TokamakCore)
|
||||
extension EnvironmentObject: _EnvironmentReader {}
|
||||
|
||||
extension ObservableObject {
|
||||
static var environmentStore: WritableKeyPath<EnvironmentValues, Self?> {
|
||||
|
|
|
@ -37,6 +37,7 @@ extension ModifiedContent: ModifierContainer {
|
|||
var environmentModifier: _EnvironmentModifier? { modifier as? _EnvironmentModifier }
|
||||
}
|
||||
|
||||
@_spi(TokamakCore)
|
||||
extension ModifiedContent: _EnvironmentReader where Modifier: _EnvironmentReader {
|
||||
public mutating func _setContent(from values: EnvironmentValues) {
|
||||
modifier._setContent(from: values)
|
||||
|
|
|
@ -38,7 +38,7 @@ public struct _BackgroundLayout<Content, Background>: _PrimitiveView
|
|||
}
|
||||
}
|
||||
|
||||
public struct _BackgroundModifier<Background>: ViewModifier, _EnvironmentReader
|
||||
public struct _BackgroundModifier<Background>: ViewModifier
|
||||
where Background: View
|
||||
{
|
||||
public var environment: EnvironmentValues!
|
||||
|
@ -63,6 +63,9 @@ public struct _BackgroundModifier<Background>: ViewModifier, _EnvironmentReader
|
|||
}
|
||||
}
|
||||
|
||||
@_spi(TokamakCore)
|
||||
extension _BackgroundModifier: _EnvironmentReader {}
|
||||
|
||||
extension _BackgroundModifier: Equatable where Background: Equatable {
|
||||
public static func == (
|
||||
lhs: _BackgroundModifier<Background>,
|
||||
|
@ -90,7 +93,7 @@ public extension View {
|
|||
}
|
||||
|
||||
@frozen
|
||||
public struct _BackgroundShapeModifier<Style, Bounds>: ViewModifier, _EnvironmentReader
|
||||
public struct _BackgroundShapeModifier<Style, Bounds>: ViewModifier
|
||||
where Style: ShapeStyle, Bounds: Shape
|
||||
{
|
||||
public var environment: EnvironmentValues!
|
||||
|
@ -116,6 +119,9 @@ public struct _BackgroundShapeModifier<Style, Bounds>: ViewModifier, _Environmen
|
|||
}
|
||||
}
|
||||
|
||||
@_spi(TokamakCore)
|
||||
extension _BackgroundShapeModifier: _EnvironmentReader {}
|
||||
|
||||
public extension View {
|
||||
@inlinable
|
||||
func background<S, T>(
|
||||
|
@ -149,7 +155,7 @@ public struct _OverlayLayout<Content, Overlay>: _PrimitiveView
|
|||
}
|
||||
}
|
||||
|
||||
public struct _OverlayModifier<Overlay>: ViewModifier, _EnvironmentReader
|
||||
public struct _OverlayModifier<Overlay>: ViewModifier
|
||||
where Overlay: View
|
||||
{
|
||||
public var environment: EnvironmentValues!
|
||||
|
@ -174,6 +180,9 @@ public struct _OverlayModifier<Overlay>: ViewModifier, _EnvironmentReader
|
|||
}
|
||||
}
|
||||
|
||||
@_spi(TokamakCore)
|
||||
extension _OverlayModifier: _EnvironmentReader {}
|
||||
|
||||
extension _OverlayModifier: Equatable where Overlay: Equatable {
|
||||
public static func == (lhs: _OverlayModifier<Overlay>, rhs: _OverlayModifier<Overlay>) -> Bool {
|
||||
lhs.overlay == rhs.overlay
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
import Foundation
|
||||
|
||||
public struct ContainerRelativeShape: Shape, _EnvironmentReader {
|
||||
public struct ContainerRelativeShape: Shape {
|
||||
var containerShape: (CGRect, GeometryProxy) -> Path? = { _, _ in nil }
|
||||
|
||||
public func path(in rect: CGRect) -> Path {
|
||||
|
@ -31,6 +31,9 @@ public struct ContainerRelativeShape: Shape, _EnvironmentReader {
|
|||
}
|
||||
}
|
||||
|
||||
@_spi(TokamakCore)
|
||||
extension ContainerRelativeShape: _EnvironmentReader {}
|
||||
|
||||
extension ContainerRelativeShape: InsettableShape {
|
||||
@inlinable
|
||||
public func inset(by amount: CGFloat) -> some InsettableShape {
|
||||
|
|
|
@ -57,8 +57,7 @@ public extension View {
|
|||
}
|
||||
|
||||
@frozen
|
||||
public struct _BackgroundStyleModifier<Style>: ViewModifier, _EnvironmentModifier,
|
||||
_EnvironmentReader
|
||||
public struct _BackgroundStyleModifier<Style>: ViewModifier, _EnvironmentModifier
|
||||
where Style: ShapeStyle
|
||||
{
|
||||
public var environment: EnvironmentValues!
|
||||
|
@ -86,3 +85,6 @@ public struct _BackgroundStyleModifier<Style>: ViewModifier, _EnvironmentModifie
|
|||
public extension ShapeStyle where Self == BackgroundStyle {
|
||||
static var background: Self { .init() }
|
||||
}
|
||||
|
||||
@_spi(TokamakCore)
|
||||
extension _BackgroundStyleModifier: _EnvironmentReader {}
|
||||
|
|
|
@ -31,15 +31,12 @@ import Foundation
|
|||
/// .bold()
|
||||
/// .italic()
|
||||
/// .underline(true, color: .red)
|
||||
public struct Text: _PrimitiveView, Equatable, _EnvironmentReader {
|
||||
public struct Text: _PrimitiveView, Equatable {
|
||||
let storage: _Storage
|
||||
let modifiers: [_Modifier]
|
||||
|
||||
public var environment: EnvironmentValues = .init()
|
||||
|
||||
public mutating func _setContent(from values: EnvironmentValues) {
|
||||
environment = values
|
||||
}
|
||||
@Environment(\.self)
|
||||
public var environment: EnvironmentValues
|
||||
|
||||
public static func == (lhs: Text, rhs: Text) -> Bool {
|
||||
lhs.storage == rhs.storage
|
||||
|
|
Loading…
Reference in New Issue