react-native-microscope

1.1.3 • Public • Published

react-native-microscope

Getting started

$ yarn add react-native-microscope $ yarn add react-native-view-shot

RN >= 0.60

iOS:

  1. add pod 'RNMicroscope', :path => '../node_modules/react-native-microscope' in Podfile.
  2. cd ios && pod install
  3. Click on project General tab
  4. Under Embedded Binaries click + and add JH_Libary.framework

Mostly automatic installation

$ react-native link react-native-microscope

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-microscope and add RNMicroscope.xcodeproj
  3. In XCode, in the project navigator, select your project. Add libRNMicroscope.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.reactlibrary.RNMicroscopePackage; to the imports at the top of the file
  • Add new RNMicroscopePackage() to the list returned by the getPackages() method
  1. Append the following lines to android/settings.gradle:
    include ':react-native-microscope'
    project(':react-native-microscope').projectDir = new File(rootProject.projectDir, 	'../node_modules/react-native-microscope/android')
    
  2. Insert the following lines inside the dependencies block in android/app/build.gradle:
      compile project(':react-native-microscope')
    

Usage

import RNMicroscopeView from "react-native-microscope";
 
return (
  <>
    <StatusBar barStyle="dark-content" />
    <View style={{ flex: 1 }}>
      <RNMicroscopeView
        style={{ flex: 1, width: "100%", height: "100%" }}
        onStartCapture={() => console.log("start")}
        onCaptureSuccess={uri => alert(uri)}
        onCaptureError={e => console.log(e)}
      />
    </View>
  </>
);
import RNMicroscopeView from "react-native-microscope";
 
return (
  <>
    <StatusBar barStyle="dark-content" />
    <View style={{ flex: 1 }}>
      <RNMicroscopeView
        ref={"microscope"}
        styleMicroscope={styles.microscope}
        buttonCaptureComponent={
          <TouchableOpacity onPress={() => this.refs.microscope._onCapture()}>
            <Text>Button custom</Text>
          </TouchableOpacity>
        }
        onStartCapture={() => console.log("start")}
        onCaptureSuccess={uri => alert(uri)}
        onCaptureError={e => console.log(e)}
      />
    </View>
  </>
);

Props

  • onStartCapture (Function) - return callback when start capture
  • onCaptureSuccess (Function) - return base64 or uri
  • onCaptureError (Function) - return error capture
  • style (Object) - style container
  • styleMicroscope (Object) - style camera view
  • buttonCaptureComponent (Component) - custom button capture (using this.refs.microscope._onCapture())
  • optionFormat (Object) - option format image, default is { format: "png", quality: 0.9 }

Package Sidebar

Install

npm i react-native-microscope

Weekly Downloads

134

Version

1.1.3

License

none

Unpacked Size

378 MB

Total Files

1849

Last publish

Collaborators

  • tranhanhieu