diff --git a/packages/rn-tester/js/examples/Accessibility/AccessibilityExample.js b/packages/rn-tester/js/examples/Accessibility/AccessibilityExample.js index bd14a801340..49fa8bfaffe 100644 --- a/packages/rn-tester/js/examples/Accessibility/AccessibilityExample.js +++ b/packages/rn-tester/js/examples/Accessibility/AccessibilityExample.js @@ -13,6 +13,8 @@ import type {PressEvent} from 'react-native/Libraries/Types/CoreEventTypes'; import type {EventSubscription} from 'react-native/Libraries/vendor/emitter/EventEmitter'; +import {RNTesterThemeContext} from '../../components/RNTesterTheme'; + const RNTesterBlock = require('../../components/RNTesterBlock'); const checkImageSource = require('./check.png'); const mixedCheckboxImageSource = require('./mixed.png'); @@ -104,180 +106,214 @@ const styles = StyleSheet.create({ class AccessibilityExample extends React.Component<{}> { render(): React.Node { return ( - - - - Text's accessibilityLabel is the raw text itself unless it is set - explicitly. - - - - - - This text component's accessibilityLabel is set explicitly. - - - - - - This is text one. - This is text two. - - - - - - This is text one. - This is text two. - - - - - - This is text one. - This is text two. - - - - - - - This view's children are hidden from the accessibility tree - - - - - {/* Android screen readers will say the accessibility hint instead of the text - since the view doesn't have a label. */} - - - This is text one. - This is text two. - - - - - - This is text one. - This is text two. - - - - - This is a title. - - - - This is a title. - - - - Alert.alert('Link has been clicked!')} - accessibilityRole="link"> - - Click me - - - - - - Alert.alert('Button has been pressed!')} - accessibilityRole="button"> - Click me - - - - - Alert.alert('Button has been pressed!')} - accessibilityRole="button" - accessibilityState={{disabled: true}} - disabled={true}> - - - I am disabled. Clicking me will not trigger any action. + + {theme => ( + + + + Text's accessibilityLabel is the raw text itself unless it is + set explicitly. - - - + - - Alert.alert('Disabled Button has been pressed!')} - accessibilityLabel={'You are pressing Disabled TouchableOpacity'} - accessibilityState={{disabled: true}}> - - - I am disabled. Clicking me will not trigger any action. + + + This text component's accessibilityLabel is set explicitly. - - - - - - This view is selected and disabled. - - + - - - Accessible view with label, hint, role, and state - - + + + This is text one. + This is text two. + + - - - Accessible view with label, hint, role, and state - - + + + This is text one. + This is text two. + + - - - Mail Address - - First Name - + + + This is text one. + This is text two. + + + + + + + This view's children are hidden from the accessibility tree + + + + + {/* Android screen readers will say the accessibility hint instead of the text + since the view doesn't have a label. */} + + + This is text one. + This is text two. + + + + + + This is text one. + This is text two. + + + + + + This is a title. + + + + + + This is a title. + + + + + Alert.alert('Link has been clicked!')} + accessibilityRole="link"> + + + Click me + + + + + + + Alert.alert('Button has been pressed!')} + accessibilityRole="button"> + Click me + + + + + Alert.alert('Button has been pressed!')} + accessibilityRole="button" + accessibilityState={{disabled: true}} + disabled={true}> + + + I am disabled. Clicking me will not trigger any action. + + + + + + + Alert.alert('Disabled Button has been pressed!')} + accessibilityLabel={ + 'You are pressing Disabled TouchableOpacity' + } + accessibilityState={{disabled: true}}> + + + I am disabled. Clicking me will not trigger any action. + + + + + + + + This view is selected and disabled. + + + + + + + + Accessible view with label, hint, role, and state + + + + + + + + Accessible view with label, hint, role, and state + + + + + + + + Mail Address + + + + First Name + + + + + + + + Enable Notifications + + + + - - - - Enable Notifications - - - - + )} + ); } } @@ -285,134 +321,170 @@ class AccessibilityExample extends React.Component<{}> { class AutomaticContentGrouping extends React.Component<{}> { render(): React.Node { return ( - - - - - - Text number 1 with a role - - Text number 2 - - - - - - { - switch (event.nativeEvent.actionName) { - case 'cut': - Alert.alert('Alert', 'cut action success'); - break; - case 'copy': - Alert.alert('Alert', 'copy action success'); - break; - case 'paste': - Alert.alert('Alert', 'paste action success'); - break; - } - }} - accessibilityRole="button"> - - Text number 1 - - Text number 2Text number 3 - - - - - - - - - Text number 1 - - - - - - - - - Text number 1 + + {theme => ( + + console.warn('onPress child')} - accessible={false} - accessibilityLabel="this is my label" - accessibilityRole="image" - accessibilityState={{disabled: true}} - accessibilityValue={{text: 'this is the accessibility value'}}> - Text number 3 + accessible={true} + accessibilityRole="button"> + + + Text number 1 with a role + + + Text number 2 + + - + + + + { + switch (event.nativeEvent.actionName) { + case 'cut': + Alert.alert('Alert', 'cut action success'); + break; + case 'copy': + Alert.alert('Alert', 'copy action success'); + break; + case 'paste': + Alert.alert('Alert', 'paste action success'); + break; + } + }} + accessibilityRole="button"> + + + Text number 1 + + + Text number 2Text number 3 + + + + + + + + + Text number 1 + + + + + + + + + + Text number 1 + + console.warn('onPress child')} + accessible={false} + accessibilityLabel="this is my label" + accessibilityRole="image" + accessibilityState={{disabled: true}} + accessibilityValue={{ + text: 'this is the accessibility value', + }}> + + Text number 3 + + + + + + + + + + + + + + + + Text number 2 + + Text number 3Text number 4 + + + + + + + console.warn('onPress child')} + accessible={true} + accessibilityRole="button"> + + + + + + + + + + + - - - - - - - - - - - - Text number 2 - - Text number 3Text number 4 - - - - - - - console.warn('onPress child')} - accessible={true} - accessibilityRole="button"> - - - - - - - - - - - - + )} + ); } } @@ -444,14 +516,20 @@ class CheckboxExample extends React.Component< render(): React.Node { return ( - - Checkbox example - + + {theme => ( + + + Checkbox example + + + )} + ); } } @@ -476,14 +554,20 @@ class SwitchExample extends React.Component< render(): React.Node { return ( - - Switch example - + + {theme => ( + + + Switch example + + + )} + ); } } @@ -589,13 +673,19 @@ class ExpandableElementExample extends React.Component< render(): React.Node { return ( - - Expandable element example - + + {theme => ( + + + Expandable element example + + + )} + ); } } @@ -666,55 +756,59 @@ class NestedCheckBox extends React.Component< render(): React.Node { return ( - - - - Meat - - - - Beef - - - - Bacon - - + + {theme => ( + + + + Meat + + + + Beef + + + + Bacon + + + )} + ); } } @@ -732,156 +826,210 @@ class AccessibilityRoleAndStateExample extends React.Component<{}> { ]; return ( - - - - {content} - - - - - {content} - - - - - {content} - - - - - - Alert example - - - - Combobox example - - - Menu example - - - Menu bar example - - - Menu item example - - - Progress bar example - - - Radio button example - - - Radio group example - - - Scrollbar example - - - Spin button example - - - - Tab example - - - Tab list example - - - Timer example - - - Toolbar example - - - State busy example - - - Drop Down List example - - - Pager example - - - Toggle Button example - - - Viewgroup example - - - Webview example - - - - Nested checkbox with delayed state change - + + {theme => ( + + + + + {content} + + + + + + + {content} + + + + + + + {content} + + + + + + + + Alert example + + + + + + Combobox example + + + + + Menu example + + + + + Menu bar example + + + + + Menu item example + + + + + Progress bar example + + + + + Radio button example + + + + + Radio group example + + + + + Scrollbar example + + + + + Spin button example + + + + + + Tab example + + + + + Tab list example + + + + + Timer example + + + + + Toolbar example + + + + + State busy example + + + + + Drop Down List example + + + + + Pager example + + + + + Toggle Button example + + + + + Viewgroup example + + + + + Webview example + + + + + + Nested checkbox with delayed state change + + + + - - + )} + ); } } @@ -889,138 +1037,150 @@ class AccessibilityRoleAndStateExample extends React.Component<{}> { class AccessibilityActionsExample extends React.Component<{}> { render(): React.Node { return ( - - - { - switch (event.nativeEvent.actionName) { - case 'activate': - Alert.alert('Alert', 'View is clicked'); - break; - } - }}> - Click me + + {theme => ( + + + { + switch (event.nativeEvent.actionName) { + case 'activate': + Alert.alert('Alert', 'View is clicked'); + break; + } + }}> + Click me + + + + + { + switch (event.nativeEvent.actionName) { + case 'cut': + Alert.alert('Alert', 'cut action success'); + break; + case 'copy': + Alert.alert('Alert', 'copy action success'); + break; + case 'paste': + Alert.alert('Alert', 'paste action success'); + break; + } + }}> + + This view supports many actions. + + + + + + { + switch (event.nativeEvent.actionName) { + case 'increment': + Alert.alert('Alert', 'increment action success'); + break; + case 'decrement': + Alert.alert('Alert', 'decrement action success'); + break; + } + }}> + Slider + + + + + { + switch (event.nativeEvent.actionName) { + case 'cut': + Alert.alert('Alert', 'cut action success'); + break; + case 'copy': + Alert.alert('Alert', 'copy action success'); + break; + case 'paste': + Alert.alert('Alert', 'paste action success'); + break; + } + }} + onPress={() => Alert.alert('Button has been pressed!')} + accessibilityRole="button"> + + + Click me + + + + + + +