diff --git a/src/screens/ImagesViewer.tsx b/src/screens/ImagesViewer.tsx index 405a1aaa..23dfb816 100644 --- a/src/screens/ImagesViewer.tsx +++ b/src/screens/ImagesViewer.tsx @@ -19,94 +19,6 @@ import { import ImageViewer from './ImageViewer/Root' import saveImage from './ImageViewer/save' -const HeaderComponent = React.memo( - ({ - messageRef, - navigation, - currentIndex, - imageUrls - }: { - messageRef: RefObject - navigation: NativeStackNavigationProp< - RootStackParamList, - 'Screen-ImagesViewer' - > - currentIndex: number - imageUrls: RootStackParamList['Screen-ImagesViewer']['imageUrls'] - }) => { - const insets = useSafeAreaInsets() - const { mode, theme } = useTheme() - const { t } = useTranslation('screenImageViewer') - const { showActionSheetWithOptions } = useActionSheet() - - const onPress = useCallback(() => { - analytics('imageviewer_more_press') - showActionSheetWithOptions( - { - options: [ - t('content.options.save'), - t('content.options.share'), - t('content.options.cancel') - ], - cancelButtonIndex: 2, - userInterfaceStyle: mode - }, - async buttonIndex => { - switch (buttonIndex) { - case 0: - analytics('imageviewer_more_save_press') - saveImage({ messageRef, theme, image: imageUrls[currentIndex] }) - break - case 1: - analytics('imageviewer_more_share_press') - switch (Platform.OS) { - case 'ios': - await Share.share({ url: imageUrls[currentIndex].url }) - break - case 'android': - await Share.share({ message: imageUrls[currentIndex].url }) - break - } - break - } - } - ) - }, [currentIndex]) - - return ( - - navigation.goBack()} - /> - - - - ) - }, - (prev, next) => prev.currentIndex === next.currentIndex -) - const ScreenImagesViewer = ({ route: { params: { imageUrls, id } @@ -118,13 +30,51 @@ const ScreenImagesViewer = ({ return null } - const { theme } = useTheme() + const insets = useSafeAreaInsets() + + const { mode, theme } = useTheme() + const { t } = useTranslation('screenImageViewer') const initialIndex = imageUrls.findIndex(image => image.id === id) const [currentIndex, setCurrentIndex] = useState(initialIndex) const messageRef = useRef(null) + const { showActionSheetWithOptions } = useActionSheet() + const onPress = useCallback(() => { + analytics('imageviewer_more_press') + showActionSheetWithOptions( + { + options: [ + t('content.options.save'), + t('content.options.share'), + t('content.options.cancel') + ], + cancelButtonIndex: 2, + userInterfaceStyle: mode + }, + async buttonIndex => { + switch (buttonIndex) { + case 0: + analytics('imageviewer_more_save_press') + saveImage({ messageRef, theme, image: imageUrls[currentIndex] }) + break + case 1: + analytics('imageviewer_more_share_press') + switch (Platform.OS) { + case 'ios': + await Share.share({ url: imageUrls[currentIndex].url }) + break + case 'android': + await Share.share({ message: imageUrls[currentIndex].url }) + break + } + break + } + } + ) + }, [currentIndex]) + return (