diff --git a/README.md b/README.md index 44978739b..c1a619184 100644 --- a/README.md +++ b/README.md @@ -172,40 +172,41 @@ Additionally, the Camera can be used for barcode scanning ### Camera Props (Optional) -| Props | Type | Description | -| ------------------------------ | -------------------------------- |------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| `ref` | Ref | Reference on the camera view | -| `style` | StyleProp\ | Style to apply on the camera view | -| `flashMode` | `'on'`/`'off'`/`'auto'` | Camera flash mode. Default: `auto` | -| `focusMode` | `'on'`/`'off'` | Camera focus mode. Default: `on` | -| `zoomMode` | `'on'`/`'off'` | Enable the pinch to zoom gesture. Default: `on`. If `on`, you must pass `zoom` as `undefined` or avoid setting `zoomMode` to allow pinch to zoom | -| `zoom` | `number` | Control the zoom. Default: `1.0` | -| `maxZoom` | `number` | Maximum zoom allowed (but not beyond what camera allows). Default: `undefined` (camera default max) | -| `onZoom` | Function | Callback when user makes a pinch gesture, regardless of what the `zoom` prop was set to. Returned event contains `zoom`. Ex: `onZoom={(e) => console.log(e.nativeEvent.zoom)}`. | -| `torchMode` | `'on'`/`'off'` | Toggle flash light when camera is active. Default: `off` | -| `cameraType` | CameraType.Back/CameraType.Front | Choose what camera to use. Default: `CameraType.Back` | -| `onOrientationChange` | Function | Callback when physical device orientation changes. Returned event contains `orientation`. Ex: `onOrientationChange={(event) => console.log(event.nativeEvent.orientation)}`. Use `import { Orientation } from 'react-native-camera-kit'; if (event.nativeEvent.orientation === Orientation.PORTRAIT) { ... }` to understand the new value | -| `allowedBarcodeTypes` | string[] | Limits which barcode formats can be detected. Ex: `['code-128', 'code-39', 'code-93', 'codabar', 'ean-13', 'ean-8', 'itf', 'upc-a', 'upc-e', 'pdf-417', 'aztec', 'data-matrix', 'code-128']`. If empty or omitted, all supported formats are scanned. | -| **Android only** | -| `onError` | Function | Android only. Callback when camera fails to initialize. Ex: `onError={(e) => console.log(e.nativeEvent.errorMessage)}`. | -| `shutterPhotoSound` | `boolean` | Android only. Enable or disable the shutter sound when capturing a photo. Default: `true` | -| **iOS only** | -| `ratioOverlay` | `'int:int'` | Show a guiding overlay in the camera preview for the selected ratio. Does not crop image as of v9.0. Example: `'16:9'` | -| `ratioOverlayColor` | Color | Any color with alpha. Default: `'#ffffff77'` | -| `resetFocusTimeout` | `number` | Dismiss tap to focus after this many milliseconds. Default `0` (disabled). Example: `5000` is 5 seconds. | -| `resetFocusWhenMotionDetected` | Boolean | Dismiss tap to focus when focus area content changes. Native iOS feature, see documentation: https://developer.apple.com/documentation/avfoundation/avcapturedevice/1624644-subjectareachangemonitoringenabl?language=objc). Default `true`. | -| `resizeMode` | `'cover' / 'contain'` | Determines the scaling and cropping behavior of content within the view. `cover` (resizeAspectFill on iOS) scales the content to fill the view completely, potentially cropping content if its aspect ratio differs from the view. `contain` (resizeAspect on iOS) scales the content to fit within the view's bounds without cropping, ensuring all content is visible but may introduce letterboxing. Default behavior depends on the specific use case. | -| `scanThrottleDelay` | `number` | Duration between scan detection in milliseconds. Default 2000 (2s) | -| `maxPhotoQualityPrioritization` | `'balanced'` / `'quality'` / `'speed'` | [iOS 13 and newer](https://developer.apple.com/documentation/avfoundation/avcapturephotooutput/3182995-maxphotoqualityprioritization). `'speed'` provides a 60-80% median capture time reduction vs 'quality' setting. Tested on iPhone 6S Max (66% faster) and iPhone 15 Pro Max (76% faster!). Default `balanced` | -| `onCaptureButtonPressIn` | Function | Callback when iPhone capture button is pressed in or Android volume or camera button is pressed in. Ex: `onCaptureButtonPressIn={() => console.log("volume button pressed in")}` | -| `onCaptureButtonPressOut` | Function | Callback when iPhone capture button is released or Android volume or camera button is released. Ex: `onCaptureButtonPressOut={() => console.log("volume button released")}` | -| **Barcode only** | -| `scanBarcode` | `boolean` | Enable barcode scanner. Default: `false` | -| `showFrame` | `boolean` | Show frame in barcode scanner. Default: `false` | -| `barcodeFrameSize` | `object` | Frame size of barcode scanner. Default: `{ width: 300, height: 150 }` | -| `laserColor` | Color | Color of barcode scanner laser visualization. Default: `red` | -| `frameColor` | Color | Color of barcode scanner frame visualization. Default: `yellow` | -| `onReadCode` | Function | Callback when scanner successfully reads barcode. Returned event contains `codeStringValue`. Default: `null`. Ex: `onReadCode={(event) => console.log(event.nativeEvent.codeStringValue)}` | +| Props | Type | Description | +| ------------------------------- | -------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `ref` | Ref | Reference on the camera view | +| `style` | StyleProp\ | Style to apply on the camera view | +| `flashMode` | `'on'`/`'off'`/`'auto'` | Camera flash mode. Default: `auto` | +| `focusMode` | `'on'`/`'off'` | Camera focus mode. Default: `on` | +| `zoomMode` | `'on'`/`'off'` | Enable the pinch to zoom gesture. Default: `on`. If `on`, you must pass `zoom` as `undefined` or avoid setting `zoomMode` to allow pinch to zoom | +| `zoom` | `number` | Control the zoom. Default: `1.0` | +| `maxZoom` | `number` | Maximum zoom allowed (but not beyond what camera allows). Default: `undefined` (camera default max) | +| `onZoom` | Function | Callback when user makes a pinch gesture, regardless of what the `zoom` prop was set to. Returned event contains `zoom`. Ex: `onZoom={(e) => console.log(e.nativeEvent.zoom)}`. | +| `torchMode` | `'on'`/`'off'` | Toggle flash light when camera is active. Default: `off` | +| `cameraType` | CameraType.Back/CameraType.Front | Choose what camera to use. Default: `CameraType.Back` | +| `onOrientationChange` | Function | Callback when physical device orientation changes. Returned event contains `orientation`. Ex: `onOrientationChange={(event) => console.log(event.nativeEvent.orientation)}`. Use `import { Orientation } from 'react-native-camera-kit'; if (event.nativeEvent.orientation === Orientation.PORTRAIT) { ... }` to understand the new value | +| `allowedBarcodeTypes` | string[] | Limits which barcode formats can be detected. Ex: `['code-128', 'code-39', 'code-93', 'codabar', 'ean-13', 'ean-8', 'itf', 'upc-a', 'upc-e', 'pdf-417', 'aztec', 'data-matrix', 'code-128']`. If empty or omitted, all supported formats are scanned. | +| **Android only** | +| `onError` | Function | Android only. Callback when camera fails to initialize. Ex: `onError={(e) => console.log(e.nativeEvent.errorMessage)}`. | +| `shutterPhotoSound` | `boolean` | Android only. Enable or disable the shutter sound when capturing a photo. Default: `true` | +| **iOS only** | +| `ratioOverlay` | `'int:int'` | Show a guiding overlay in the camera preview for the selected ratio. Does not crop image as of v9.0. Example: `'16:9'` | +| `ratioOverlayColor` | Color | Any color with alpha. Default: `'#ffffff77'` | +| `resetFocusTimeout` | `number` | Dismiss tap to focus after this many milliseconds. Default `0` (disabled). Example: `5000` is 5 seconds. | +| `resetFocusWhenMotionDetected` | Boolean | Dismiss tap to focus when focus area content changes. Native iOS feature, see documentation: https://developer.apple.com/documentation/avfoundation/avcapturedevice/1624644-subjectareachangemonitoringenabl?language=objc). Default `true`. | +| `resizeMode` | `'cover' / 'contain'` | Determines the scaling and cropping behavior of content within the view. `cover` (resizeAspectFill on iOS) scales the content to fill the view completely, potentially cropping content if its aspect ratio differs from the view. `contain` (resizeAspect on iOS) scales the content to fit within the view's bounds without cropping, ensuring all content is visible but may introduce letterboxing. Default behavior depends on the specific use case. | +| `scanThrottleDelay` | `number` | Duration between scan detection in milliseconds. Default 2000 (2s) | +| `maxPhotoQualityPrioritization` | `'balanced'` / `'quality'` / `'speed'` | [iOS 13 and newer](https://developer.apple.com/documentation/avfoundation/avcapturephotooutput/3182995-maxphotoqualityprioritization). `'speed'` provides a 60-80% median capture time reduction vs 'quality' setting. Tested on iPhone 6S Max (66% faster) and iPhone 15 Pro Max (76% faster!). Default `balanced` | +| `iOsSleepBeforeStarting` | `number` | iOS only. Delay (ms) before the capture session starts. Default `100`. Set to `0` to skip. Helps ensure `session.commitConfiguration()` finishes before `session.startRunning()`, reducing occasional crashes seen when rapidly toggling cameras: `-[AVCaptureSession startRunning] startRunning may not be called between calls to beginConfiguration and commitConfiguration`. iOS feedback ID: FB21533559 | +| `onCaptureButtonPressIn` | Function | Callback when iPhone capture button is pressed in or Android volume or camera button is pressed in. Ex: `onCaptureButtonPressIn={() => console.log("volume button pressed in")}` | +| `onCaptureButtonPressOut` | Function | Callback when iPhone capture button is released or Android volume or camera button is released. Ex: `onCaptureButtonPressOut={() => console.log("volume button released")}` | +| **Barcode only** | +| `scanBarcode` | `boolean` | Enable barcode scanner. Default: `false` | +| `showFrame` | `boolean` | Show frame in barcode scanner. Default: `false` | +| `barcodeFrameSize` | `object` | Frame size of barcode scanner. Default: `{ width: 300, height: 150 }` | +| `laserColor` | Color | Color of barcode scanner laser visualization. Default: `red` | +| `frameColor` | Color | Color of barcode scanner frame visualization. Default: `yellow` | +| `onReadCode` | Function | Callback when scanner successfully reads barcode. Returned event contains `codeStringValue`. Default: `null`. Ex: `onReadCode={(event) => console.log(event.nativeEvent.codeStringValue)}` | ### Imperative API diff --git a/example/src/App.tsx b/example/src/App.tsx index 5c0daf97c..e4ae525e5 100644 --- a/example/src/App.tsx +++ b/example/src/App.tsx @@ -1,20 +1,22 @@ import React, { useState } from 'react'; -import { StyleSheet, Text, View, TouchableOpacity, ScrollView } from 'react-native'; +import { StyleSheet, Text, View, TouchableOpacity, ScrollView, Button, Alert, TextInput } from 'react-native'; import BarcodeScreenExample from './BarcodeScreenExample'; import CameraExample from './CameraExample'; const App = () => { - const [example, setExample] = useState(); + const [example, setExample] = useState(undefined); + const [testNo, setTestNo] = useState(0); + const [interval, setIntervalId] = useState(null); + const [speed, setSpeed] = useState('1000'); + const onBack = () => setExample(undefined); if (example) { return example; } - const onBack = () => setExample(undefined); - return ( - + 🎈 React Native Camera Kit @@ -24,6 +26,67 @@ const App = () => { setExample()}> Barcode Scanner + + Mount Stress Test + + {!testNo ? ( + <> + + Speed (ms): + + + +