Skip to content

Commit

Permalink
new: BREAKING CHANGES for pressable props and upgraded dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
WrathChaos committed Jun 22, 2021
1 parent 96eb4f2 commit e8179a4
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 25 deletions.
25 changes: 22 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
<key>NSCameraUsageDescription</key>
<string>This allows us to capture and use the the captured photo</string>
<key>NSPhotoLibraryAddUsageDescription</key>
<string>This allows us to show/pick a photo from your library</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>This allows us to show/pick a photo from your library</string>
```

### Android

```xml
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
```

# Usage

## Import
Expand Down Expand Up @@ -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 |
Expand Down
20 changes: 10 additions & 10 deletions lib/MediaPicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 {}
Expand All @@ -53,12 +53,12 @@ export default class MediaPicker extends React.Component<IProps, IState> {
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,
Expand Down Expand Up @@ -98,22 +98,22 @@ export default class MediaPicker extends React.Component<IProps, IState> {
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)
);
};

handleGalleryPressed = () => {
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)
);
};

Expand Down
13 changes: 1 addition & 12 deletions package.json
Original file line number Diff line number Diff line change
@@ -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": "[email protected]:WrathChaos/@paraboly/react-native-media-picker.git",
Expand All @@ -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",
Expand Down

0 comments on commit e8179a4

Please sign in to comment.