1.0.5 • Published 3 years ago

react-native-show-touches-ios v1.0.5

Weekly downloads
17
License
MIT
Repository
github
Last release
3 years ago

react-native-show-touches-ios

Use react-native-show-touches to show customizable touch indicators for any touches recieved on iOS.
App UI components will continue to function as expected.

Has no effect on Android.

Getting started

1. Install with package manager

$ yarn add react-native-show-touches-ios

or

$ npm install react-native-show-touches-ios --save

2. Install CocoaPod

cd ios && pod install

Usage

Basic touch indicators

import ShowTouches from "react-native-show-touches-ios";

// Wrap your root component to show default touch indicator for all touches
const App = () => {
  return (
    <ShowTouches>
      <SafeAreaView style={styles.container}>{/* Your app... */}</SafeAreaView>
    </ShowTouches>
  );
};

Customization

import ShowTouches from "react-native-show-touches-ios";

const App = () => {
  return (
    <ShowTouches
      color="red"
      opacity={0.1}
      radius={100}
      borderColor="orange"
      borderOpacity={0.9}
      borderWidth={5}
      fadeDuration={1}
    >
      <SafeAreaView style={styles.container}>{/* Your app... */}</SafeAreaView>
    </ShowTouches>
  );
};

***Usage with react-navigation

When using with an app that uses react-navigation, you can wrap your root component with <ShowTouches> just as you normally would.
In order for your underlying UI components to work, you must use react-native-gesture-handler as described in the react-navigation docs.

Proper usage with react-native-gesture-handler:

import ShowTouches from 'react-native-show-touches-ios';
import {TouchableOpacity} from 'react-native-gesture-handler

const App = () => {
  return (
    <ShowTouches
      color="red"
      opacity={0.1}
      radius={100}
      borderColor="orange"
      borderOpacity={0.9}
      borderWidth={5}
      fadeDuration={1}>
        ... REACT-NAVIGATION-CONTAINER ...
            <TouchableOpacity
              onPress={() => {
                console.log('pressed');
              }}>
              <Text>Press Me</Text>
            </TouchableOpacity>
        ... REACT-NAVIGATION-CONTAINER END ...
    </ShowTouches>
  );
};

Incorrect usage with react-native-gesture-handler:

TouchableOpacity from react-native will not work when using react-navigation - must use the component provided by react-native-gesture handler when using react-navigation

import ShowTouches from "react-native-show-touches-ios";
import { TouchableOpacity } from "react-native";

const App = () => {
  return (
    <ShowTouches
      color="red"
      opacity={0.1}
      radius={100}
      borderColor="orange"
      borderOpacity={0.9}
      borderWidth={5}
      fadeDuration={1}
    >
      ... REACT-NAVIGATION-CONTAINER ...
      <TouchableOpacity
        onPress={() => {
          console.log("pressed");
        }}
      >
        <Text>Press Me</Text>
      </TouchableOpacity>
      ... REACT-NAVIGATION-CONTAINER END ...
    </ShowTouches>
  );
};

Props

NameDescriptionTypeDefault Value
colorthe inner color of the touch indicatorString#007bff '#007bff' (UIColor.systemBlue)
opacitythe inner opacity of the touch indicatorNumber0.5
radiusthe radius of the touch indicatorNumber40
borderColorthe border colorString#007bff '#007bff' (UIColor.systemBlue)
borderOpacitythe opacity of the borderNumber1
borderWidththe width of the borderNumber2
fadeDurationthe duration of the touch indicator's fade out animation in secondsNumber0.3

Todo

  • iOS support
  • Android support
  • More animation customization options

Author

Michael Kiley

License

MIT