react-native-expo-cropper 1.2.50 → 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;
@@ -1388,7 +1393,26 @@ var ImageCropper = function ImageCropper(_ref) {
1388
1393
  paddingHorizontal: Math.round(12 * responsiveScale),
1389
1394
  gap: Math.round(8 * responsiveScale)
1390
1395
  }]
1391
- }, _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, {
1392
1416
  style: [_ImageCropperStyles["default"].rotationButton, {
1393
1417
  width: Math.round(56 * responsiveScale),
1394
1418
  height: Math.round(48 * responsiveScale),
@@ -1418,7 +1442,7 @@ var ImageCropper = function ImageCropper(_ref) {
1418
1442
  style: [_ImageCropperStyles["default"].buttonText, {
1419
1443
  fontSize: Math.max(14, Math.round(18 * responsiveScale))
1420
1444
  }]
1421
- }, "Reset")), /*#__PURE__*/_react["default"].createElement(_reactNative.TouchableOpacity, {
1445
+ }, resetText)), /*#__PURE__*/_react["default"].createElement(_reactNative.TouchableOpacity, {
1422
1446
  onPress: /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2() {
1423
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;
1424
1448
  return _regenerator().w(function (_context2) {
@@ -1594,7 +1618,7 @@ var ImageCropper = function ImageCropper(_ref) {
1594
1618
  style: [_ImageCropperStyles["default"].buttonText, {
1595
1619
  fontSize: Math.max(14, Math.round(18 * responsiveScale))
1596
1620
  }]
1597
- }, "Confirm"))), !showResult && !image && /*#__PURE__*/_react["default"].createElement(_reactNative.View, {
1621
+ }, confirmText))), !showResult && !image && /*#__PURE__*/_react["default"].createElement(_reactNative.View, {
1598
1622
  style: _ImageCropperStyles["default"].centerButtonsContainer
1599
1623
  }, /*#__PURE__*/_react["default"].createElement(_reactNative.Text, {
1600
1624
  style: _ImageCropperStyles["default"].welcomeText
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-expo-cropper",
3
- "version": "1.2.50",
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
@@ -1192,15 +1201,40 @@ const rotatePreviewImage = async (degrees) => {
1192
1201
 
1193
1202
  {/* ✅ Buttons positioned as a responsive bottom bar (scale with screen size) */}
1194
1203
  {!showResult && image && (
1195
- <View style={[
1196
- styles.buttonContainerBelow,
1197
- {
1198
- paddingBottom: Math.max(insets.bottom, Math.round(16 * responsiveScale)),
1199
- paddingTop: Math.round(12 * responsiveScale),
1200
- paddingHorizontal: Math.round(12 * responsiveScale),
1201
- gap: Math.round(8 * responsiveScale),
1202
- },
1203
- ]}>
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
+
1204
1238
  {Platform.OS === 'android' && (
1205
1239
  <TouchableOpacity
1206
1240
  style={[
@@ -1234,7 +1268,14 @@ const rotatePreviewImage = async (degrees) => {
1234
1268
  ]}
1235
1269
  onPress={handleReset}
1236
1270
  >
1237
- <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>
1238
1279
  </TouchableOpacity>
1239
1280
 
1240
1281
  <TouchableOpacity
@@ -1377,7 +1418,14 @@ const rotatePreviewImage = async (degrees) => {
1377
1418
  },
1378
1419
  ]}
1379
1420
  >
1380
- <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>
1381
1429
  </TouchableOpacity>
1382
1430
  </View>
1383
1431
  )}