AppAndroid.js 1.71 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14
/**
 * Sample React Native App
 * https://github.com/facebook/react-native
 *
 * @format
 * @flow strict-local
 */

import React from 'react';
import {
  StyleSheet,
  TouchableOpacity,
  View,
  Text,
15
  findNodeHandle,
16 17
} from 'react-native';

18 19 20
import FocusOrder from './FocusOrder';

const AppAndroid = () => {
21 22 23 24 25 26 27 28 29 30 31
  const ref1 = React.useRef();
  const ref2 = React.useRef();
  const ref3 = React.useRef();

  return (
    <>
      <View style={styles.header}>
        <Text style={styles.headerText}>RNAccessibilityOrder</Text>
      </View>
      <View style={styles.body}>
        <TouchableOpacity
32
          style={styles.button}
33
          onPress={() => {
34 35 36 37 38
            FocusOrder.setOrder([
              findNodeHandle(ref3.current),
              findNodeHandle(ref2.current),
              findNodeHandle(ref1.current),
            ]);
39 40 41
          }}>
          <Text>Change accessibility focus order</Text>
        </TouchableOpacity>
42 43
        <View>
          <TouchableOpacity ref={ref1} style={styles.button}>
44 45
            <Text>Button 1</Text>
          </TouchableOpacity>
46
          <TouchableOpacity ref={ref2} style={styles.button}>
47 48
            <Text>Button 2</Text>
          </TouchableOpacity>
49
          <TouchableOpacity ref={ref3} style={styles.button}>
50 51
            <Text>Button 3</Text>
          </TouchableOpacity>
52
        </View>
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
      </View>
    </>
  );
};

const styles = StyleSheet.create({
  body: {
    flex: 1,
    paddingHorizontal: 10,
  },
  group: {
    padding: 10,
  },
  header: {
    backgroundColor: '#008577',
    paddingHorizontal: 20,
    paddingVertical: 20,
  },
  headerText: {
    color: 'white',
  },
74 75 76 77 78
  button: {
    padding: 10,
    margin: 10,
    backgroundColor: '#aaa',
  },
79 80
});

81
export default AppAndroid;