Skip to content

Commit

Permalink
Merge pull request #1 from vemarav/fix-android
Browse files Browse the repository at this point in the history
Fix android
  • Loading branch information
vemarav committed Aug 2, 2021
2 parents 54d2822 + 1c091b6 commit b7a61cd
Show file tree
Hide file tree
Showing 15 changed files with 672 additions and 230 deletions.
24 changes: 24 additions & 0 deletions .github/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
name: Bug report
about: Create a report to help us improve
---

**Describe the bug**

A clear and concise description of what the bug is.

**To Reproduce**

Steps to reproduce the behavior:

**Expected behavior**

A clear and concise description of what you expected to happen.

**Screenshots**

If applicable, add screenshots to help explain your problem.

**Additional context**

Add any other context about the problem here.
20 changes: 20 additions & 0 deletions .github/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
name: Feature request
about: Suggest an idea for this project
---

**Is your feature request related to a problem? Please describe.**

A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

**Describe the solution you'd like**

A clear and concise description of what you want to happen.

**Describe alternatives you've considered**

A clear and concise description of any alternative solutions or features you've considered.

**Additional context**

Add any other context or screenshots about the feature request here.
23 changes: 23 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
MIT License

Copyright (c) 2018 - present Aravind Vemula

All rights reserved.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
72 changes: 71 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,71 @@
# react-native-avatar-crop
# react-native-avatar-crop

## Demo

<br>

![video](/screenshots/demo.gif)

## Usage

check [dependencies](https://www.npmjs.com/package/react-native-avatar-crop?activeTab=dependencies)

```
let crop;
const {width: SCREEN_WIDTH} = Dimensions.get('window');
<Crop
source={uri}
cropShape={"circle"} // rect || circle
width={SCREEN_WIDTH}
height={SCREEN_WIDTH}
cropArea={{
width: SCREEN_WIDTH / 1.3,
height: SCREEN_WIDTH / 1.3,
}}
borderWidth={0}
backgroundColor={'#FFFFFF'}
opacity={0.7} // 0 till 1, default is 0.7
maxZoom= {3} // default 3
resizeMode={"contain"} // default "cover"
onCrop={cropCallback => (crop = cropCallback)} // returns a function
/>
```

see full example [here](https://github.com/vemarav/react-native-avatar-crop/blob/main/example/CropImage.tsx)

## CONTRIBUTING

1. Whether you are a novice or experienced software developer, all contributions and suggestions are welcome!

Clone repo

git clone https://github.com/vemarav/react-native-avatar-crop.git
2. Add features or bug fixes

3. Make a Pull Request

OR

Report a bug [here](https://github.com/vemarav/react-native-avatar-crop/issues/new/choose)

Feel free to contribute, hosted on 鉂わ笍 with Github.

## LICENSE

Package published under [MIT License](https://github.com/vemarav/subdomains/blob/master/LICENSE)

## Author

- [Aravind Vemula](https://github.com/vemarav)

## LIKED IT

Please use following button to star the, so it can reach others too

[![](https://img.shields.io/github/stars/vemarav/react-native-avatar-crop.svg?label=Stars&style=social)](https://github.com/vemarav/react-native-avatar-crop)


## SOCIAL

[![Twitter Follow](https://img.shields.io/twitter/follow/vemarav.svg?style=social&label=Follow)](https://twitter.com/vemarav)
1 change: 1 addition & 0 deletions example/.prettierrc.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
module.exports = {
printWidth: 120,
bracketSpacing: false,
jsxBracketSameLine: true,
singleQuote: true,
Expand Down
18 changes: 7 additions & 11 deletions example/CropImage.tsx
Original file line number Diff line number Diff line change
@@ -1,25 +1,20 @@
import React from 'react';
import {
View,
StyleSheet,
TouchableOpacity,
Text,
Dimensions,
} from 'react-native';
import {View, StyleSheet, TouchableOpacity, Text, Dimensions} from 'react-native';
import Routes from './Routes';
import Crop from './src';
import Crop from 'react-native-avatar-crop';

const {width: SCREEN_WIDTH} = Dimensions.get('window');

type CropImageProps = {
route: {params: {uri: string; width: number; height: number}};
navigation: {
navigate: (name: string, params?: {[key: string]: any}) => {};
navigate: (name: string, params?: {[key: string]: string | number}) => {};
};
};

const CropImage = ({route, navigation}: CropImageProps): JSX.Element => {
const {uri, width, height} = route.params;
const {uri} = route.params;

const styles = StyleSheet.create({
center: {
flex: 1,
Expand All @@ -44,13 +39,14 @@ const CropImage = ({route, navigation}: CropImageProps): JSX.Element => {
padding: 20,
},
});

let crop = async (quality?: number) => ({uri: '', width: 0, height: 0});


return (
<View style={styles.center}>
<Crop
source={{uri}}
imageSize={{width, height}}
width={SCREEN_WIDTH}
height={SCREEN_WIDTH}
cropArea={{width: SCREEN_WIDTH / 1.3, height: SCREEN_WIDTH / 1.3}}
Expand Down
9 changes: 1 addition & 8 deletions example/CroppedImage.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
import React from 'react';
import {
View,
Dimensions,
Image,
StyleSheet,
TouchableOpacity,
Text,
} from 'react-native';
import {View, Dimensions, Image, StyleSheet, TouchableOpacity, Text} from 'react-native';

export const getRatio = ({width, height}: {width: number; height: number}) =>
Math.max(width, height) / Math.min(width, height);
Expand Down
2 changes: 1 addition & 1 deletion example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"@react-navigation/stack": "^5.14.5",
"react": "17.0.1",
"react-native": "0.64.2",
"react-native-avatar-crop": "^0.0.6",
"react-native-avatar-crop": "0.0.7",
"react-native-gesture-handler": "^1.10.3",
"react-native-image-picker": "^4.0.6",
"react-native-image-size": "^1.1.3",
Expand Down
21 changes: 13 additions & 8 deletions example/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1173,12 +1173,12 @@
resolved "https://registry.yarnpkg.com/@react-native-community/eslint-plugin/-/eslint-plugin-1.1.0.tgz#e42b1bef12d2415411519fd528e64b593b1363dc"
integrity sha512-W/J0fNYVO01tioHjvYWQ9m6RgndVtbElzYozBq1ZPrHO/iCzlqoySHl4gO/fpCl9QEFjvJfjPgtPMTMlsoq5DQ==

"@react-native-community/image-editor@^2.3.0":
"@react-native-community/image-editor@*", "@react-native-community/image-editor@^2.3.0":
version "2.3.0"
resolved "https://registry.yarnpkg.com/@react-native-community/image-editor/-/image-editor-2.3.0.tgz#8ac6c3691fd2c762d2abeb84c01a3b201bac3b1e"
integrity sha512-+UJY8WkTkfSkjoU5blQnEI7tTg11jJLoM+YojjiQpEopUaRlYQU4SZ9Zd6F6wWfvc9bjvIeMY6FlKuESK/q4fQ==

"@react-native-community/masked-view@^0.1.11":
"@react-native-community/masked-view@*", "@react-native-community/masked-view@^0.1.11":
version "0.1.11"
resolved "https://registry.yarnpkg.com/@react-native-community/masked-view/-/masked-view-0.1.11.tgz#2f4c6e10bee0786abff4604e39a37ded6f3980ce"
integrity sha512-rQfMIGSR/1r/SyN87+VD8xHHzDYeHaJq6elOSCAD+0iLagXkSI2pfA0LmSXP21uw5i3em7GkkRjfJ8wpqWXZNw==
Expand Down Expand Up @@ -5601,10 +5601,15 @@ react-is@^16.13.0, react-is@^16.7.0, react-is@^16.8.1:
resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.13.1.tgz#789729a4dc36de2999dc156dd6c1d9c18cea56a4"
integrity sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==

react-native-avatar-crop@^0.0.6:
version "0.0.6"
resolved "https://registry.yarnpkg.com/react-native-avatar-crop/-/react-native-avatar-crop-0.0.6.tgz#d8ab66db5015af950a37c4e46f62756a3e5283b0"
integrity sha512-ploV7UtMp0BfEs3meKloBeuGRd+VeX0PTOMtaH/s8TDIwhOeGD0zT/Go6VvkrIIUDKrwR8W26wbCk9/O5+rb3Q==
[email protected]:
version "0.0.7"
resolved "https://registry.yarnpkg.com/react-native-avatar-crop/-/react-native-avatar-crop-0.0.7.tgz#58d7ba58755ca5a8715afeb3f97ced78c252753e"
integrity sha512-nmssr8mOxJo7BDXD8E/8ZM0BTfsTmZ15mypHDiaeeAUtNUxpuWvmxYrbqU3fOtYwnf8Om6S5FbURRe5wlMHm6g==
dependencies:
"@react-native-community/image-editor" "*"
"@react-native-community/masked-view" "*"
react-native-gesture-handler "*"
react-native-image-size "*"

react-native-codegen@^0.0.6:
version "0.0.6"
Expand All @@ -5615,7 +5620,7 @@ react-native-codegen@^0.0.6:
jscodeshift "^0.11.0"
nullthrows "^1.1.1"

react-native-gesture-handler@^1.10.3:
react-native-gesture-handler@*, react-native-gesture-handler@^1.10.3:
version "1.10.3"
resolved "https://registry.yarnpkg.com/react-native-gesture-handler/-/react-native-gesture-handler-1.10.3.tgz#942bbf2963bbf49fa79593600ee9d7b5dab3cfc0"
integrity sha512-cBGMi1IEsIVMgoox4RvMx7V2r6bNKw0uR1Mu1o7NbuHS6BRSVLq0dP34l2ecnPlC+jpWd3le6Yg1nrdCjby2Mw==
Expand All @@ -5631,7 +5636,7 @@ react-native-image-picker@^4.0.6:
resolved "https://registry.yarnpkg.com/react-native-image-picker/-/react-native-image-picker-4.0.6.tgz#0dfa5bb83bcf6ff58635ebb9201a185c2271e8cc"
integrity sha512-Pp3UWKUADuMG1mz12m6dSO/R2KnvXVEd77bldrfTMFpz4PFc4iVKo+bHeS79It0mUBezfzDMgfesg/OPLSugvQ==

react-native-image-size@^1.1.3:
react-native-image-size@*, react-native-image-size@^1.1.3:
version "1.1.3"
resolved "https://registry.yarnpkg.com/react-native-image-size/-/react-native-image-size-1.1.3.tgz#7d69c2cd4e1d1632947867e47643ed8cabb9de27"
integrity sha512-jJvN6CjXVAm69LAVZNV7m7r50Qk9vuPZwLyrbs/k31/3Xs8bZyVCdvfP44FuBisITn/yFsiOo6i8NPrFBPH20w==
Expand Down
70 changes: 69 additions & 1 deletion package/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,71 @@
# react-native-avatar-crop

TODO: Add readme
## Demo

<br>

![video](/screenshots/demo.gif)

## Usage

check [dependencies](https://www.npmjs.com/package/react-native-avatar-crop?activeTab=dependencies)

```
let crop;
const {width: SCREEN_WIDTH} = Dimensions.get('window');
<Crop
source={uri}
cropShape={"circle"} // rect || circle
width={SCREEN_WIDTH}
height={SCREEN_WIDTH}
cropArea={{
width: SCREEN_WIDTH / 1.3,
height: SCREEN_WIDTH / 1.3,
}}
borderWidth={0}
backgroundColor={'#FFFFFF'}
opacity={0.7} // 0 till 1, default is 0.7
maxZoom= {3} // default 3
resizeMode={"contain"} // default "cover"
onCrop={cropCallback => (crop = cropCallback)} // returns a function
/>
```

see full example [here](https://github.com/vemarav/react-native-avatar-crop/blob/main/example/CropImage.tsx)

## CONTRIBUTING

1. Whether you are a novice or experienced software developer, all contributions and suggestions are welcome!

Clone repo

git clone https://github.com/vemarav/react-native-avatar-crop.git

2. Add features or bug fixes

3. Make a Pull Request

OR

Report a bug [here](https://github.com/vemarav/react-native-avatar-crop/issues/new/choose)

Feel free to contribute, hosted on 鉂わ笍 with Github.

## LICENSE

Package published under [MIT License](https://github.com/vemarav/subdomains/blob/master/LICENSE)

## Author

- [Aravind Vemula](https://github.com/vemarav)

## LIKED IT

Please use following button to star the, so it can reach others too

[![](https://img.shields.io/github/stars/vemarav/react-native-avatar-crop.svg?label=Stars&style=social)](https://github.com/vemarav/react-native-avatar-crop)

## SOCIAL

[![Twitter Follow](https://img.shields.io/twitter/follow/vemarav.svg?style=social&label=Follow)](https://twitter.com/vemarav)
Loading

0 comments on commit b7a61cd

Please sign in to comment.