@@ -22,15 +22,21 @@ extension Element {
2222 largeContentImageInsets: UIEdgeInsets = . zero,
2323 interactionEndedCallback: ( ( CGPoint ) -> Void ) ? = nil
2424 ) -> Element {
25- Accessibility . LargeContentViewer (
26- wrapping: self ,
27- configuration: . init(
28- display: display,
29- scalesLargeContentImage: scalesLargeContentImage,
30- largeContentImageInsets: largeContentImageInsets,
31- interactionEndedCallback: interactionEndedCallback
25+ EnvironmentReader { env in
26+ assert (
27+ env. isWrappedInLargeContentViewerContainer,
28+ " accessibilityShowsLargeContentViewer() must be used in conjunction with accessibilityLargeContentViewerInteractionContainer(). "
3229 )
33- )
30+ return Accessibility . LargeContentViewer (
31+ wrapping: self ,
32+ configuration: . init(
33+ display: display,
34+ scalesLargeContentImage: scalesLargeContentImage,
35+ largeContentImageInsets: largeContentImageInsets,
36+ interactionEndedCallback: interactionEndedCallback
37+ )
38+ )
39+ }
3440 }
3541}
3642
@@ -191,7 +197,10 @@ extension Element {
191197 /// Elements that are wrapped in this container will be able to show a large content viewer and allow a user to swipe through them with one finger
192198 /// and have the HUD update in real time.
193199 public func accessibilityLargeContentViewerInteractionContainer( ) -> Element {
194- Accessibility . LargeContentViewerInteractionContainer ( wrapping: self )
200+ Accessibility . LargeContentViewerInteractionContainer ( wrapping: self ) . adaptedEnvironment (
201+ keyPath: \. isWrappedInLargeContentViewerContainer,
202+ value: true
203+ )
195204 }
196205}
197206
@@ -243,3 +252,13 @@ extension Accessibility {
243252 }
244253}
245254
255+ extension Environment {
256+ private enum LargeContentViewerContainerKey : EnvironmentKey {
257+ static let defaultValue = false
258+ }
259+
260+ var isWrappedInLargeContentViewerContainer : Bool {
261+ get { self [ LargeContentViewerContainerKey . self] }
262+ set { self [ LargeContentViewerContainerKey . self] = newValue }
263+ }
264+ }
0 commit comments