Skip to content

Commit 52522f1

Browse files
author
Max Moiseev
committed
[overlay] Implement UIFocusEnvironment.contains using a shim
Addresses: <rdar://problem/32538412>
1 parent 351ffab commit 52522f1

File tree

4 files changed

+47
-2
lines changed

4 files changed

+47
-2
lines changed

stdlib/public/SDK/UIKit/UIKit.swift

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313
import Foundation
1414
@_exported import UIKit
1515

16+
#if os(iOS) || os(tvOS)
17+
import _SwiftUIKitOverlayShims
18+
#endif
19+
1620
//===----------------------------------------------------------------------===//
1721
// UIGeometry
1822
//===----------------------------------------------------------------------===//
@@ -277,13 +281,15 @@ extension UIContentSizeCategory {
277281
#if os(iOS) || os(tvOS)
278282
@available(iOS 11.0, tvOS 11.0, *)
279283
extension UIFocusEnvironment {
284+
@available(iOS 11.0, tvOS 11.0, *)
280285
public func contains(_ environment: UIFocusEnvironment) -> Bool {
281-
return UIFocusSystem.environment(self, contains: environment)
286+
return _swift_UIKit_UIFocusEnvironmentContainsEnvironment(self, environment)
282287
}
283288
}
284289

285290
@available(iOS 11.0, tvOS 11.0, *)
286291
extension UIFocusItem {
292+
@available(iOS 11.0, tvOS 11.0, *)
287293
public var isFocused: Bool {
288294
return self === UIScreen.main.focusedItem
289295
}

stdlib/public/SwiftShims/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,10 @@ set(sources
1616
Visibility.h
1717

1818
DispatchOverlayShims.h
19-
ObjectiveCOverlayShims.h
2019
OSOverlayShims.h
20+
ObjectiveCOverlayShims.h
2121
SafariServicesOverlayShims.h
22+
UIKitOverlayShims.h
2223
XCTestOverlayShims.h
2324
XPCOverlayShims.h
2425

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
//===--- UIKitOverlayShims.h ---===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See https://swift.org/LICENSE.txt for license information
9+
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
//===--------------------===//
12+
13+
#ifndef SWIFT_STDLIB_SHIMS_UIKIT_OVERLAY_H
14+
#define SWIFT_STDLIB_SHIMS_UIKIT_OVERLAY_H
15+
16+
@import UIKit;
17+
18+
#if __has_feature(nullability)
19+
#pragma clang assume_nonnull begin
20+
#endif
21+
22+
#if TARGET_OS_TV || TARGET_OS_IOS
23+
static inline BOOL _swift_UIKit_UIFocusEnvironmentContainsEnvironment(id<UIFocusEnvironment> environment, id<UIFocusEnvironment> otherEnvironment) {
24+
return [UIFocusSystem environment:environment containsEnvironment:otherEnvironment];
25+
}
26+
#endif // TARGET_OS_TV || TARGET_OS_IOS
27+
28+
#if __has_feature(nullability)
29+
#pragma clang assume_nonnull end
30+
#endif
31+
32+
33+
#endif // SWIFT_STDLIB_SHIMS_UIKIT_OVERLAY_H
34+

stdlib/public/SwiftShims/module.modulemap

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ module _SwiftSafariServicesOverlayShims {
4040
header "SafariServicesOverlayShims.h"
4141
}
4242

43+
module _SwiftUIKitOverlayShims {
44+
header "UIKitOverlayShims.h"
45+
}
46+
4347
module _SwiftXCTestOverlayShims {
4448
header "XCTestOverlayShims.h"
4549
}

0 commit comments

Comments
 (0)