diff --git a/native/components/full-screen-view-modal.react.js b/native/components/full-screen-view-modal.react.js --- a/native/components/full-screen-view-modal.react.js +++ b/native/components/full-screen-view-modal.react.js @@ -37,18 +37,11 @@ import SWMansionIcon from './swmansion-icon.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 type { NavigationRoute } from '../navigation/route-names.js'; import { useSelector } from '../redux/redux-utils.js'; -import { - type DerivedDimensionsInfo, - derivedDimensionsInfoSelector, -} from '../selectors/dimensions-selectors.js'; +import { derivedDimensionsInfoSelector } from '../selectors/dimensions-selectors.js'; import type { NativeMethods } from '../types/react-native.js'; -import type { AnimatedViewStyle, ViewStyle } from '../types/styles.js'; import type { UserProfileBottomSheetNavigationProp } from '../user-profile/user-profile-bottom-sheet-navigator.react.js'; import { clampV2 } from '../utils/animation-utils.js'; @@ -71,7 +64,7 @@ +height: number, }; -type BaseProps = { +type Props = { +navigation: | AppNavigationProp<'ImageModal'> | UserProfileBottomSheetNavigationProp<'UserProfileAvatarModal'>, @@ -83,134 +76,728 @@ +saveContentCallback?: () => Promise, +copyContentCallback?: () => mixed, }; -type Props = { - ...BaseProps, - // Redux state - +dimensions: DerivedDimensionsInfo, - // withOverlayContext - +overlayContext: ?OverlayContextType, - +isActive: boolean, - +closeButtonEnabled: boolean, - +actionLinksEnabled: boolean, - +gesture: ExclusiveGesture, - +closeButtonRef: { current: ?React.ElementRef }, - +mediaIconsRef: { current: ?React.ElementRef }, - +onCloseButtonLayout: () => void, - +onMediaIconsLayout: () => void, - +close: () => void, - +contentViewContainerStyle: ViewStyle, - +animatedBackdropStyle: AnimatedViewStyle, - +animatedCloseButtonStyle: AnimatedViewStyle, - +animatedMediaIconsButtonStyle: AnimatedViewStyle, -}; -class FullScreenViewModal extends React.PureComponent { - get contentContainerStyle(): ViewStyle { - const { verticalBounds } = this.props.route.params; - const fullScreenHeight = this.props.dimensions.height; - const top = verticalBounds.y; - const bottom = fullScreenHeight - verticalBounds.y - verticalBounds.height; +function FullScreenViewModal(props: Props) { + const dimensions = useSelector(derivedDimensionsInfoSelector); + const overlayContext = React.useContext(OverlayContext); - // margin will clip, but padding won't - const verticalStyle = this.props.isActive - ? { paddingTop: top, paddingBottom: bottom } - : { marginTop: top, marginBottom: bottom }; - return [styles.contentContainer, verticalStyle]; - } + invariant(overlayContext, 'FullScreenViewModal should have OverlayContext'); - render(): React.Node { - const { children, saveContentCallback, copyContentCallback } = this.props; + const isActive = !overlayContext.isDismissing; - const statusBar = this.props.isActive ? ( -