Page MenuHomePhorge

D14223.1768746481.diff
No OneTemporary

Size
2 KB
Referenced Files
None
Subscribers
None

D14223.1768746481.diff

diff --git a/native/media/camera-modal.react.js b/native/media/camera-modal.react.js
--- a/native/media/camera-modal.react.js
+++ b/native/media/camera-modal.react.js
@@ -250,10 +250,11 @@
+isActive: boolean,
+flashMode: number,
+changeFlashMode: () => void,
+ +useFrontCamera: boolean,
+ +switchCamera: () => void,
};
type State = {
+zoom: number,
- +useFrontCamera: boolean,
+hasCamerasOnBothSides: boolean,
+autoFocusPointOfInterest: ?{
x: number,
@@ -315,7 +316,6 @@
this.state = {
zoom: 0,
- useFrontCamera: props.deviceCameraInfo.defaultUseFrontCamera,
hasCamerasOnBothSides: props.deviceCameraInfo.hasCamerasOnBothSides,
autoFocusPointOfInterest: undefined,
stagingMode: false,
@@ -666,7 +666,7 @@
if (this.state.hasCamerasOnBothSides) {
switchCameraButton = (
<TouchableOpacity
- onPress={this.switchCamera}
+ onPress={this.props.switchCamera}
onLayout={this.onSwitchCameraButtonLayout}
style={styles.switchCameraButton}
ref={this.switchCameraButtonRef}
@@ -736,7 +736,7 @@
const statusBar = this.props.isActive ? (
<ConnectedStatusBar hidden />
) : null;
- const type = this.state.useFrontCamera
+ const type = this.props.useFrontCamera
? RNCamera.Constants.Type.front
: RNCamera.Constants.Type.back;
return (
@@ -855,14 +855,14 @@
invariant(camera, 'camera ref should be set');
this.setState({ stagingMode: true });
- // We avoid flipping this.state.useFrontCamera if we discover we don't
+ // We avoid flipping this.props.useFrontCamera if we discover we don't
// actually have a back camera since it causes a bit of lag, but this
// means there are cases where it is false but we are actually using the
// front camera
const { hasCamerasOnBothSides, defaultUseFrontCamera } =
this.props.deviceCameraInfo;
const usingFrontCamera =
- this.state.useFrontCamera ||
+ this.props.useFrontCamera ||
(!hasCamerasOnBothSides && defaultUseFrontCamera);
const startTime = Date.now();
@@ -929,12 +929,6 @@
});
};
- switchCamera = () => {
- this.setState((prevState: State) => ({
- useFrontCamera: !prevState.useFrontCamera,
- }));
- };
-
updateZoom = ([zoom]: [number]) => {
this.setState({ zoom });
};
@@ -1197,6 +1191,14 @@
});
}, []);
+ const [useFrontCamera, setUseFrontCamera] = React.useState(
+ deviceCameraInfo.defaultUseFrontCamera,
+ );
+
+ const switchCamera = React.useCallback(() => {
+ setUseFrontCamera(prevUseFrontCamera => !prevUseFrontCamera);
+ }, []);
+
return (
<CameraModal
{...props}
@@ -1209,6 +1211,8 @@
isActive={isActive}
flashMode={flashMode}
changeFlashMode={changeFlashMode}
+ useFrontCamera={useFrontCamera}
+ switchCamera={switchCamera}
/>
);
});

File Metadata

Mime Type
text/plain
Expires
Sun, Jan 18, 2:28 PM (4 h, 41 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5951976
Default Alt Text
D14223.1768746481.diff (2 KB)

Event Timeline