Permalink
Browse files

added native iOS functionality for prop currentViewStates

Summary:
Added Native iOS functionality for prop currentViewStates.

On iOS, this property modifies both the view property userInteractionEnabled and also adds corresponding UIAccessibilityTraits to the view.

If disabled is passed in, userInteractionEnabled of the view will be set to false.

The value that is passed into currentviewStates is converted to a UIAccessibilityTrait Enum and masked in with existing UIAccessibilityTraits on that native view.

The native implementation for accessibilityRole is also changed to also mask new UIAccessibilityTraits with existing ones.

Reviewed By: PeteTheHeat

Differential Revision: D8842691

fbshipit-source-id: 919267300c70efed93a7a92377a0178bd8885eb5
  • Loading branch information...
ziqichen6 authored and facebook-github-bot committed Jul 17, 2018
1 parent c1d0ccd commit 679bff2658071dcc5dd10ee847d711d669f46d82
Showing with 15 additions and 1 deletion.
  1. +15 −1 React/Views/RCTViewManager.m
@@ -112,7 +112,6 @@ - (RCTShadowView *)shadowView
RCT_REMAP_VIEW_PROPERTY(accessibilityActions, reactAccessibilityElement.accessibilityActions, NSString)
RCT_REMAP_VIEW_PROPERTY(accessibilityLabel, reactAccessibilityElement.accessibilityLabel, NSString)
RCT_REMAP_VIEW_PROPERTY(accessibilityTraits, reactAccessibilityElement.accessibilityTraits, UIAccessibilityTraits)
RCT_REMAP_VIEW_PROPERTY(accessibilityRole, 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)
@@ -149,6 +148,21 @@ - (RCTShadowView *)shadowView
view.layer.allowsEdgeAntialiasing = !CATransform3DIsIdentity(view.layer.transform);
}
RCT_CUSTOM_VIEW_PROPERTY(accessibilityRole, UIAccessibilityTraits, RCTView)
{
view.reactAccessibilityElement.accessibilityTraits |= json ? [RCTConvert UIAccessibilityTraits:json] : defaultView.accessibilityTraits;
}
RCT_CUSTOM_VIEW_PROPERTY(currentViewStates, UIAccessibilityTraits, RCTView)
{
UIAccessibilityTraits traits = json ? [RCTConvert UIAccessibilityTraits:json] : defaultView.accessibilityTraits;
view.reactAccessibilityElement.accessibilityTraits |= traits;
if (traits == UIAccessibilityTraitNotEnabled || traits == (UIAccessibilityTraitNotEnabled | UIAccessibilityTraitSelected))
{
view.userInteractionEnabled = NO;
}
}
RCT_CUSTOM_VIEW_PROPERTY(pointerEvents, RCTPointerEvents, RCTView)
{
if ([view respondsToSelector:@selector(setPointerEvents:)]) {

0 comments on commit 679bff2

Please sign in to comment.