Skip to content

[overlay] Implement UIFocusEnvironment.contains using a shim #10430

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 21, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion stdlib/public/SDK/UIKit/UIKit.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
import Foundation
@_exported import UIKit

#if os(iOS) || os(tvOS)
import _SwiftUIKitOverlayShims
#endif

//===----------------------------------------------------------------------===//
// UIGeometry
//===----------------------------------------------------------------------===//
Expand Down Expand Up @@ -277,13 +281,15 @@ extension UIContentSizeCategory {
#if os(iOS) || os(tvOS)
@available(iOS 11.0, tvOS 11.0, *)
extension UIFocusEnvironment {
@available(iOS 11.0, tvOS 11.0, *)
public func contains(_ environment: UIFocusEnvironment) -> Bool {
return UIFocusSystem.environment(self, contains: environment)
return _swift_UIKit_UIFocusEnvironmentContainsEnvironment(self, environment)
}
}

@available(iOS 11.0, tvOS 11.0, *)
extension UIFocusItem {
@available(iOS 11.0, tvOS 11.0, *)
public var isFocused: Bool {
return self === UIScreen.main.focusedItem
}
Expand Down
3 changes: 2 additions & 1 deletion stdlib/public/SwiftShims/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ set(sources
Visibility.h

DispatchOverlayShims.h
ObjectiveCOverlayShims.h
OSOverlayShims.h
ObjectiveCOverlayShims.h
SafariServicesOverlayShims.h
UIKitOverlayShims.h
XCTestOverlayShims.h
XPCOverlayShims.h

Expand Down
34 changes: 34 additions & 0 deletions stdlib/public/SwiftShims/UIKitOverlayShims.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
//===--- UIKitOverlayShims.h ---===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===--------------------===//

#ifndef SWIFT_STDLIB_SHIMS_UIKIT_OVERLAY_H
#define SWIFT_STDLIB_SHIMS_UIKIT_OVERLAY_H

@import UIKit;

#if __has_feature(nullability)
#pragma clang assume_nonnull begin
#endif

#if TARGET_OS_TV || TARGET_OS_IOS
static inline BOOL _swift_UIKit_UIFocusEnvironmentContainsEnvironment(id<UIFocusEnvironment> environment, id<UIFocusEnvironment> otherEnvironment) {
return [UIFocusSystem environment:environment containsEnvironment:otherEnvironment];
}
#endif // TARGET_OS_TV || TARGET_OS_IOS

#if __has_feature(nullability)
#pragma clang assume_nonnull end
#endif


#endif // SWIFT_STDLIB_SHIMS_UIKIT_OVERLAY_H

4 changes: 4 additions & 0 deletions stdlib/public/SwiftShims/module.modulemap
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ module _SwiftSafariServicesOverlayShims {
header "SafariServicesOverlayShims.h"
}

module _SwiftUIKitOverlayShims {
header "UIKitOverlayShims.h"
}

module _SwiftXCTestOverlayShims {
header "XCTestOverlayShims.h"
}
Expand Down