react-native-customizable-image-crop-picker 1.0.6 → 1.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +161 -69
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -43,52 +43,24 @@ iOS/Android image picker + cropper with support for **camera**, **gallery**, opt
43
43
 
44
44
  ## Demo
45
45
 
46
- **Android**
47
-
48
- </br></br>
49
- <p>
50
- <img src="https://github.com/amitkumarcoding/imagecroppicker/blob/main/images/1.png" alt="Android demo" width="320" />
51
- </p>
52
- </br>
53
- <p>
54
- <img src="https://github.com/amitkumarcoding/imagecroppicker/blob/main/images/2.png" alt="Android demo" width="320" />
55
- </p>
56
- </br>
57
- <p>
58
- <img src="https://github.com/amitkumarcoding/imagecroppicker/blob/main/images/3.png" alt="Android demo" width="320" />
59
- </p>
60
- </br>
61
- <p>
62
- <img src="https://github.com/amitkumarcoding/imagecroppicker/blob/main/images/4.png" alt="Android demo" width="320" />
63
- </p>
64
- </br>
65
- </br>
66
-
67
- **iOS**
68
-
69
- </br>
70
- </br>
71
- <p>
72
- <img src="https://github.com/amitkumarcoding/imagecroppicker/blob/main/images/5.png" alt="iOS demo" width="320" />
73
- </p>
74
- </br>
75
- <p>
76
- <img src="https://github.com/amitkumarcoding/imagecroppicker/blob/main/images/6.png" alt="iOS demo" width="320" />
77
- </p>
78
- </br>
79
- <p>
80
- <img src="https://github.com/amitkumarcoding/imagecroppicker/blob/main/images/7.png" alt="iOS demo" width="320" />
81
- </p>
82
- </br>
83
- <p>
84
- <img src="https://github.com/amitkumarcoding/imagecroppicker/blob/main/images/8.png" alt="iOS demo" width="320" />
85
- </p>
86
- </br>
87
- <p>
88
- <img src="https://github.com/amitkumarcoding/imagecroppicker/blob/main/images/9.png" alt="iOS demo" width="320" />
89
- </p>
90
- </br>
91
- </br>
46
+ ### Android
47
+
48
+ <div style="display: flex; flex-wrap: wrap; gap: 12px;">
49
+ <img src="https://github.com/amitkumarcoding/imagecroppicker/blob/main/images/1.png" width="260" />
50
+ <img src="https://github.com/amitkumarcoding/imagecroppicker/blob/main/images/2.png" width="260" />
51
+ <img src="https://github.com/amitkumarcoding/imagecroppicker/blob/main/images/3.png" width="260" />
52
+ <img src="https://github.com/amitkumarcoding/imagecroppicker/blob/main/images/4.png" width="260" />
53
+ </div>
54
+
55
+ ### iOS
56
+
57
+ <div style="display: flex; flex-wrap: wrap; gap: 12px;">
58
+ <img src="https://github.com/amitkumarcoding/imagecroppicker/blob/main/images/5.png" width="260" />
59
+ <img src="https://github.com/amitkumarcoding/imagecroppicker/blob/main/images/6.png" width="260" />
60
+ <img src="https://github.com/amitkumarcoding/imagecroppicker/blob/main/images/7.png" width="260" />
61
+ <img src="https://github.com/amitkumarcoding/imagecroppicker/blob/main/images/8.png" width="260" />
62
+ <img src="https://github.com/amitkumarcoding/imagecroppicker/blob/main/images/9.png" width="260" />
63
+ </div>
92
64
 
93
65
 
94
66
  ## Important notes
@@ -236,29 +208,149 @@ This package also exports a **fully customizable React Native modal** (`ImageCro
236
208
  ### Usage
237
209
 
238
210
  ```js
239
- import React, { useState } from 'react';
240
- import { View, Button } from 'react-native';
241
- import { ImageCropPickerModal } from 'react-native-customizable-image-crop-picker';
242
-
243
- export default function Screen() {
244
- const [visible, setVisible] = useState(false);
245
-
246
- return (
247
- <View style={{ flex: 1 }}>
248
- <Button title="Open preview UI" onPress={() => setVisible(true)} />
249
-
250
- <ImageCropPickerModal
251
- visible={visible}
252
- imageUri="file:///path/to/image.jpg"
253
- headerTitle="Preview Image"
254
- cancelText="Cancel"
255
- uploadText="Upload"
256
- onCancel={() => setVisible(false)}
257
- onConfirm={() => setVisible(false)}
258
- />
259
- </View>
260
- );
261
- }
211
+
212
+ import React from 'react';
213
+ import {
214
+ View,
215
+ Text,
216
+ StyleSheet,
217
+ StatusBar,
218
+ TouchableOpacity,
219
+ Alert,
220
+ Platform,
221
+ PermissionsAndroid,
222
+ } from 'react-native';
223
+ import { SafeAreaView } from 'react-native-safe-area-context';
224
+ import { openImageCropPicker } from 'react-native-customizable-image-crop-picker';
225
+
226
+ const App = () => {
227
+ async function ensureCameraPermission() {
228
+ if (Platform.OS !== 'android') return true;
229
+ const res = await PermissionsAndroid.request(PermissionsAndroid.PERMISSIONS.CAMERA);
230
+ return res === PermissionsAndroid.RESULTS.GRANTED;
231
+ }
232
+
233
+ const baseConfig = {
234
+ cropWidth: 1,
235
+ cropHeight: 1,
236
+ circularCrop: true,
237
+ cropGridEnabled: true,
238
+ dimmedLayerColor: '#B3000000',
239
+ compressQuality: 0.8,
240
+ compressFormat: 'jpeg',
241
+ headerTitle: 'Preview',
242
+ headerAlignment: 'center',
243
+ controlsPlacement: 'bottom',
244
+ uploadText: 'Upload',
245
+ cancelText: 'Cancel',
246
+ uploadButtonContent: 'text',
247
+ cancelButtonContent: 'text',
248
+ };
249
+
250
+ const openCamera = async () => {
251
+ const ok = await ensureCameraPermission();
252
+ if (!ok) return;
253
+
254
+ try {
255
+ const result = await openImageCropPicker({
256
+ ...baseConfig,
257
+ source: 'camera',
258
+ });
259
+ console.log('Camera Result:', result);
260
+ } catch (error) {
261
+ handleError(error);
262
+ }
263
+ };
264
+
265
+ const openGallery = async () => {
266
+ try {
267
+ const result = await openImageCropPicker({
268
+ ...baseConfig,
269
+ source: 'gallery',
270
+ });
271
+
272
+ console.log('Gallery Result:', result);
273
+ } catch (error) {
274
+ handleError(error);
275
+ }
276
+ };
277
+
278
+ const handleError = (error) => {
279
+ if (error?.code === 'E_PERMISSION_MISSING') {
280
+ Alert.alert('Permission Required', 'Please allow camera access');
281
+ return;
282
+ }
283
+
284
+ if (error?.code === 'E_PICKER_CANCELLED') {
285
+ console.log('User cancelled');
286
+ return;
287
+ }
288
+
289
+ console.error('Unhandled Error:', error);
290
+ };
291
+
292
+ return (
293
+ <SafeAreaView style={styles.safeArea}>
294
+ <StatusBar barStyle="dark-content" />
295
+
296
+ <View style={styles.container}>
297
+ <TouchableOpacity
298
+ style={styles.primaryButton}
299
+ activeOpacity={0.8}
300
+ onPress={openCamera}
301
+ >
302
+ <Text style={styles.primaryText}>Open Camera</Text>
303
+ </TouchableOpacity>
304
+
305
+ <TouchableOpacity
306
+ style={styles.secondaryButton}
307
+ activeOpacity={0.8}
308
+ onPress={openGallery}
309
+ >
310
+ <Text style={styles.secondaryText}>Open Gallery</Text>
311
+ </TouchableOpacity>
312
+ </View>
313
+ </SafeAreaView>
314
+ );
315
+ };
316
+
317
+ export default App;
318
+
319
+ const styles = StyleSheet.create({
320
+ safeArea: {
321
+ flex: 1,
322
+ backgroundColor: '#F9FAFB',
323
+ },
324
+ container: {
325
+ flex: 1,
326
+ justifyContent: 'center',
327
+ paddingHorizontal: 20,
328
+ gap: 16,
329
+ },
330
+ primaryButton: {
331
+ backgroundColor: '#111827',
332
+ paddingVertical: 14,
333
+ borderRadius: 12,
334
+ alignItems: 'center',
335
+ },
336
+ primaryText: {
337
+ color: '#FFFFFF',
338
+ fontSize: 16,
339
+ fontWeight: '600',
340
+ },
341
+ secondaryButton: {
342
+ borderWidth: 1.5,
343
+ borderColor: '#111827',
344
+ paddingVertical: 14,
345
+ borderRadius: 12,
346
+ alignItems: 'center',
347
+ },
348
+ secondaryText: {
349
+ color: '#111827',
350
+ fontSize: 16,
351
+ fontWeight: '600',
352
+ },
353
+ });
262
354
  ```
263
355
 
264
356
  ### Modal props
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-customizable-image-crop-picker",
3
- "version": "1.0.6",
3
+ "version": "1.0.8",
4
4
  "description": "Fully customizable React Native image crop picker (JS UI + native performance).",
5
5
  "keywords": [
6
6
  "react-native",