Skip to content

Commit aebf572

Browse files
authored
Merge pull request #6 from vemarav/fixes/issue-#3-#4
Fixes: Install dependencies with npm@7 & image pannning for unequal width, height
2 parents 8f4ef1b + e55befb commit aebf572

File tree

13 files changed

+13395
-496
lines changed

13 files changed

+13395
-496
lines changed

example/CropImage.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
2-
import {View, StyleSheet, TouchableOpacity, Text, Dimensions} from 'react-native';
2+
import {View, StyleSheet, TouchableOpacity, Text, Dimensions, ScrollView} from 'react-native';
33
import Routes from './Routes';
44
import Crop from 'react-native-avatar-crop';
55

@@ -42,9 +42,8 @@ const CropImage = ({route, navigation}: CropImageProps): JSX.Element => {
4242

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

45-
4645
return (
47-
<View style={styles.center}>
46+
<ScrollView contentContainerStyle={styles.center}>
4847
<Crop
4948
source={{uri}}
5049
width={SCREEN_WIDTH}
@@ -62,7 +61,7 @@ const CropImage = ({route, navigation}: CropImageProps): JSX.Element => {
6261
<Text style={styles.btnText}>Save Crop</Text>
6362
</View>
6463
</TouchableOpacity>
65-
</View>
64+
</ScrollView>
6665
);
6766
};
6867

example/CroppedImage.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,8 @@ type CroppedImageProps = {
1414

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

17-
const CroppedImage = ({route, navigation}: CroppedImageProps) => {
17+
const CroppedImage = ({route}: CroppedImageProps) => {
1818
const {uri, width, height} = route.params;
19-
const aspectRatio = getRatio({width, height});
2019
const styles = StyleSheet.create({
2120
center: {
2221
flex: 1,

example/PickImage.tsx

Lines changed: 47 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
11
import React, {useState} from 'react';
2-
import {StyleSheet, Text, TouchableOpacity, View, TextInput, Image, Dimensions, ScrollView} from 'react-native';
3-
import {Asset, ImagePickerResponse, launchImageLibrary} from 'react-native-image-picker';
2+
import {
3+
StyleSheet,
4+
Text,
5+
TouchableOpacity,
6+
View,
7+
TextInput,
8+
Image,
9+
Dimensions,
10+
ScrollView,
11+
} from 'react-native';
412
import Routes from './Routes';
13+
import ImagePicker from 'react-native-image-crop-picker';
514

615
const {width: SCREEN_WIDTH} = Dimensions.get('screen');
716

@@ -15,15 +24,17 @@ const PickImage = ({navigation}: PickImageProps): JSX.Element => {
1524
const [uri, setUri] = useState('');
1625

1726
const openImagePicker = () => {
18-
launchImageLibrary({mediaType: 'photo'}, ({assets}: ImagePickerResponse) => {
19-
if (assets) {
20-
onPickedImage(assets[0]);
21-
}
22-
});
27+
ImagePicker.openPicker({
28+
mediaType: 'photo',
29+
}).then(onPickedImage);
2330
};
2431

25-
const onPickedImage = (image: Asset) => {
26-
navigation.navigate(Routes.cropImage, image);
32+
const onPickedImage = (image: any) => {
33+
navigation.navigate(Routes.cropImage, {
34+
uri: image.sourceURL,
35+
width: image.width,
36+
height: image.height,
37+
});
2738
};
2839

2940
const cropNetworkImage = () => {
@@ -42,19 +53,42 @@ const PickImage = ({navigation}: PickImageProps): JSX.Element => {
4253
backgroundColor: '#cccccc',
4354
}}>
4455
{uri ? (
45-
<Image source={{uri}} style={{width: SCREEN_WIDTH, height: SCREEN_WIDTH, resizeMode: 'contain'}} />
56+
<Image
57+
source={{uri}}
58+
style={{
59+
width: SCREEN_WIDTH,
60+
height: SCREEN_WIDTH,
61+
resizeMode: 'contain',
62+
}}
63+
/>
4664
) : (
4765
<Text>after typing url, wait till image loads</Text>
4866
)}
4967
</View>
50-
<View style={{flexDirection: 'row', justifyContent: 'center', alignItems: 'center', paddingHorizontal: 30}}>
68+
<View
69+
style={{
70+
flexDirection: 'row',
71+
justifyContent: 'center',
72+
alignItems: 'center',
73+
paddingHorizontal: 30,
74+
}}>
5175
<TextInput
52-
style={{flex: 1, borderBottomWidth: 1, padding: 10, marginRight: 20, color: 'black'}}
76+
style={{
77+
flex: 1,
78+
borderBottomWidth: 1,
79+
padding: 10,
80+
marginRight: 20,
81+
color: 'black',
82+
}}
5383
onChangeText={setUri}
5484
placeholder={'paste image url'}
85+
autoCorrect={false}
86+
autoCapitalize={"none"}
87+
keyboardType={"url"}
5588
/>
5689
<TouchableOpacity onPress={cropNetworkImage}>
57-
<View style={{padding: 10, backgroundColor: '#0275d8', borderRadius: 4}}>
90+
<View
91+
style={{padding: 10, backgroundColor: '#0275d8', borderRadius: 4}}>
5892
<Text style={{color: 'white', fontWeight: '600'}}>Go</Text>
5993
</View>
6094
</TouchableOpacity>

example/ios/Example.xcodeproj/project.pbxproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -561,7 +561,7 @@
561561
COPY_PHASE_STRIP = NO;
562562
ENABLE_STRICT_OBJC_MSGSEND = YES;
563563
ENABLE_TESTABILITY = YES;
564-
"EXCLUDED_ARCHS[sdk=iphonesimulator*]" = "arm64 ";
564+
"EXCLUDED_ARCHS[sdk=iphonesimulator*]" = "";
565565
GCC_C_LANGUAGE_STANDARD = gnu99;
566566
GCC_DYNAMIC_NO_PIC = NO;
567567
GCC_NO_COMMON_BLOCKS = YES;
@@ -626,7 +626,7 @@
626626
COPY_PHASE_STRIP = YES;
627627
ENABLE_NS_ASSERTIONS = NO;
628628
ENABLE_STRICT_OBJC_MSGSEND = YES;
629-
"EXCLUDED_ARCHS[sdk=iphonesimulator*]" = "arm64 ";
629+
"EXCLUDED_ARCHS[sdk=iphonesimulator*]" = "";
630630
GCC_C_LANGUAGE_STANDARD = gnu99;
631631
GCC_NO_COMMON_BLOCKS = YES;
632632
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;

example/ios/Example/Info.plist

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,5 +51,13 @@
5151
</array>
5252
<key>UIViewControllerBasedStatusBarAppearance</key>
5353
<false/>
54+
<key>NSCameraUsageDescription</key>
55+
<string>$(PRODUCT_NAME) would like to access your camera or photo library to be used as an avatar in an event.</string>
56+
<key>NSLocalNetworkUsageDescription</key>
57+
<string>$(PRODUCT_NAME) would like to access local network discovery for finding nearby atom devices.</string>
58+
<key>NSLocationWhenInUseUsageDescription</key>
59+
<string>$(PRODUCT_NAME) would like to access location for local network discovery.</string>
60+
<key>NSPhotoLibraryUsageDescription</key>
61+
<string>$(PRODUCT_NAME) would like to access your camera or photo library to be used as an avatar in an event.</string>
5462
</dict>
5563
</plist>

example/ios/Podfile.lock

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -255,8 +255,6 @@ PODS:
255255
- react-native-image-editor (2.3.0):
256256
- React
257257
- React-RCTImage
258-
- react-native-image-picker (4.0.6):
259-
- React-Core
260258
- react-native-safe-area-context (3.2.0):
261259
- React-Core
262260
- React-perflogger (0.64.2)
@@ -327,6 +325,15 @@ PODS:
327325
- React
328326
- RNGestureHandler (1.10.3):
329327
- React-Core
328+
- RNImageCropPicker (0.36.2):
329+
- React-Core
330+
- React-RCTImage
331+
- RNImageCropPicker/QBImagePickerController (= 0.36.2)
332+
- TOCropViewController
333+
- RNImageCropPicker/QBImagePickerController (0.36.2):
334+
- React-Core
335+
- React-RCTImage
336+
- TOCropViewController
330337
- RNReanimated (2.2.0):
331338
- DoubleConversion
332339
- FBLazyVector
@@ -359,6 +366,7 @@ PODS:
359366
- RNScreens (3.4.0):
360367
- React-Core
361368
- React-RCTImage
369+
- TOCropViewController (2.6.0)
362370
- Yoga (1.14.0)
363371
- YogaKit (1.18.1):
364372
- Yoga (~> 1.14)
@@ -401,7 +409,6 @@ DEPENDENCIES:
401409
- React-jsiexecutor (from `../node_modules/react-native/ReactCommon/jsiexecutor`)
402410
- React-jsinspector (from `../node_modules/react-native/ReactCommon/jsinspector`)
403411
- "react-native-image-editor (from `../node_modules/@react-native-community/image-editor`)"
404-
- react-native-image-picker (from `../node_modules/react-native-image-picker`)
405412
- react-native-safe-area-context (from `../node_modules/react-native-safe-area-context`)
406413
- React-perflogger (from `../node_modules/react-native/ReactCommon/reactperflogger`)
407414
- React-RCTActionSheet (from `../node_modules/react-native/Libraries/ActionSheetIOS`)
@@ -417,6 +424,7 @@ DEPENDENCIES:
417424
- ReactCommon/turbomodule/core (from `../node_modules/react-native/ReactCommon`)
418425
- "RNCMaskedView (from `../node_modules/@react-native-community/masked-view`)"
419426
- RNGestureHandler (from `../node_modules/react-native-gesture-handler`)
427+
- RNImageCropPicker (from `../node_modules/react-native-image-crop-picker`)
420428
- RNReanimated (from `../node_modules/react-native-reanimated`)
421429
- RNScreens (from `../node_modules/react-native-screens`)
422430
- Yoga (from `../node_modules/react-native/ReactCommon/yoga`)
@@ -434,6 +442,7 @@ SPEC REPOS:
434442
- FlipperKit
435443
- libevent
436444
- OpenSSL-Universal
445+
- TOCropViewController
437446
- YogaKit
438447

439448
EXTERNAL SOURCES:
@@ -469,8 +478,6 @@ EXTERNAL SOURCES:
469478
:path: "../node_modules/react-native/ReactCommon/jsinspector"
470479
react-native-image-editor:
471480
:path: "../node_modules/@react-native-community/image-editor"
472-
react-native-image-picker:
473-
:path: "../node_modules/react-native-image-picker"
474481
react-native-safe-area-context:
475482
:path: "../node_modules/react-native-safe-area-context"
476483
React-perflogger:
@@ -501,6 +508,8 @@ EXTERNAL SOURCES:
501508
:path: "../node_modules/@react-native-community/masked-view"
502509
RNGestureHandler:
503510
:path: "../node_modules/react-native-gesture-handler"
511+
RNImageCropPicker:
512+
:path: "../node_modules/react-native-image-crop-picker"
504513
RNReanimated:
505514
:path: "../node_modules/react-native-reanimated"
506515
RNScreens:
@@ -513,7 +522,7 @@ SPEC CHECKSUMS:
513522
CocoaAsyncSocket: 065fd1e645c7abab64f7a6a2007a48038fdc6a99
514523
DoubleConversion: cf9b38bf0b2d048436d9a82ad2abe1404f11e7de
515524
FBLazyVector: e686045572151edef46010a6f819ade377dfeb4b
516-
FBReactNativeSpec: e5f8db2cdc4e29fa726e78d31456fb6d2b605ccc
525+
FBReactNativeSpec: c4a108970fc6d9c3463a5115eba221e386cbae80
517526
Flipper: d3da1aa199aad94455ae725e9f3aa43f3ec17021
518527
Flipper-DoubleConversion: 38631e41ef4f9b12861c67d17cb5518d06badc41
519528
Flipper-Folly: 755929a4f851b2fb2c347d533a23f191b008554c
@@ -536,7 +545,6 @@ SPEC CHECKSUMS:
536545
React-jsiexecutor: 80c46bd381fd06e418e0d4f53672dc1d1945c4c3
537546
React-jsinspector: cc614ec18a9ca96fd275100c16d74d62ee11f0ae
538547
react-native-image-editor: 9361a215c3991cafbe5e7f28cbbad6e72c9c2705
539-
react-native-image-picker: a6e56460d34905c849ada551db30897dc7f3d535
540548
react-native-safe-area-context: f0906bf8bc9835ac9a9d3f97e8bde2a997d8da79
541549
React-perflogger: 25373e382fed75ce768a443822f07098a15ab737
542550
React-RCTActionSheet: af7796ba49ffe4ca92e7277a5d992d37203f7da5
@@ -552,11 +560,13 @@ SPEC CHECKSUMS:
552560
ReactCommon: 149906e01aa51142707a10665185db879898e966
553561
RNCMaskedView: 0e1bc4bfa8365eba5fbbb71e07fbdc0555249489
554562
RNGestureHandler: a479ebd5ed4221a810967000735517df0d2db211
563+
RNImageCropPicker: 35a3ceb837446fa11547704709bb22b5fac6d584
555564
RNReanimated: 9c13c86454bfd54dab7505c1a054470bfecd2563
556565
RNScreens: 21b73c94c9117e1110a79ee0ee80c93ccefed8ce
566+
TOCropViewController: 3105367e808b7d3d886a74ff59bf4804e7d3ab38
557567
Yoga: 575c581c63e0d35c9a83f4b46d01d63abc1100ac
558568
YogaKit: f782866e155069a2cca2517aafea43200b01fd5a
559569

560570
PODFILE CHECKSUM: d24bf39ea41186607a7a2d6f21b4ffb7c434338e
561571

562-
COCOAPODS: 1.10.1
572+
COCOAPODS: 1.10.2

example/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717
"@react-navigation/stack": "^5.14.5",
1818
"react": "17.0.1",
1919
"react-native": "0.64.2",
20-
"react-native-avatar-crop": "0.0.7",
20+
"react-native-avatar-crop": "1.1.1",
2121
"react-native-gesture-handler": "^1.10.3",
22-
"react-native-image-picker": "^4.0.6",
22+
"react-native-image-crop-picker": "^0.36.2",
2323
"react-native-image-size": "^1.1.3",
2424
"react-native-reanimated": "^2.2.0",
2525
"react-native-safe-area-context": "^3.2.0",

example/yarn.lock

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1173,11 +1173,15 @@
11731173
resolved "https://registry.yarnpkg.com/@react-native-community/eslint-plugin/-/eslint-plugin-1.1.0.tgz#e42b1bef12d2415411519fd528e64b593b1363dc"
11741174
integrity sha512-W/J0fNYVO01tioHjvYWQ9m6RgndVtbElzYozBq1ZPrHO/iCzlqoySHl4gO/fpCl9QEFjvJfjPgtPMTMlsoq5DQ==
11751175

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

1181+
"@react-native-community/image-editor@git+https://github.com/vemarav/react-native-image-editor.git":
1182+
version "2.3.0"
1183+
resolved "git+https://github.com/vemarav/react-native-image-editor.git#081db98b4c9b70d86247cbbd0b5ce916aa97ce64"
1184+
11811185
"@react-native-community/masked-view@*", "@react-native-community/masked-view@^0.1.11":
11821186
version "0.1.11"
11831187
resolved "https://registry.yarnpkg.com/@react-native-community/masked-view/-/masked-view-0.1.11.tgz#2f4c6e10bee0786abff4604e39a37ded6f3980ce"
@@ -5601,12 +5605,12 @@ react-is@^16.13.0, react-is@^16.7.0, react-is@^16.8.1:
56015605
resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.13.1.tgz#789729a4dc36de2999dc156dd6c1d9c18cea56a4"
56025606
integrity sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==
56035607

5604-
react-native-avatar-crop@0.0.7:
5605-
version "0.0.7"
5606-
resolved "https://registry.yarnpkg.com/react-native-avatar-crop/-/react-native-avatar-crop-0.0.7.tgz#58d7ba58755ca5a8715afeb3f97ced78c252753e"
5607-
integrity sha512-nmssr8mOxJo7BDXD8E/8ZM0BTfsTmZ15mypHDiaeeAUtNUxpuWvmxYrbqU3fOtYwnf8Om6S5FbURRe5wlMHm6g==
5608+
react-native-avatar-crop@1.1.1:
5609+
version "1.1.1"
5610+
resolved "https://registry.yarnpkg.com/react-native-avatar-crop/-/react-native-avatar-crop-1.1.1.tgz#5ce2ea0c7c44a2bb30f58815380e23a97bc28bc3"
5611+
integrity sha512-Jbtutzj1Zk+4nLH9ieiozChK8GUeBeGw4UEJJH87OxhlOvYixeFUWOrombCTQFKKrq+q4kbo+THOMcxSteWAMg==
56085612
dependencies:
5609-
"@react-native-community/image-editor" "*"
5613+
"@react-native-community/image-editor" "https://github.com/vemarav/react-native-image-editor"
56105614
"@react-native-community/masked-view" "*"
56115615
react-native-gesture-handler "*"
56125616
react-native-image-size "*"
@@ -5631,10 +5635,10 @@ react-native-gesture-handler@*, react-native-gesture-handler@^1.10.3:
56315635
invariant "^2.2.4"
56325636
prop-types "^15.7.2"
56335637

5634-
react-native-image-picker@^4.0.6:
5635-
version "4.0.6"
5636-
resolved "https://registry.yarnpkg.com/react-native-image-picker/-/react-native-image-picker-4.0.6.tgz#0dfa5bb83bcf6ff58635ebb9201a185c2271e8cc"
5637-
integrity sha512-Pp3UWKUADuMG1mz12m6dSO/R2KnvXVEd77bldrfTMFpz4PFc4iVKo+bHeS79It0mUBezfzDMgfesg/OPLSugvQ==
5638+
react-native-image-crop-picker@^0.36.2:
5639+
version "0.36.2"
5640+
resolved "https://registry.yarnpkg.com/react-native-image-crop-picker/-/react-native-image-crop-picker-0.36.2.tgz#fcb35c1a12d805bedbb6d94a87078e86a6c9b49f"
5641+
integrity sha512-cTauoEHHzx14ZHA7Pt65e7RVnbn1WRYQz2ufTZp9/05EtNDrdsXwNhgtXdWVFbOhYB8qgUFQjy2NelkBOHIH3g==
56385642

56395643
react-native-image-size@*, react-native-image-size@^1.1.3:
56405644
version "1.1.3"

package/README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# react-native-avatar-crop
22

3-
⚠️ WARNING: The package is in development and may have bugs apart from what is shown in the demo.
4-
53
Supports rect and circle cropping. Use `cropArea={{width, height}}` for custom aspect ratio.
64

75
Download apk to see it in action, [click to download](https://github.com/vemarav/react-native-avatar-crop/releases/download/v1.0.5/app-release.apk)

0 commit comments

Comments
 (0)