diff --git a/Airship/AirshipCore/Source/Media.swift b/Airship/AirshipCore/Source/Media.swift index afbe55dc1..e31ffe6c2 100644 --- a/Airship/AirshipCore/Source/Media.swift +++ b/Airship/AirshipCore/Source/Media.swift @@ -23,7 +23,7 @@ struct Media : View { .background(self.model.backgroundColor) .border(self.model.border) .common(self.model) - .accessible(self.model) + .accessible(self.model, hideIfNotSet: true) case .video, .youtube: #if !os(tvOS) && !os(watchOS) MediaWebView(url: model.url, diff --git a/Airship/AirshipCore/Source/ViewExtensions.swift b/Airship/AirshipCore/Source/ViewExtensions.swift index 358c76ac7..ceda76e30 100644 --- a/Airship/AirshipCore/Source/ViewExtensions.swift +++ b/Airship/AirshipCore/Source/ViewExtensions.swift @@ -39,11 +39,20 @@ extension View { } @ViewBuilder - func accessible(_ accessible: Accessible?) -> some View { + func accessibleHiddenCompat(hidden: Bool) -> some View { + if #available(iOS 14.0, tvOS 14.0, *) { + self.accessibilityHidden(hidden) + } else { + self.accessibility(hidden: hidden) + } + } + + @ViewBuilder + func accessible(_ accessible: Accessible?, hideIfNotSet: Bool = false) -> some View { if let label = accessible?.contentDescription { self.accessibility(label: Text(label)) } else { - self + self.accessibleHiddenCompat(hidden: hideIfNotSet) } }