Package Exports
- @meddly/rn-vision-camera
- @meddly/rn-vision-camera/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@meddly/rn-vision-camera) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Setup
- Follow setup instructions for the following libraries
Overview
Features:
- Image & Video Capture
- Gesture Controls
- Pinch to Zoom
- Tap to focus
- Custom Gestures via props
- onDoubleTap
- onSwipeLeft
- onSwipeRight
- onSwipeUp
- onSwipeDown
- Portrait / Landscape UI for right and left handed individuals
- Save to camera roll
- Flash
- Custom icons, custom top bar, custom middle section, left / right of record / snap icons, and custom bottom bar
- Component Example (includes all props)
- Camera settings: control state and hook into component
- Flash
- Viewport
- Video / Photo Mode
import Camera from '@meddly/rn-vision-camera';
const [isVideo, setIsVideo] = useState<boolean>(true);
const [frontCamera, setFrontCamera] = useState<boolean>(false);
const [flash, setFlash] = useState<string>('auto');
const [videoStabilizationMode, setVideoStabilizationMode] =
useState<VideoStabilizationMode>('auto');
const [hideStatusBar, setHideStatusBar] = useState<boolean>(false);
const [isRecording, setIsRecording] = useState<boolean>(false);
/*/
* startRecording:
* - can be async
* - must return true to start recording
* stopRecording:
* - can be async
* - must return true to stop recording
/*/
const stateActions = {
startRecording: () => true,
stopRecording: () => true,
getDeviceInfo: (x: CameraDevice) => console.log('Device Info: ', x)
};
const cameraState = {
isVideo,
frontCamera,
flash,
videoStabilizationMode,
hideStatusBar,
startswitch: false, // Only needed for overrides
killswitch: false, // Only needed for overrides
};
const cameraConfig = {
photo: true, // Required
video: true, // Required
nameConvention: 'Meddly',
};
const customComponents = {
// Main Sections
cameraTop: {
component: <Text>Top</Text>,
},
cameraMiddle: {
component: <Text>Middle</Text>,
},
cameraAboveControls: {
component: <Text>Above Camera</Text>,
},
cameraBottom: {
component: <Text>Bottom</Text>,
},
// Camera Controls Section
cameraControlsLeft: {
component: <Text>Left</Text>,
},
cameraControlsPrimary: {
component: (
<Text>{isVideo ? (isRecording ? 'Stop' : 'Start') : 'Photo'}</Text>
),
},
cameraControlsRight: {
component: <Text>Right</Text>,
},
// Alternatively, you don't want to add custom logic to ,
// cameraControlsPrimary you can use the built-in camera
// controls and just add custom icons
// Note: if you use both, cameraControlsPrimary will take precedence
// Camera Control Icons
icons: {
takePictureIcon: <Text>SNP</Text>,
startRecordingIcon: <Text>REC</Text>,
stopRecordingIcon: <Text>STP</Text>,
},
};
const sectionHeights = {
top: 100,
bottom: 100,
};
// Render
<MeddlyCamera
// Camera Config
config={config}
isFocused={true}
useLocation={true}
forceUseLocation={false}
cameraState={cameraState}
stateActions={stateActions}
sectionHeights={sectionHeights}
hideNoDeviceFound={true}
// Pre-Built Actions
showCameraControls={true}
saveToCameraRoll={true}
// Lifecycle Events
onIsRecording={val => setIsRecording(val)}
onTakePicture={res => console.log('onTakePicture', res)}
onRecordingStart={res => console.log('onRecordingStart', res)}
onRecordingFinished={res => console.log('onRecordingFinished', res)}
onRecordingError={e => console.log('onRecordingError', e)}
onOrientationChange={val => console.log('onOrientationChange', val)}
// Custom Gesture Controls
onDoubleTap={res => console.log('onDoubleTap', res)}
swipeDistance={200}
onSwipeLeft={res => console.log('onSwipeLeft', res)}
onSwipeRight={res => console.log('onSwipeRight', res)}
onSwipeUp={res => console.log('onSwipeUp', res)}
onSwipeDown={res => console.log('onSwipeDown', res)}>
{customComponents}
</MeddlyCamera>
;