react-native-accessible-image

1.0.0 • Public • Published

react-native-accessible-image

React Native's Accessibility APIs doesn't provide a method to listen for focus enter on a certain view. React Native Accessibility Focus provides an alternative Image component, which is able to listen for accessibility events like accessibility-focus-start and accessibility-focus-end.

Getting started

$ npm install react-native-accessible-image --save

Mostly automatic installation

$ react-native link react-native-accessible-image

Manual installation

iOS

  1. In XCode, in the project navigator, right click LibrariesAdd Files to [your project's name]
  2. Go to node_modulesreact-native-accessible-image and add RNAccessibilityFocus.xcodeproj
  3. In XCode, in the project navigator, select your project. Add libRNAccessibilityFocus.a to your project's Build PhasesLink Binary With Libraries
  4. Run your project (Cmd+R)<

Android

  1. Open up android/app/src/main/java/[...]/MainActivity.java
  • Add import com.thetwo.accessibilityfocus.RNAccessibilityFocusPackage; to the imports at the top of the file
  • Add new RNAccessibilityFocusPackage() to the list returned by the getPackages() method
  1. Append the following lines to android/settings.gradle:
    include ':react-native-accessible-image'
    project(':react-native-accessible-image').projectDir = new File(rootProject.projectDir, 	'../node_modules/react-native-accessible-image/android')
    
  2. Insert the following lines inside the dependencies block in android/app/build.gradle:
      compile project(':react-native-accessible-image')
    

Usage

import AccessibleImage from 'react-native-accessible-image';
 
<AccessibleImage
    src={require('./my-image-path.png')}
    style={{ flex: 1 }}
    onFocusStart={() => console.log('focus started')}
    onFocusEnd={() => console.log('focus end')}
    onPress={() => console.log('pressed')}
    onLongPress={() => console.log('long pressed')}
/>

Package Sidebar

Install

npm i react-native-accessible-image

Weekly Downloads

0

Version

1.0.0

License

CC-BY-NC-4.0

Unpacked Size

54.2 kB

Total Files

21

Last publish

Collaborators

  • nicokant