Skip to content

Commit 90e002c

Browse files
author
Alexis Mangin
committed
Initial commit
0 parents  commit 90e002c

File tree

5 files changed

+547
-0
lines changed

5 files changed

+547
-0
lines changed

.eslintrc

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"parser": "babel-eslint",
3+
"env": {
4+
"browser": false,
5+
"node": true,
6+
"es6": true
7+
},
8+
"plugins": [
9+
"react",
10+
"react-native"
11+
],
12+
"extends": "airbnb",
13+
14+
"rules": {
15+
"indent": [2, "tab", {"SwitchCase": 1}],
16+
"react/jsx-filename-extension": [1, { "extensions": [".js", ".jsx"] }],
17+
"no-else-return": 0,
18+
"consistent-return": 0,
19+
"react/jsx-indent": [2, 'tab'],
20+
"react/jsx-indent-props": [2, 'tab']
21+
}
22+
}

.gitignore

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# OSX
2+
#
3+
.DS_Store
4+
5+
# Xcode
6+
#
7+
build/
8+
*.pbxuser
9+
!default.pbxuser
10+
*.mode1v3
11+
!default.mode1v3
12+
*.mode2v3
13+
!default.mode2v3
14+
*.perspectivev3
15+
!default.perspectivev3
16+
xcuserdata
17+
*.xccheckout
18+
*.moved-aside
19+
DerivedData
20+
*.hmap
21+
*.ipa
22+
*.xcuserstate
23+
project.xcworkspace
24+
25+
# Android/IJ
26+
#
27+
*.iml
28+
.idea
29+
.gradle
30+
local.properties
31+
32+
# node.js
33+
#
34+
node_modules/
35+
npm-debug.log
36+
37+
# BUCK
38+
buck-out/
39+
\.buckd/
40+
android/app/libs
41+
android/keystores/debug.keystore

README.md

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# react-native-image-crop
2+
3+
Image crop editor component for iOS and Android
4+
5+
## Usage
6+
7+
Install the Component
8+
9+
```
10+
npm install react-native-image-crop
11+
```
12+
13+
Import it
14+
15+
```js
16+
import ImageCrop from 'react-native-image-crop';
17+
```
18+
19+
Use the component directly in your code. The component will automatically fit the parent view.
20+
21+
```jsx
22+
<View>
23+
<ImageCrop
24+
ref={(c) => { this.imageCrop = c; }}
25+
cropWidth={500}
26+
cropHeight={500}
27+
image={{
28+
uri: 'https://c1.staticflickr.com/9/8073/28582653114_d154039cb9_k.jpg',
29+
}}
30+
/>
31+
</View>
32+
```
33+
34+
To crop the image, you can call the method `crop()` from the component
35+
36+
```js
37+
onButtonPress() {
38+
this.imageCrop.crop().then((uri) => {
39+
// uri contains the cropped image
40+
});
41+
}
42+
```
43+
44+
45+
## Properties
46+
47+
| Property | Type | Description |
48+
|--- |--- |--- |
49+
| `image`| ImageSource <br>https://facebook.github.io/react-native/docs/image.html#source | Source of the image. <br> This property is mandatory |
50+
| `containerPaddingLeft` | Number | Apply padding on the left of the image <br> Default: 20 |
51+
| `containerPaddingRight` | Number | Apply padding on the right of the image <br> Default: 20 |
52+
| `containerPaddingTop` | Number | Apply padding at the top of the image <br> Default: 20 |
53+
| `containerPaddingBottom` | Number | Apply padding at the bottom of the image <br> Default: 20 |
54+
| `cropWidth` | Number | Enforce the cropped width of the image. This property must be used with `cropHeight` |
55+
| `cropHeight` | Number | Enforce the cropped height of the image. This property must be used with `cropWidth` |
56+
57+
58+
## Methods
59+
60+
| Method | Description | Example |
61+
|--- |--- |--- |
62+
| `crop()` | Crop and, if necessary, resize the image. This method returns a Promise. | `this.imageCrop.crop().then((uri) => { this.setState({ uri })})` |

0 commit comments

Comments
 (0)