/** * 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. * * @flow strict-local * @format */ 'use strict'; import type {RNTesterModuleExample} from '../../types/RNTesterTypes'; import RNTesterBlock from '../../components/RNTesterBlock'; import RNTesterPage from '../../components/RNTesterPage'; import RNTesterText from '../../components/RNTesterText'; import React from 'react'; import {Alert, StyleSheet, TouchableWithoutFeedback, View} from 'react-native'; const importantForAccessibilityValues = [ 'auto', 'yes', 'no', 'no-hide-descendants', ] as const; type AccessibilityAndroidExampleState = { count: number, backgroundImportantForAcc: number, forgroundImportantForAcc: number, }; class AccessibilityAndroidExample extends React.Component< {}, AccessibilityAndroidExampleState, > { state: AccessibilityAndroidExampleState = { count: 0, backgroundImportantForAcc: 0, forgroundImportantForAcc: 0, }; _addOne = () => { this.setState({ count: ++this.state.count, }); }; _changeBackgroundImportantForAcc = () => { this.setState({ backgroundImportantForAcc: (this.state.backgroundImportantForAcc + 1) % 4, }); }; _changeForgroundImportantForAcc = () => { this.setState({ forgroundImportantForAcc: (this.state.forgroundImportantForAcc + 1) % 4, }); }; render(): React.Node { return ( Bacon {this.state.count} Ipsum{'\n'} Dolor sit amet{'\n'} Eggsecetur{'\n'} {'\n'} http://github.com Click me Clicked {this.state.count} times Hello world Change importantForAccessibility for background layout. Background layout importantForAccessibility { importantForAccessibilityValues[ this.state.backgroundImportantForAcc ] } Change importantForAccessibility for forground layout. Forground layout importantForAccessibility { importantForAccessibilityValues[ this.state.forgroundImportantForAcc ] } In the following example, the words "test", "inline links", "another link", and "link that spans multiple lines because the text is so long", should each be independently focusable elements, announced as their content followed by ", Link". They should be focused in order from top to bottom *after* the contents of the entire paragraph. Focusing on the paragraph itself should also announce that there are "links available", and opening Talkback's links menu should show these same links. Clicking on each link, or selecting the link From Talkback's links menu should trigger an alert. The links that wraps to multiple lines will intentionally only draw a focus outline around the first line, but using the "explore by touch" tap-and-drag gesture should move focus to this link even if the second line is touched. Using the "Explore by touch" gesture and touching an area that is *not* a link should move focus to the entire paragraph. Example This is a{' '} { Alert.alert('pressed test'); }}> test {' '} of{' '} { Alert.alert('pressed Inline Links'); }}> inline links {' '} in React Native. Here's{' '} { Alert.alert('pressed another link'); }}> another link . Here is a{' '} { Alert.alert('pressed long link'); }}> link that spans multiple lines because the text is so long. This sentence has no links in it. ); } } const styles = StyleSheet.create({ buttonText: { color: 'black', }, touchableContainer: { position: 'absolute', left: 10, top: 10, right: 10, height: 100, backgroundColor: 'green', }, embedded: { backgroundColor: 'yellow', padding: 10, }, container: { flex: 1, backgroundColor: 'white', padding: 10, height: 150, }, paragraph: { paddingBottom: 10, }, link: { color: 'blue', fontWeight: 'bold', }, exampleTitle: { fontWeight: 'bold', fontSize: 20, }, }); exports.title = 'AccessibilityAndroid'; exports.description = 'Android specific Accessibility APIs.'; exports.examples = [ { title: 'Accessibility elements', render(): React.MixedElement { return ; }, }, ] as Array;