react-native-expo-cropper 1.2.49 → 1.2.51

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.
@@ -45,7 +45,12 @@ var ImageCropper = function ImageCropper(_ref) {
45
45
  openCameraFirst = _ref.openCameraFirst,
46
46
  initialImage = _ref.initialImage,
47
47
  addheight = _ref.addheight,
48
- rotationLabel = _ref.rotationLabel;
48
+ rotationLabel = _ref.rotationLabel,
49
+ onCancel = _ref.onCancel,
50
+ _ref$confirmText = _ref.confirmText,
51
+ confirmText = _ref$confirmText === void 0 ? 'Confirm' : _ref$confirmText,
52
+ _ref$resetText = _ref.resetText,
53
+ resetText = _ref$resetText === void 0 ? 'Reset' : _ref$resetText;
49
54
  var _useWindowDimensions = (0, _reactNative.useWindowDimensions)(),
50
55
  windowWidth = _useWindowDimensions.width,
51
56
  windowHeight = _useWindowDimensions.height;
@@ -1251,9 +1256,7 @@ var ImageCropper = function ImageCropper(_ref) {
1251
1256
  }, image && /*#__PURE__*/_react["default"].createElement(_reactNative.View, {
1252
1257
  style: _ImageCropperStyles["default"].imageRegion
1253
1258
  }, /*#__PURE__*/_react["default"].createElement(_reactNative.View, {
1254
- style: [_ImageCropperStyles["default"].commonWrapper, {
1255
- maxHeight: windowHeight * 0.7
1256
- }],
1259
+ style: _ImageCropperStyles["default"].commonWrapper,
1257
1260
  ref: commonWrapperRef,
1258
1261
  onLayout: onCommonWrapperLayout
1259
1262
  }, /*#__PURE__*/_react["default"].createElement(_reactNative.View, {
@@ -1390,7 +1393,26 @@ var ImageCropper = function ImageCropper(_ref) {
1390
1393
  paddingHorizontal: Math.round(12 * responsiveScale),
1391
1394
  gap: Math.round(8 * responsiveScale)
1392
1395
  }]
1393
- }, _reactNative.Platform.OS === 'android' && /*#__PURE__*/_react["default"].createElement(_reactNative.TouchableOpacity, {
1396
+ }, /*#__PURE__*/_react["default"].createElement(_reactNative.TouchableOpacity, {
1397
+ style: [_ImageCropperStyles["default"].rotationButton, {
1398
+ backgroundColor: 'transparent',
1399
+ borderWidth: 1,
1400
+ borderColor: 'white',
1401
+ width: Math.round(40 * responsiveScale),
1402
+ height: Math.round(40 * responsiveScale),
1403
+ borderRadius: Math.round(20 * responsiveScale),
1404
+ marginRight: Math.round(6 * responsiveScale)
1405
+ }],
1406
+ onPress: function onPress() {
1407
+ if (onCancel) {
1408
+ onCancel();
1409
+ }
1410
+ }
1411
+ }, /*#__PURE__*/_react["default"].createElement(_vectorIcons.Ionicons, {
1412
+ name: "close",
1413
+ size: Math.round(20 * responsiveScale),
1414
+ color: "white"
1415
+ })), _reactNative.Platform.OS === 'android' && /*#__PURE__*/_react["default"].createElement(_reactNative.TouchableOpacity, {
1394
1416
  style: [_ImageCropperStyles["default"].rotationButton, {
1395
1417
  width: Math.round(56 * responsiveScale),
1396
1418
  height: Math.round(48 * responsiveScale),
@@ -1420,7 +1442,7 @@ var ImageCropper = function ImageCropper(_ref) {
1420
1442
  style: [_ImageCropperStyles["default"].buttonText, {
1421
1443
  fontSize: Math.max(14, Math.round(18 * responsiveScale))
1422
1444
  }]
1423
- }, "Reset")), /*#__PURE__*/_react["default"].createElement(_reactNative.TouchableOpacity, {
1445
+ }, resetText)), /*#__PURE__*/_react["default"].createElement(_reactNative.TouchableOpacity, {
1424
1446
  onPress: /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2() {
1425
1447
  var _cameraFrameData$curr4, actualImageWidth, actualImageHeight, isCoverMode, captured, layout, contentRect, displayedWidth, displayedHeight, scale, coverOffsetX, coverOffsetY, scaledWidth, scaledHeight, originalUri, cropMeta, imagePoints, minX, minY, maxX, maxY, cropX, cropY, cropEndX, cropEndY, cropWidth, cropHeight, bbox, polygon, ext, safeExt, name, _t2;
1426
1448
  return _regenerator().w(function (_context2) {
@@ -1596,7 +1618,7 @@ var ImageCropper = function ImageCropper(_ref) {
1596
1618
  style: [_ImageCropperStyles["default"].buttonText, {
1597
1619
  fontSize: Math.max(14, Math.round(18 * responsiveScale))
1598
1620
  }]
1599
- }, "Confirm"))), !showResult && !image && /*#__PURE__*/_react["default"].createElement(_reactNative.View, {
1621
+ }, confirmText))), !showResult && !image && /*#__PURE__*/_react["default"].createElement(_reactNative.View, {
1600
1622
  style: _ImageCropperStyles["default"].centerButtonsContainer
1601
1623
  }, /*#__PURE__*/_react["default"].createElement(_reactNative.Text, {
1602
1624
  style: _ImageCropperStyles["default"].welcomeText
@@ -30,17 +30,18 @@ var styles = _reactNative.StyleSheet.create({
30
30
  flexDirection: 'column',
31
31
  minHeight: 0
32
32
  },
33
- // Wrapper that centers the crop box vertically and horizontally on screen
33
+ // Wrapper that occupies all space above the buttons
34
34
  imageRegion: {
35
35
  flex: 1,
36
36
  width: '100%',
37
- justifyContent: 'center',
38
- alignItems: 'center'
37
+ alignSelf: 'stretch',
38
+ justifyContent: 'flex-start',
39
+ alignItems: 'stretch'
39
40
  },
40
- // Crop preview: responsive box, centered inside imageRegion
41
+ // Crop preview: fill all available space in imageRegion
41
42
  commonWrapper: {
43
+ flex: 1,
42
44
  width: '100%',
43
- aspectRatio: 9 / 16,
44
45
  overflow: 'hidden',
45
46
  alignItems: 'center',
46
47
  justifyContent: 'center',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-expo-cropper",
3
- "version": "1.2.49",
3
+ "version": "1.2.51",
4
4
  "description": "Recadrage polygonal d'images.",
5
5
  "main": "index.js",
6
6
  "author": "PCS AGRI",
@@ -13,7 +13,16 @@ const PRIMARY_GREEN = '#198754';
13
13
  // Base dimension for responsive scaling (e.g. ~375pt design width)
14
14
  const RESPONSIVE_BASE = 375;
15
15
 
16
- const ImageCropper = ({ onConfirm, openCameraFirst, initialImage, addheight, rotationLabel }) => {
16
+ const ImageCropper = ({
17
+ onConfirm,
18
+ openCameraFirst,
19
+ initialImage,
20
+ addheight,
21
+ rotationLabel,
22
+ onCancel,
23
+ confirmText = 'Confirm',
24
+ resetText = 'Reset',
25
+ }) => {
17
26
  const { width: windowWidth, height: windowHeight } = useWindowDimensions();
18
27
 
19
28
  // Responsive scale: image and UI adapt to small (phone) and large (tablet) screens
@@ -1071,12 +1080,7 @@ const rotatePreviewImage = async (degrees) => {
1071
1080
  {image && (
1072
1081
  <View style={styles.imageRegion}>
1073
1082
  <View
1074
- style={[
1075
- styles.commonWrapper,
1076
- {
1077
- maxHeight: windowHeight * 0.7,
1078
- },
1079
- ]}
1083
+ style={styles.commonWrapper}
1080
1084
  ref={commonWrapperRef}
1081
1085
  onLayout={onCommonWrapperLayout}
1082
1086
  >
@@ -1197,15 +1201,40 @@ const rotatePreviewImage = async (degrees) => {
1197
1201
 
1198
1202
  {/* ✅ Buttons positioned as a responsive bottom bar (scale with screen size) */}
1199
1203
  {!showResult && image && (
1200
- <View style={[
1201
- styles.buttonContainerBelow,
1202
- {
1203
- paddingBottom: Math.max(insets.bottom, Math.round(16 * responsiveScale)),
1204
- paddingTop: Math.round(12 * responsiveScale),
1205
- paddingHorizontal: Math.round(12 * responsiveScale),
1206
- gap: Math.round(8 * responsiveScale),
1207
- },
1208
- ]}>
1204
+ <View
1205
+ style={[
1206
+ styles.buttonContainerBelow,
1207
+ {
1208
+ paddingBottom: Math.max(insets.bottom, Math.round(16 * responsiveScale)),
1209
+ paddingTop: Math.round(12 * responsiveScale),
1210
+ paddingHorizontal: Math.round(12 * responsiveScale),
1211
+ gap: Math.round(8 * responsiveScale),
1212
+ },
1213
+ ]}
1214
+ >
1215
+ {/* Close button: always visible, closes cropper */}
1216
+ <TouchableOpacity
1217
+ style={[
1218
+ styles.rotationButton,
1219
+ {
1220
+ backgroundColor: 'transparent',
1221
+ borderWidth: 1,
1222
+ borderColor: 'white',
1223
+ width: Math.round(40 * responsiveScale),
1224
+ height: Math.round(40 * responsiveScale),
1225
+ borderRadius: Math.round(20 * responsiveScale),
1226
+ marginRight: Math.round(6 * responsiveScale),
1227
+ },
1228
+ ]}
1229
+ onPress={() => {
1230
+ if (onCancel) {
1231
+ onCancel();
1232
+ }
1233
+ }}
1234
+ >
1235
+ <Ionicons name="close" size={Math.round(20 * responsiveScale)} color="white" />
1236
+ </TouchableOpacity>
1237
+
1209
1238
  {Platform.OS === 'android' && (
1210
1239
  <TouchableOpacity
1211
1240
  style={[
@@ -1239,7 +1268,14 @@ const rotatePreviewImage = async (degrees) => {
1239
1268
  ]}
1240
1269
  onPress={handleReset}
1241
1270
  >
1242
- <Text style={[styles.buttonText, { fontSize: Math.max(14, Math.round(18 * responsiveScale)) }]}>Reset</Text>
1271
+ <Text
1272
+ style={[
1273
+ styles.buttonText,
1274
+ { fontSize: Math.max(14, Math.round(18 * responsiveScale)) },
1275
+ ]}
1276
+ >
1277
+ {resetText}
1278
+ </Text>
1243
1279
  </TouchableOpacity>
1244
1280
 
1245
1281
  <TouchableOpacity
@@ -1382,7 +1418,14 @@ const rotatePreviewImage = async (degrees) => {
1382
1418
  },
1383
1419
  ]}
1384
1420
  >
1385
- <Text style={[styles.buttonText, { fontSize: Math.max(14, Math.round(18 * responsiveScale)) }]}>Confirm</Text>
1421
+ <Text
1422
+ style={[
1423
+ styles.buttonText,
1424
+ { fontSize: Math.max(14, Math.round(18 * responsiveScale)) },
1425
+ ]}
1426
+ >
1427
+ {confirmText}
1428
+ </Text>
1386
1429
  </TouchableOpacity>
1387
1430
  </View>
1388
1431
  )}
@@ -25,17 +25,18 @@ const styles = StyleSheet.create({
25
25
  flexDirection: 'column',
26
26
  minHeight: 0,
27
27
  },
28
- // Wrapper that centers the crop box vertically and horizontally on screen
28
+ // Wrapper that occupies all space above the buttons
29
29
  imageRegion: {
30
30
  flex: 1,
31
31
  width: '100%',
32
- justifyContent: 'center',
33
- alignItems: 'center',
32
+ alignSelf: 'stretch',
33
+ justifyContent: 'flex-start',
34
+ alignItems: 'stretch',
34
35
  },
35
- // Crop preview: responsive box, centered inside imageRegion
36
+ // Crop preview: fill all available space in imageRegion
36
37
  commonWrapper: {
38
+ flex: 1,
37
39
  width: '100%',
38
- aspectRatio: 9 / 16,
39
40
  overflow: 'hidden',
40
41
  alignItems: 'center',
41
42
  justifyContent: 'center',