Skip to content

Commit

Permalink
feat: capturePhotoOptions and libraryPhotoOptions props are available
Browse files Browse the repository at this point in the history
  • Loading branch information
WrathChaos committed Jan 26, 2022
1 parent 08d6fa2 commit 168410e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ should work of the example project.
| actionButtonUnderlayColor | string | rgba(0,0,0,0.3) | change the action button's underlay color |
| cancelButtonUnderlayColor | string | rgba(200,200,200,0.1) | change the cancel button's underlay color |
| includeBase64 | boolean | false | when you need `base64` |
| capturePhotoOptions | CameraOptions | default | override the options for capturing the photo |
| libraryPhotoOptions | ImageLibraryOptions | default | override the options for picking images from library |

## Future Plans

Expand Down
10 changes: 8 additions & 2 deletions lib/ImagePickerModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import PickerModal, {
IPickerModalProps,
} from "@freakycoder/react-native-picker-modal";
import {
CameraOptions,
ImageLibraryOptions,
launchCamera,
launchImageLibrary,
MediaType,
Expand All @@ -19,13 +21,17 @@ interface IImagePickerModalProps extends IPickerModalProps {
isVisible: boolean;
data: string[];
includeBase64?: boolean;
capturePhotoOptions?: CameraOptions;
libraryPhotoOptions?: ImageLibraryOptions;
onPress: (item: any) => void;
}

const ImagePickerModal: React.FC<IImagePickerModalProps> = ({
isVisible,
data,
onPress,
capturePhotoOptions,
libraryPhotoOptions,
includeBase64 = false,
...rest
}) => {
Expand All @@ -37,7 +43,7 @@ const ImagePickerModal: React.FC<IImagePickerModalProps> = ({
includeBase64: includeBase64,
includeExtra: true,
};
const result = await launchCamera(options);
const result = await launchCamera(capturePhotoOptions || options);
onPress && onPress(result);
} else if (selectedItem === data[1]) {
const options = {
Expand All @@ -46,7 +52,7 @@ const ImagePickerModal: React.FC<IImagePickerModalProps> = ({
includeBase64: includeBase64,
includeExtra: true,
};
const result = await launchImageLibrary(options);
const result = await launchImageLibrary(libraryPhotoOptions || options);
onPress && onPress(result);
}
};
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-native-image-picker-modal",
"version": "0.1.2",
"version": "0.1.3",
"description": "Easy to use image picker modal with awesome iOS Picker design for React Native",
"main": "./build/dist/ImagePickerModal.js",
"repository": "git@github.com:WrathChaos/react-native-image-picker-modal.git",
Expand Down

0 comments on commit 168410e

Please sign in to comment.