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 @@ -30,14 +30,12 @@ runOnJS, interpolate, Extrapolate, - type SharedValue, } from 'react-native-reanimated'; import { SafeAreaView } from 'react-native-safe-area-context'; import { pathFromURI, filenameFromPathOrURI } from 'lib/media/file-utils.js'; import { useIsAppForegrounded } from 'lib/shared/lifecycle-utils.js'; import type { PhotoCapture } from 'lib/types/media-types.js'; -import type { Dispatch } from 'lib/types/redux-types.js'; import { useDispatch } from 'lib/utils/redux-utils.js'; import SendMediaButton from './send-media-button.react.js'; @@ -45,17 +43,11 @@ import ContentLoading from '../components/content-loading.react.js'; import ConnectedStatusBar from '../connected-status-bar.react.js'; import type { AppNavigationProp } from '../navigation/app-navigator.react.js'; -import { - OverlayContext, - type OverlayContextType, -} from '../navigation/overlay-context.js'; +import { OverlayContext } from '../navigation/overlay-context.js'; import { updateDeviceCameraInfoActionType } from '../redux/action-types.js'; -import { type DimensionsInfo } from '../redux/dimensions-updater.react.js'; import { useSelector } from '../redux/redux-utils.js'; import { colors } from '../themes/colors.js'; -import { type DeviceCameraInfo } from '../types/camera.js'; import type { NativeMethods } from '../types/react-native.js'; -import { type ViewStyle } from '../types/styles.js'; import { clampV2 } from '../utils/animation-utils.js'; const maxZoom = 16; @@ -121,7 +113,7 @@ height: number, }; -type BaseProps = { +type Props = { +handlePhotoCapture: (capture: PhotoCapture) => mixed, +navigation: | AppNavigationProp<'ChatCameraModal'> @@ -129,221 +121,6 @@ | AppNavigationProp<'ThreadAvatarCameraModal'> | AuthNavigationProp<'RegistrationUserAvatarCameraModal'>, }; -type Props = { - ...BaseProps, - // Redux state - +dimensions: DimensionsInfo, - +deviceCameraInfo: DeviceCameraInfo, - +deviceOrientation: Orientations, - +foreground: boolean, - // Redux dispatch functions - +dispatch: Dispatch, - // withOverlayContext - +overlayContext: ?OverlayContextType, - +isActive: boolean, - +flashMode: number, - +changeFlashMode: () => void, - +useFrontCamera: boolean, - +switchCamera: () => void, - +hasCamerasOnBothSides: boolean, - +fetchCameraIDs: (camera: RNCamera) => Promise, - +autoFocusPointOfInterest: AutoFocusPointOfInterest, - +setAutoFocusPointOfInterest: AutoFocusPointOfInterest => void, - +focusOnPoint: (input: [number, number]) => void, - +zoom: number, - +setZoom: (zoom: number) => void, - +stagingMode: boolean, - +setStagingMode: (stagingMode: boolean) => void, - +pendingPhotoCapture: ?PhotoCapture, - +setPendingPhotoCapture: (?PhotoCapture) => void, - +camera: { current: ?RNCamera }, - +takePhoto: () => Promise, - +close: () => void, - +sendPhoto: () => Promise, - +clearPendingImage: () => void, - +gesture: ExclusiveGesture, - +closeButtonRef: { current: ?React.ElementRef }, - +photoButtonRef: { current: ?React.ElementRef }, - +switchCameraButtonRef: { - current: ?React.ElementRef, - }, - +flashButtonRef: { current: ?React.ElementRef }, - +onCloseButtonLayout: () => void, - +onPhotoButtonLayout: () => void, - +onSwitchCameraButtonLayout: () => void, - +onFlashButtonLayout: () => void, - +cancelFocusAnimation: () => void, - +focusIndicatorStyle: ViewStyle, - +stagingModeProgress: SharedValue, - +overlayStyle: ViewStyle, - +sendButtonProgress: Animated.Value, - +sendButtonStyle: ViewStyle, - +containerStyle: ViewStyle, -}; - -class CameraModal extends React.PureComponent { - renderCamera = ({ - camera, - status, - }: { - +camera: RNCamera & { +_cameraHandle?: mixed, ... }, - status: RNCameraStatus, - ... - }): React.Node => { - if (camera && camera._cameraHandle) { - void this.props.fetchCameraIDs(camera); - } - if (this.props.stagingMode) { - return this.renderStagingView(); - } - - return ( - - - {this.renderCameraContent(status)} - - × - - - - ); - }; - - renderStagingView(): React.Node { - let image = null; - const { pendingPhotoCapture } = this.props; - if (pendingPhotoCapture) { - const imageSource = { uri: pendingPhotoCapture.uri }; - image = ; - } else { - image = ; - } - - return ( - <> - {image} - - - - - - - - - - ); - } - - renderCameraContent(status: RNCameraStatus): React.Node { - if (status === 'PENDING_AUTHORIZATION') { - return ; - } else if (status === 'NOT_AUTHORIZED') { - return ( - - - {'don’t have permission :('} - - - ); - } - - let switchCameraButton = null; - if (this.props.hasCamerasOnBothSides) { - switchCameraButton = ( - - - - ); - } - - let flashIcon; - if (this.props.flashMode === RNCamera.Constants.FlashMode.on) { - flashIcon = ; - } else if (this.props.flashMode === RNCamera.Constants.FlashMode.off) { - flashIcon = ; - } else { - flashIcon = ( - <> - - A - - ); - } - - return ( - - - - - {flashIcon} - - - - - - {switchCameraButton} - - - - ); - } - - render(): React.Node { - const statusBar = this.props.isActive ? ( -