AppIos.js 1.67 KB
Newer Older
1 2 3 4 5 6 7 8 9
/**
 * Sample React Native App
 * https://github.com/facebook/react-native
 *
 * @format
 * @flow strict-local
 */

import React from 'react';
10
import {StyleSheet, TouchableOpacity, View, Text} from 'react-native';
11 12
import AccessibilityWrapper from './AccessibilityWrapper';

13
const AppIos = () => {
14 15 16 17 18 19 20 21 22 23 24 25 26
  const ref1 = React.useRef();
  const ref2 = React.useRef();
  const ref3 = React.useRef();

  const [state, setState] = React.useState([ref1, ref2, ref3]);

  return (
    <>
      <View style={styles.header}>
        <Text style={styles.headerText}>RNAccessibilityOrder</Text>
      </View>
      <View style={styles.body}>
        <TouchableOpacity
27
          style={styles.button}
28
          onPress={() => {
29
            setState([ref3, ref2, ref1]);
30 31 32 33
          }}>
          <Text>Change accessibility focus order</Text>
        </TouchableOpacity>
        <AccessibilityWrapper fieldsRefs={state}>
34
          <TouchableOpacity ref={ref1} style={styles.button}>
35 36
            <Text>Button 1</Text>
          </TouchableOpacity>
37
          <TouchableOpacity ref={ref2} style={styles.button}>
38 39
            <Text>Button 2</Text>
          </TouchableOpacity>
40
          <TouchableOpacity ref={ref3} style={styles.button}>
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
            <Text>Button 3</Text>
          </TouchableOpacity>
        </AccessibilityWrapper>
      </View>
    </>
  );
};

const styles = StyleSheet.create({
  body: {
    flex: 1,
    paddingHorizontal: 10,
  },
  group: {
    padding: 10,
  },
  header: {
    backgroundColor: '#008577',
    paddingHorizontal: 20,
    paddingVertical: 20,
  },
  headerText: {
    color: 'white',
  },
65 66 67 68 69
  button: {
    padding: 10,
    margin: 10,
    backgroundColor: '#aaa',
  },
70 71
});

72
export default AppIos;