1.0.5 • Published 6 years ago

react-native-choose-image-button v1.0.5

Weekly downloads
4
License
MIT
Repository
-
Last release
6 years ago

React Native Choose Image Button

  • React Native wrappable component
  • Choose image or take photo, the resultant image is then passed to a callback you provide
  • Optional styles can be passed via props

Getting Started

Installation

npm install react-native-choose-image-button --save

Example

This library uses the @expo/react-native-action-sheet dependency so first wrap your app with the ActionSheetProvider class which serves as a container for calling the native action popup that shows the options 'Take photo', 'Choose Image' etc...

import { ActionSheetProvider, connectActionSheet } from '@expo/react-native-action-sheet';

export default class App extends React.Component {
  render() {
    return (
      <ActionSheetProvider>
        <RootApp />
      </ActionSheetProvider>
    );
  }
}

Then wrap your target button with the choose image button:

import Icon from 'react-native-vector-icons/Ionicons';
import ChooseImageButton from 'react-native-choose-image-button';

const UploadButton = () => {

    return(
        <ChooseImageButton
        onLoading={someFunction}
        onComplete={someFunction}
        style={someStyle}>
            <Icon name="ios-add"/>
        </ChooseImageButton>
    );

}

Props

PropDescription
styleAn style object to apply styles to the component
onLoadingThe function that is called when the image is buffering and loading
onCompleteThe function that receives the resultant base64 image