Skip to content
Open
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
36 changes: 7 additions & 29 deletions Libraries/Components/View/View.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ const ViewStylePropTypes = require('ViewStylePropTypes');

const invariant = require('fbjs/lib/invariant');

const {
AccessibilityComponentTypes,
AccessibilityTraits,
} = require('ViewAccessibility');

var TVViewPropTypes = {};
if (Platform.isTVOS) {
TVViewPropTypes = require('TVViewPropTypes');
Expand All @@ -34,39 +39,12 @@ const PropTypes = React.PropTypes;

const stylePropType = StyleSheetPropType(ViewStylePropTypes);

const AccessibilityTraits = [
'none',
'button',
'link',
'header',
'search',
'image',
'selected',
'plays',
'key',
'text',
'summary',
'disabled',
'frequentUpdates',
'startsMedia',
'adjustable',
'allowsDirectInteraction',
'pageTurn',
];

const AccessibilityComponentType = [
'none',
'button',
'radiobutton_checked',
'radiobutton_unchecked',
];

const forceTouchAvailable = (NativeModules.IOSConstants &&
NativeModules.IOSConstants.forceTouchAvailable) || false;

const statics = {
AccessibilityTraits,
AccessibilityComponentType,
AccessibilityComponentType: AccessibilityComponentTypes,
/**
* Is 3D Touch / Force Touch available (i.e. will touch events include `force`)
* @platform ios
Expand Down Expand Up @@ -169,7 +147,7 @@ const View = React.createClass({
*
* @platform android
*/
accessibilityComponentType: PropTypes.oneOf(AccessibilityComponentType),
accessibilityComponentType: PropTypes.oneOf(AccessibilityComponentTypes),

/**
* Indicates to accessibility services whether the user should be notified
Expand Down
65 changes: 65 additions & 0 deletions Libraries/Components/View/ViewAccessibility.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @providesModule ViewAccessibility
* @flow
*/
'use strict';

export type AccessibilityTrait =
'none' |
'button' |
'link' |
'header' |
'search' |
'image' |
'selected' |
'plays' |
'key' |
'text' |
'summary' |
'disabled' |
'frequentUpdates' |
'startsMedia' |
'adjustable' |
'allowsDirectInteraction' |
'pageTurn';

export type AccessibilityComponentType =
'none' |
'button' |
'radiobutton_checked' |
'radiobutton_unchecked';

module.exports = {
AccessibilityTraits: [
'none',
'button',
'link',
'header',
'search',
'image',
'selected',
'plays',
'key',
'text',
'summary',
'disabled',
'frequentUpdates',
'startsMedia',
'adjustable',
'allowsDirectInteraction',
'pageTurn',
],
AccessibilityComponentTypes: [
'none',
'button',
'radiobutton_checked',
'radiobutton_unchecked',
],
};
2 changes: 1 addition & 1 deletion React/Views/RCTPicker.m
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ - (void)pickerView:(__unused UIPickerView *)pickerView
didSelectRow:(NSInteger)row inComponent:(__unused NSInteger)component
{
_selectedIndex = row;
if (_onChange) {
if (_onChange && _items.count > row) {
_onChange(@{
@"newIndex": @(row),
@"newValue": RCTNullIfNil(_items[row][@"value"]),
Expand Down