diff --git a/components/FaceScanner/FaceCompare.tsx b/components/FaceScanner/FaceCompare.tsx index 1846e3ccb4..b569b8b8ad 100644 --- a/components/FaceScanner/FaceCompare.tsx +++ b/components/FaceScanner/FaceCompare.tsx @@ -10,6 +10,7 @@ import testIDProps from '../../shared/commonUtil'; const FaceCompare: React.FC = ({ whichCamera, setCameraRef, + flipCamera, isCapturing, isVerifying, service, @@ -53,7 +54,7 @@ const FaceCompare: React.FC = ({ - service.send('FLIP_CAMERA')}> + {SvgImage.FlipCameraIcon()} void; + flipCamera: () => void; isCapturing: boolean; isVerifying: boolean; service: any; diff --git a/components/FaceScanner/FaceScanner.tsx b/components/FaceScanner/FaceScanner.tsx index 49dbd11066..4a898dee92 100644 --- a/components/FaceScanner/FaceScanner.tsx +++ b/components/FaceScanner/FaceScanner.tsx @@ -15,7 +15,6 @@ import { selectIsValid, selectIsPermissionDenied, selectIsScanning, - selectWhichCamera, createFaceScannerMachine, selectIsInvalid, selectIsCapturing, @@ -45,7 +44,7 @@ export const FaceScanner: React.FC = props => { const machine = useRef(createFaceScannerMachine(props.vcImage)); const service = useInterpret(machine.current); - const whichCamera = useSelector(service, selectWhichCamera); + const [cameraType, setCameraType] = useState(Camera.Constants.Type.front); const cameraRef = useSelector(service, selectCameraRef); const isPermissionDenied = useSelector(service, selectIsPermissionDenied); @@ -77,6 +76,14 @@ export const FaceScanner: React.FC = props => { [isScanning], ); + const flipCamera = () => { + setCameraType(prevType => + prevType === Camera.Constants.Type.front + ? Camera.Constants.Type.back + : Camera.Constants.Type.front, + ); + }; + function handleOnCancel() { props.onCancel(); } @@ -177,7 +184,7 @@ export const FaceScanner: React.FC = props => { = props => { } else { return ( ({cameraRef}), - FLIP_CAMERA: () => ({}), CAPTURE: () => ({}), DENIED: (response: PermissionResponse) => ({response}), GRANTED: () => ({}), @@ -32,11 +30,6 @@ const model = createModel( export const FaceScannerEvents = model.events; -export interface FaceScanResult { - metadata: Face; - image: CameraCapturedPicture; -} - export const createFaceScannerMach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WJA3mD6fIVQYfozNKLjFsGJCmDMIxLTl47xCtq6GW1G09WoJREPgVCQPtzmDfaGEYQMvJOpYSmehE-jSX6rmQdM7gRNYEW3pGNDRjqsB6gam0EgdzJOcBLkeSE0odIO-go3B-lFTorqWCYc2RA4yxBAY6PvXsgOk20MIjdCY2TJNDPIrN4TBpB0puOY3P4YRlCcU+ZF8+JjMzbYjhcjW7TmHyQTCjYM2yehMojjpKIKxGSvEZgEj8FQPF7SJgFA5l2aonK4Rgk43mmAF2awmVmGVa5zpwjbUUPvq6sDTY9rZVhoH5UbRVOHYpXRNmZgebMXOvXhTacKgMDUqgChUFq6quxaolA+0YoxAjbgjrYRjCuhUlmO0Osophzq1usb3KvHLRtKYIODsLoGi5O4w6Ms9rwYYyxGL0ha1XEQA */ model.createMachine( @@ -118,9 +111,6 @@ export const createFaceScannerMachine = (vcImage: string) => CAPTURE: { target: 'capturing', }, - FLIP_CAMERA: { - actions: 'flipWhichCamera', - }, }, }, capturing: { @@ -175,13 +165,6 @@ export const createFaceScannerMachine = (vcImage: string) => capturedImage: (_context, event) => event.data, }), - flipWhichCamera: model.assign({ - whichCamera: context => - context.whichCamera === Camera.Constants.Type.front - ? Camera.Constants.Type.back - : Camera.Constants.Type.front, - }), - setCaptureError: assign({ captureError: '', }), @@ -236,10 +219,6 @@ export const createFaceScannerMachine = (vcImage: string) => type State = StateFrom>; -export function selectWhichCamera(state: State) { - return state.context.whichCamera; -} - export function selectCameraRef(state: State) { return state.context.cameraRef; }