added check for iOS 11 on ignore inverted colors

Summary:
Added Check for iOS 11 before setting property for `accessibilityIgnoreInvertColor`

Builds on top of
https://our.intern.facebook.com/intern/diff/D8549084/

Reviewed By: shergin

Differential Revision: D8599698

fbshipit-source-id: c5cc26b4c1c20fb9cca5bfe7143fa9dcb217a2d7
This commit is contained in:
Ziqi Chen 2018-06-28 11:56:53 -07:00 committed by Facebook Github Bot
parent 75a0273de2
commit 5f8b44fd22
3 changed files with 26 additions and 0 deletions

View File

@ -112,6 +112,7 @@ RCT_REMAP_VIEW_PROPERTY(accessibilityLabel, reactAccessibilityElement.accessibil
RCT_REMAP_VIEW_PROPERTY(accessibilityTraits, reactAccessibilityElement.accessibilityTraits, UIAccessibilityTraits)
RCT_REMAP_VIEW_PROPERTY(accessibilityViewIsModal, reactAccessibilityElement.accessibilityViewIsModal, BOOL)
RCT_REMAP_VIEW_PROPERTY(accessibilityElementsHidden, reactAccessibilityElement.accessibilityElementsHidden, BOOL)
RCT_REMAP_VIEW_PROPERTY(accessibilityIgnoresInvertColors, reactAccessibilityElement.shouldAccessibilityIgnoresInvertColors, BOOL)
RCT_REMAP_VIEW_PROPERTY(onAccessibilityAction, reactAccessibilityElement.onAccessibilityAction, RCTDirectEventBlock)
RCT_REMAP_VIEW_PROPERTY(onAccessibilityTap, reactAccessibilityElement.onAccessibilityTap, RCTDirectEventBlock)
RCT_REMAP_VIEW_PROPERTY(onMagicTap, reactAccessibilityElement.onMagicTap, RCTDirectEventBlock)

View File

@ -27,6 +27,12 @@
*/
@property (nonatomic, copy) NSString *nativeID;
/**
* Determines whether or not a view should ignore inverted colors or not. Used to set
* UIView property accessibilityIgnoresInvertColors in iOS 11+.
*/
@property (nonatomic, assign) BOOL shouldAccessibilityIgnoresInvertColors;
/**
* Layout direction of the view.
* Internally backed to `semanticContentAttribute` property.

View File

@ -35,6 +35,25 @@
objc_setAssociatedObject(self, @selector(nativeID), nativeID, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}
- (BOOL)shouldAccessibilityIgnoresInvertColors
{
#if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 110000 /* __IPHONE_11_0 */
if (@available(iOS 11.0, *)) {
return self.accessibilityIgnoresInvertColors;
}
#endif
return NO;
}
- (void)setShouldAccessibilityIgnoresInvertColors:(BOOL)shouldAccessibilityIgnoresInvertColors
{
#if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 110000 /* __IPHONE_11_0 */
if (@available(iOS 11.0, *)) {
self.accessibilityIgnoresInvertColors = shouldAccessibilityIgnoresInvertColors;
}
#endif
}
- (BOOL)isReactRootView
{
return RCTIsReactRootView(self.reactTag);