Permalink
Browse files

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
  • Loading branch information...
ziqichen6 authored and facebook-github-bot committed Jun 28, 2018
1 parent 75a0273 commit 5f8b44fd227e20fc51bc16de80d6582adf78fc7b
Showing with 26 additions and 0 deletions.
  1. +1 −0 React/Views/RCTViewManager.m
  2. +6 −0 React/Views/UIView+React.h
  3. +19 −0 React/Views/UIView+React.m
@@ -112,6 +112,7 @@ - (RCTShadowView *)shadowView
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)
@@ -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
@@ -35,6 +35,25 @@ - (void)setNativeID:(NSNumber *)nativeID
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);

0 comments on commit 5f8b44f

Please sign in to comment.