react-native/Libraries/Components/View/ViewAccessibility.js

100 lines
1.8 KiB
JavaScript
Raw Normal View History

/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
* @flow strict
*/
'use strict';
export type AccessibilityTrait =
| 'none'
| 'button'
| 'link'
| 'header'
| 'search'
| 'image'
| 'selected'
| 'plays'
| 'key'
| 'text'
| 'summary'
| 'disabled'
| 'frequentUpdates'
| 'startsMedia'
| 'adjustable'
| 'allowsDirectInteraction'
| 'pageTurn';
export type AccessibilityTraits =
| AccessibilityTrait
| $ReadOnlyArray<AccessibilityTrait>;
export type AccessibilityComponentType =
| 'none'
| 'button'
| 'radiobutton_checked'
| 'radiobutton_unchecked';
added accessibilityRole Prop, added functionality support for role on android Summary: Added a new property to View for Accessibility called `accessibilityRole`. This property merges functionality of existing properties: `accessibilityTraits` (iOS) and `accessibilityComponentType` (android). Currently, nine values are supported with equivalent behavior as `accessibilityTraits` (iOS) when `accessibilityRole` is set on iOS Voiceover and Android TalkBack ``` | 'none' | 'button' | 'link' | 'search' | 'image' | 'keyboardkey' | 'text' | 'adjustable' | 'tabbar' ``` They currently support similar behavior on talkback on Android and voice over on iOS Does not break functionality of existing properties, but have not tested for behavior of setting both this one and the old one. * iOS - I added a property accessibilityRoles, and basically remapped it to the same thing as accessibilityTraits. I also added in enum mappings for keyboardkey and tabbar. * Android - Also added a property accessibilityRoles, from the Android side. For the underlying native functionality, I built a helper class that is based off of AccessibilityRolesUtil.java from the accessibility team. Biggest changes made are that I defined my own enums if needed, and also set some properties to match the functionality of iOS Accessibility Traits. I also handled the logic for switch/case statements of setting roles for the android side on this file. Also, I currently haven't localized strings for setRoleDescription, but plan to. * Javascript - I added a view property accessibilityRoles in ViewPropTypes. Reviewed By: blavalla Differential Revision: D8756225 fbshipit-source-id: e03eec40cce86042551764f433e1defe7ee41b35
2018-07-10 19:09:02 +00:00
export type AccessibilityRole =
| 'none'
| 'button'
| 'link'
| 'search'
added accessibilityRole Prop, added functionality support for role on android Summary: Added a new property to View for Accessibility called `accessibilityRole`. This property merges functionality of existing properties: `accessibilityTraits` (iOS) and `accessibilityComponentType` (android). Currently, nine values are supported with equivalent behavior as `accessibilityTraits` (iOS) when `accessibilityRole` is set on iOS Voiceover and Android TalkBack ``` | 'none' | 'button' | 'link' | 'search' | 'image' | 'keyboardkey' | 'text' | 'adjustable' | 'tabbar' ``` They currently support similar behavior on talkback on Android and voice over on iOS Does not break functionality of existing properties, but have not tested for behavior of setting both this one and the old one. * iOS - I added a property accessibilityRoles, and basically remapped it to the same thing as accessibilityTraits. I also added in enum mappings for keyboardkey and tabbar. * Android - Also added a property accessibilityRoles, from the Android side. For the underlying native functionality, I built a helper class that is based off of AccessibilityRolesUtil.java from the accessibility team. Biggest changes made are that I defined my own enums if needed, and also set some properties to match the functionality of iOS Accessibility Traits. I also handled the logic for switch/case statements of setting roles for the android side on this file. Also, I currently haven't localized strings for setRoleDescription, but plan to. * Javascript - I added a view property accessibilityRoles in ViewPropTypes. Reviewed By: blavalla Differential Revision: D8756225 fbshipit-source-id: e03eec40cce86042551764f433e1defe7ee41b35
2018-07-10 19:09:02 +00:00
| 'image'
| 'keyboardkey'
| 'text'
| 'adjustable'
| 'imagebutton'
| 'header'
| 'summary';
added accessibilityRole Prop, added functionality support for role on android Summary: Added a new property to View for Accessibility called `accessibilityRole`. This property merges functionality of existing properties: `accessibilityTraits` (iOS) and `accessibilityComponentType` (android). Currently, nine values are supported with equivalent behavior as `accessibilityTraits` (iOS) when `accessibilityRole` is set on iOS Voiceover and Android TalkBack ``` | 'none' | 'button' | 'link' | 'search' | 'image' | 'keyboardkey' | 'text' | 'adjustable' | 'tabbar' ``` They currently support similar behavior on talkback on Android and voice over on iOS Does not break functionality of existing properties, but have not tested for behavior of setting both this one and the old one. * iOS - I added a property accessibilityRoles, and basically remapped it to the same thing as accessibilityTraits. I also added in enum mappings for keyboardkey and tabbar. * Android - Also added a property accessibilityRoles, from the Android side. For the underlying native functionality, I built a helper class that is based off of AccessibilityRolesUtil.java from the accessibility team. Biggest changes made are that I defined my own enums if needed, and also set some properties to match the functionality of iOS Accessibility Traits. I also handled the logic for switch/case statements of setting roles for the android side on this file. Also, I currently haven't localized strings for setRoleDescription, but plan to. * Javascript - I added a view property accessibilityRoles in ViewPropTypes. Reviewed By: blavalla Differential Revision: D8756225 fbshipit-source-id: e03eec40cce86042551764f433e1defe7ee41b35
2018-07-10 19:09:02 +00:00
export type AccessibilityStates = $ReadOnlyArray<'disabled' | 'selected'>;
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',
],
// This must be kept in sync with the AccessibilityRolesMask in RCTViewManager.m
added accessibilityRole Prop, added functionality support for role on android Summary: Added a new property to View for Accessibility called `accessibilityRole`. This property merges functionality of existing properties: `accessibilityTraits` (iOS) and `accessibilityComponentType` (android). Currently, nine values are supported with equivalent behavior as `accessibilityTraits` (iOS) when `accessibilityRole` is set on iOS Voiceover and Android TalkBack ``` | 'none' | 'button' | 'link' | 'search' | 'image' | 'keyboardkey' | 'text' | 'adjustable' | 'tabbar' ``` They currently support similar behavior on talkback on Android and voice over on iOS Does not break functionality of existing properties, but have not tested for behavior of setting both this one and the old one. * iOS - I added a property accessibilityRoles, and basically remapped it to the same thing as accessibilityTraits. I also added in enum mappings for keyboardkey and tabbar. * Android - Also added a property accessibilityRoles, from the Android side. For the underlying native functionality, I built a helper class that is based off of AccessibilityRolesUtil.java from the accessibility team. Biggest changes made are that I defined my own enums if needed, and also set some properties to match the functionality of iOS Accessibility Traits. I also handled the logic for switch/case statements of setting roles for the android side on this file. Also, I currently haven't localized strings for setRoleDescription, but plan to. * Javascript - I added a view property accessibilityRoles in ViewPropTypes. Reviewed By: blavalla Differential Revision: D8756225 fbshipit-source-id: e03eec40cce86042551764f433e1defe7ee41b35
2018-07-10 19:09:02 +00:00
AccessibilityRoles: [
'none',
'button',
'link',
'search',
added accessibilityRole Prop, added functionality support for role on android Summary: Added a new property to View for Accessibility called `accessibilityRole`. This property merges functionality of existing properties: `accessibilityTraits` (iOS) and `accessibilityComponentType` (android). Currently, nine values are supported with equivalent behavior as `accessibilityTraits` (iOS) when `accessibilityRole` is set on iOS Voiceover and Android TalkBack ``` | 'none' | 'button' | 'link' | 'search' | 'image' | 'keyboardkey' | 'text' | 'adjustable' | 'tabbar' ``` They currently support similar behavior on talkback on Android and voice over on iOS Does not break functionality of existing properties, but have not tested for behavior of setting both this one and the old one. * iOS - I added a property accessibilityRoles, and basically remapped it to the same thing as accessibilityTraits. I also added in enum mappings for keyboardkey and tabbar. * Android - Also added a property accessibilityRoles, from the Android side. For the underlying native functionality, I built a helper class that is based off of AccessibilityRolesUtil.java from the accessibility team. Biggest changes made are that I defined my own enums if needed, and also set some properties to match the functionality of iOS Accessibility Traits. I also handled the logic for switch/case statements of setting roles for the android side on this file. Also, I currently haven't localized strings for setRoleDescription, but plan to. * Javascript - I added a view property accessibilityRoles in ViewPropTypes. Reviewed By: blavalla Differential Revision: D8756225 fbshipit-source-id: e03eec40cce86042551764f433e1defe7ee41b35
2018-07-10 19:09:02 +00:00
'image',
'keyboardkey',
'text',
'adjustable',
'imagebutton',
'header',
'summary',
added accessibilityRole Prop, added functionality support for role on android Summary: Added a new property to View for Accessibility called `accessibilityRole`. This property merges functionality of existing properties: `accessibilityTraits` (iOS) and `accessibilityComponentType` (android). Currently, nine values are supported with equivalent behavior as `accessibilityTraits` (iOS) when `accessibilityRole` is set on iOS Voiceover and Android TalkBack ``` | 'none' | 'button' | 'link' | 'search' | 'image' | 'keyboardkey' | 'text' | 'adjustable' | 'tabbar' ``` They currently support similar behavior on talkback on Android and voice over on iOS Does not break functionality of existing properties, but have not tested for behavior of setting both this one and the old one. * iOS - I added a property accessibilityRoles, and basically remapped it to the same thing as accessibilityTraits. I also added in enum mappings for keyboardkey and tabbar. * Android - Also added a property accessibilityRoles, from the Android side. For the underlying native functionality, I built a helper class that is based off of AccessibilityRolesUtil.java from the accessibility team. Biggest changes made are that I defined my own enums if needed, and also set some properties to match the functionality of iOS Accessibility Traits. I also handled the logic for switch/case statements of setting roles for the android side on this file. Also, I currently haven't localized strings for setRoleDescription, but plan to. * Javascript - I added a view property accessibilityRoles in ViewPropTypes. Reviewed By: blavalla Differential Revision: D8756225 fbshipit-source-id: e03eec40cce86042551764f433e1defe7ee41b35
2018-07-10 19:09:02 +00:00
],
// This must be kept in sync with the AccessibilityStatesMask in RCTViewManager.m
AccessibilityStates: ['selected', 'disabled'],
};