mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
7b05b091fd
Summary: This PR fixes https://github.com/facebook/react-native/issues/30891 This PR is going to add an `accessibilityLanguage` prop to all the available components. This props is currently working only on iOS and should follow the [guidelines of the relative configuration](https://developer.apple.com/documentation/objectivec/nsobject/1615192-accessibilitylanguage). I'm in no way an expert on native programming (especially Objective-C) so I'm open to changes / improvements 🙂 ## Changelog <!-- Help reviewers and the release process by writing your own changelog entry. For an example, see: https://github.com/facebook/react-native/wiki/Changelog --> [iOS] [Added] - Integrated the `accessibilityLanguage` prop to all the available components. The prop is available for any platform but it will work only on iOS. Pull Request resolved: https://github.com/facebook/react-native/pull/33090 Test Plan: This has been tested using both the Simulator, checking for the `Language` attribute, and using a physical device with the Voice Over enabled. <img width="1083" alt="Screenshot 2022-02-11 at 13 17 32" src="https://user-images.githubusercontent.com/5963683/153590415-65fcb4ff-8f31-4a0f-90e5-8eb1aae6aa3d.png"> Reviewed By: philIip Differential Revision: D34523608 Pulled By: rh389 fbshipit-source-id: b5d77fc0b3d76ea8ed8f30c8385459ba98122ff6
153 lines
4.5 KiB
C++
153 lines
4.5 KiB
C++
/*
|
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*/
|
|
|
|
#include "AccessibilityProps.h"
|
|
|
|
#include <react/renderer/components/view/accessibilityPropsConversions.h>
|
|
#include <react/renderer/components/view/propsConversions.h>
|
|
#include <react/renderer/core/propsConversions.h>
|
|
#include <react/renderer/debug/debugStringConvertibleUtils.h>
|
|
|
|
namespace facebook {
|
|
namespace react {
|
|
|
|
AccessibilityProps::AccessibilityProps(
|
|
const PropsParserContext &context,
|
|
AccessibilityProps const &sourceProps,
|
|
RawProps const &rawProps)
|
|
: accessible(convertRawProp(
|
|
context,
|
|
rawProps,
|
|
"accessible",
|
|
sourceProps.accessible,
|
|
false)),
|
|
accessibilityTraits(convertRawProp(
|
|
context,
|
|
rawProps,
|
|
"accessibilityRole",
|
|
sourceProps.accessibilityTraits,
|
|
AccessibilityTraits::None)),
|
|
accessibilityState(convertRawProp(
|
|
context,
|
|
rawProps,
|
|
"accessibilityState",
|
|
sourceProps.accessibilityState,
|
|
{})),
|
|
accessibilityLabel(convertRawProp(
|
|
context,
|
|
rawProps,
|
|
"accessibilityLabel",
|
|
sourceProps.accessibilityLabel,
|
|
"")),
|
|
accessibilityLabelledBy(convertRawProp(
|
|
context,
|
|
rawProps,
|
|
"accessibilityLabelledBy",
|
|
sourceProps.accessibilityLabelledBy,
|
|
{})),
|
|
accessibilityLiveRegion(convertRawProp(
|
|
context,
|
|
rawProps,
|
|
"accessibilityLiveRegion",
|
|
sourceProps.accessibilityLiveRegion,
|
|
AccessibilityLiveRegion::None)),
|
|
accessibilityRole(convertRawProp(
|
|
context,
|
|
rawProps,
|
|
"accessibilityRole",
|
|
sourceProps.accessibilityRole,
|
|
"")),
|
|
accessibilityHint(convertRawProp(
|
|
context,
|
|
rawProps,
|
|
"accessibilityHint",
|
|
sourceProps.accessibilityHint,
|
|
"")),
|
|
accessibilityLanguage(convertRawProp(
|
|
context,
|
|
rawProps,
|
|
"accessibilityLanguage",
|
|
sourceProps.accessibilityLanguage,
|
|
"")),
|
|
accessibilityValue(convertRawProp(
|
|
context,
|
|
rawProps,
|
|
"accessibilityValue",
|
|
sourceProps.accessibilityValue,
|
|
{})),
|
|
accessibilityActions(convertRawProp(
|
|
context,
|
|
rawProps,
|
|
"accessibilityActions",
|
|
sourceProps.accessibilityActions,
|
|
{})),
|
|
accessibilityViewIsModal(convertRawProp(
|
|
context,
|
|
rawProps,
|
|
"accessibilityViewIsModal",
|
|
sourceProps.accessibilityViewIsModal,
|
|
false)),
|
|
accessibilityElementsHidden(convertRawProp(
|
|
context,
|
|
rawProps,
|
|
"accessibilityElementsHidden",
|
|
sourceProps.accessibilityElementsHidden,
|
|
false)),
|
|
accessibilityIgnoresInvertColors(convertRawProp(
|
|
context,
|
|
rawProps,
|
|
"accessibilityIgnoresInvertColors",
|
|
sourceProps.accessibilityIgnoresInvertColors,
|
|
false)),
|
|
onAccessibilityTap(convertRawProp(
|
|
context,
|
|
rawProps,
|
|
"onAccessibilityTap",
|
|
sourceProps.onAccessibilityTap,
|
|
{})),
|
|
onAccessibilityMagicTap(convertRawProp(
|
|
context,
|
|
rawProps,
|
|
"onAccessibilityMagicTap",
|
|
sourceProps.onAccessibilityMagicTap,
|
|
{})),
|
|
onAccessibilityEscape(convertRawProp(
|
|
context,
|
|
rawProps,
|
|
"onAccessibilityEscape",
|
|
sourceProps.onAccessibilityEscape,
|
|
{})),
|
|
onAccessibilityAction(convertRawProp(
|
|
context,
|
|
rawProps,
|
|
"onAccessibilityAction",
|
|
sourceProps.onAccessibilityAction,
|
|
{})),
|
|
importantForAccessibility(convertRawProp(
|
|
context,
|
|
rawProps,
|
|
"importantForAccessibility",
|
|
sourceProps.importantForAccessibility,
|
|
ImportantForAccessibility::Auto)),
|
|
testId(
|
|
convertRawProp(context, rawProps, "testID", sourceProps.testId, "")) {
|
|
}
|
|
|
|
#pragma mark - DebugStringConvertible
|
|
|
|
#if RN_DEBUG_STRING_CONVERTIBLE
|
|
SharedDebugStringConvertibleList AccessibilityProps::getDebugProps() const {
|
|
auto const &defaultProps = AccessibilityProps();
|
|
return SharedDebugStringConvertibleList{
|
|
debugStringConvertibleItem("testId", testId, defaultProps.testId),
|
|
};
|
|
}
|
|
#endif // RN_DEBUG_STRING_CONVERTIBLE
|
|
|
|
} // namespace react
|
|
} // namespace facebook
|