diff --git a/README.md b/README.md index 2d0b6fb..ac16b8f 100644 --- a/README.md +++ b/README.md @@ -31,13 +31,32 @@ npm i @paraboly/react-native-media-picker ```js "@freakycoder/react-native-helpers": ">= 0.1.2", -"react-native-gesture-handler": ">= 1.5.3", "react-native-image-crop-picker": ">= 0.26.2", "react-native-modalize": ">= 2.0.0", "react-native-vector-icons": ">= 6.6.0", "react-native-dynamic-vector-icons": ">= 0.2.1", ``` +## iOS & Android Permissions + +### iOS + +```plist +NSCameraUsageDescription +This allows us to capture and use the the captured photo +NSPhotoLibraryAddUsageDescription +This allows us to show/pick a photo from your library +NSPhotoLibraryUsageDescription +This allows us to show/pick a photo from your library +``` + +### Android + +```xml + + +``` + # Usage ## Import @@ -111,8 +130,8 @@ this.mediaPicker.closeModal(); | cameraText | string | Camera | change the camera button's text | | galleryText | string | Gallery | change the gallery button's text | | backgroundColor | color | #90a1fc | change the modal's background color | -| cameraOnPress | function | default | set your own logic when camera is on pressed **(please check the example)** | -| galleryOnPress | function | default | set your own logic when gallery is on pressed **(please check the example)** | +| onCameraPress | function | default | set your own logic when camera is on pressed **(please check the example)** | +| onGalleryPress | function | default | set your own logic when gallery is on pressed **(please check the example)** | | cameraIconName | string | camera | change the camera's icon name | | cameraIconType | string | FontAwesome | change the camera's icon type | | cameraIconColor | color | #fdfdfd | change the camera's icon color | diff --git a/lib/MediaPicker.tsx b/lib/MediaPicker.tsx index f5ca1e8..d84e355 100644 --- a/lib/MediaPicker.tsx +++ b/lib/MediaPicker.tsx @@ -12,8 +12,6 @@ import { isIPhoneXFamily } from "@freakycoder/react-native-helpers"; import ImagePicker, { Image } from "react-native-image-crop-picker"; export interface IProps { - cameraOnPress?: (image: Image | Image[]) => void; - galleryOnPress?: (images: Image | Image[]) => void; IconComponent: any; multiple: boolean; cameraText: string; @@ -31,9 +29,11 @@ export interface IProps { cameraButtonSize: number; galleryIconColor: string; galleryButtonSize: number; + compressImageQuality: number; cameraButtonBackgroundColor: string; galleryButtonBackgroundColor: string; - compressImageQuality: number; + onCameraPress?: (image: Image | Image[]) => void; + onGalleryPress?: (images: Image | Image[]) => void; } interface IState {} @@ -53,12 +53,12 @@ export default class MediaPicker extends React.Component { cameraIconName: "camera", cameraIconColor: "#90a1fc", backgroundColor: "#90a1fc", + cameraIconType: "FontAwesome", cameraTextColor: "#fdfdfd", - galleryIconType: "Ionicons", galleryIconColor: "#90a1fc", galleryTextColor: "#fdfdfd", - galleryIconName: "md-photos", - cameraIconType: "FontAwesome", + galleryIconType: "MaterialIcons", + galleryIconName: "photo-size-select-actual", cameraButtonBackgroundColor: "#fdfdfd", galleryButtonBackgroundColor: "#fdfdfd", compressImageQuality: 0.8, @@ -98,10 +98,10 @@ export default class MediaPicker extends React.Component { this.openCamera() .then( (image: any) => - this.props.cameraOnPress && this.props.cameraOnPress(image) + this.props.onCameraPress && this.props.onCameraPress(image) ) .catch( - (err: any) => this.props.cameraOnPress && this.props.cameraOnPress(err) + (err: any) => this.props.onCameraPress && this.props.onCameraPress(err) ); }; @@ -109,11 +109,11 @@ export default class MediaPicker extends React.Component { this.openGallery() .then( (images: any) => - this.props.galleryOnPress && this.props.galleryOnPress(images) + this.props.onGalleryPress && this.props.onGalleryPress(images) ) .catch( (err: any) => - this.props.galleryOnPress && this.props.galleryOnPress(err) + this.props.onGalleryPress && this.props.onGalleryPress(err) ); }; diff --git a/package.json b/package.json index b1ae34a..d5eff82 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@paraboly/react-native-media-picker", - "version": "0.1.0", + "version": "0.2.0", "description": "Easy to use media picker modal for React Native by Paraboly", "main": "./build/dist/MediaPicker.js", "repository": "git@github.com:WrathChaos/@paraboly/react-native-media-picker.git", @@ -27,17 +27,6 @@ "version": "npm run format && git add -A src", "postversion": "git push && git push --tags" }, - "dependencies": { - "@freakycoder/react-native-helpers": "^0.1.2", - "react": "16.9.0", - "react-native": "0.61.5", - "react-native-dynamic-vector-icons": "^0.2.1", - "react-native-gesture-handler": "^1.5.3", - "react-native-image-crop-picker": "^0.26.2", - "react-native-modalize": "^1.3.6", - "react-native-reanimated": "^1.4.0", - "react-native-vector-icons": "^6.6.0" - }, "peerDependencies": { "react": ">= 16.x.x", "react-native": ">= 0.55.x",