Skip to content

Commit 11998ee

Browse files
committed
Rename viewEnvironment to environment
1 parent 3391f7a commit 11998ee

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

ViewEnvironmentUI/Sources/ViewEnvironmentPropagating.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public protocol ViewEnvironmentPropagating {
8181
/// `layoutSubviews()` respectively.
8282
///
8383
@_spi(ViewEnvironmentWiring)
84-
var viewEnvironment: ViewEnvironment { get }
84+
var environment: ViewEnvironment { get }
8585
}
8686

8787
extension ViewEnvironmentPropagating {
@@ -110,20 +110,20 @@ extension ViewEnvironmentPropagating {
110110
/// ``ViewEnvironmentObserving/applyEnvironmentIfNeeded()-8gr5k`` in `viewWillLayoutSubviews()` and
111111
/// `layoutSubviews()` respectively.
112112
///
113-
public var viewEnvironment: ViewEnvironment {
113+
public var environment: ViewEnvironment {
114114
_defaultViewEnvironment
115115
}
116116

117-
/// The default `ViewEnvironment` returned by ``viewEnvironment-1p2gj``.
117+
/// The default `ViewEnvironment` returned by ``environment``.
118118
///
119119
/// The environment is constructed by recursively walking to the root of the propagation path
120120
/// and then applying all customizations on the way back down.
121121
///
122-
/// You should only need to access this value if you are overriding ``viewEnvironment-1p2gj``
122+
/// You should only need to access this value if you are overriding ``environment``
123123
/// and want to conditionally return the default.
124124
@_spi(ViewEnvironmentWiring)
125125
public var _defaultViewEnvironment: ViewEnvironment {
126-
var environment = environmentAncestor?.viewEnvironment
126+
var environment = environmentAncestor?.environment
127127
?? .empty
128128

129129
(self as? ViewEnvironmentCustomizing)?.customize(environment: &environment)

ViewEnvironmentUI/Sources/ViewEnvironmentPropagatingObject.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ extension ViewEnvironmentObserving where Self: ViewEnvironmentPropagatingObject
5151

5252
needsEnvironmentUpdate = false
5353

54-
apply(environment: viewEnvironment)
54+
apply(environment: environment)
5555
}
5656
}
5757

@@ -215,7 +215,7 @@ extension ViewEnvironmentPropagatingObject {
215215
needsEnvironmentUpdate = true
216216

217217
if !needsUpdateObservers.isEmpty {
218-
let environment = viewEnvironment
218+
let environment = self.environment
219219

220220
for observer in needsUpdateObservers.values {
221221
observer(environment)

ViewEnvironmentUI/Tests/ViewEnvironmentObservingTests.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ final class ViewEnvironmentObservingTests: XCTestCase {
1515
container.addChild(child)
1616
child.didMove(toParent: container)
1717

18-
XCTAssertEqual(child.viewEnvironment.testContext.number, 1)
18+
XCTAssertEqual(child.environment.testContext.number, 1)
1919
}
2020

2121
func test_environment_propagation_to_presented() {
@@ -30,7 +30,7 @@ final class ViewEnvironmentObservingTests: XCTestCase {
3030

3131
container.present(child, animated: false, completion: {})
3232

33-
XCTAssertEqual(child.viewEnvironment.testContext.number, 1)
33+
XCTAssertEqual(child.environment.testContext.number, 1)
3434
}
3535

3636
func test_environment_multiple_overrides_with_root() {
@@ -67,7 +67,7 @@ final class ViewEnvironmentObservingTests: XCTestCase {
6767
// Mutation by child
6868
expectedContext.number = 2
6969

70-
XCTAssertEqual(child.viewEnvironment.testContext, expectedContext)
70+
XCTAssertEqual(child.environment.testContext, expectedContext)
7171
}
7272

7373
// MARK: - apply(environment:)
@@ -176,7 +176,7 @@ final class ViewEnvironmentObservingTests: XCTestCase {
176176
let viewController = UIViewController()
177177
viewController.environmentAncestorOverride = { ancestor }
178178

179-
XCTAssertEqual(viewController.viewEnvironment.testContext, expectedTestContext)
179+
XCTAssertEqual(viewController.environment.testContext, expectedTestContext)
180180
}
181181

182182
func test_descendant_customFlow() {
@@ -229,7 +229,7 @@ final class ViewEnvironmentObservingTests: XCTestCase {
229229
XCTAssertTrue(child.needsEnvironmentUpdate)
230230
XCTAssertTrue(descendant.needsEnvironmentUpdate)
231231

232-
XCTAssertEqual(descendant.viewEnvironment.testContext, expectedContext)
232+
XCTAssertEqual(descendant.environment.testContext, expectedContext)
233233
}
234234

235235
// MARK: - Observations

0 commit comments

Comments
 (0)