This commit is contained in:
xmflsct 2022-10-30 15:05:40 +01:00
parent 10e22f9d4a
commit d203c00279
3 changed files with 5 additions and 27 deletions

View File

@ -326,11 +326,7 @@ const Screens: React.FC<Props> = ({ localCorrupt }) => {
<Stack.Screen <Stack.Screen
name='Screen-ImagesViewer' name='Screen-ImagesViewer'
component={ScreenImagesViewer} component={ScreenImagesViewer}
options={{ options={{ headerShown: false, animation: 'fade' }}
headerShown: false,
presentation: 'fullScreenModal',
animation: 'fade'
}}
/> />
<Stack.Screen <Stack.Screen
name='Screen-AccountSelection' name='Screen-AccountSelection'

View File

@ -5,22 +5,18 @@ import { RootStackParamList } from '@utils/navigation/navigators'
import { Theme } from '@utils/styles/themes' import { Theme } from '@utils/styles/themes'
import * as FileSystem from 'expo-file-system' import * as FileSystem from 'expo-file-system'
import i18next from 'i18next' import i18next from 'i18next'
import { RefObject } from 'react'
import { PermissionsAndroid, Platform } from 'react-native' import { PermissionsAndroid, Platform } from 'react-native'
import FlashMessage from 'react-native-flash-message'
type CommonProps = { type CommonProps = {
messageRef: RefObject<FlashMessage>
theme: Theme theme: Theme
image: RootStackParamList['Screen-ImagesViewer']['imageUrls'][0] image: RootStackParamList['Screen-ImagesViewer']['imageUrls'][0]
} }
const saveIos = async ({ messageRef, theme, image }: CommonProps) => { const saveIos = async ({ theme, image }: CommonProps) => {
CameraRoll.save(image.url) CameraRoll.save(image.url)
.then(() => { .then(() => {
haptics('Success') haptics('Success')
displayMessage({ displayMessage({
ref: messageRef,
theme, theme,
type: 'success', type: 'success',
message: i18next.t('screenImageViewer:content.save.succeed') message: i18next.t('screenImageViewer:content.save.succeed')
@ -32,7 +28,6 @@ const saveIos = async ({ messageRef, theme, image }: CommonProps) => {
.then(() => { .then(() => {
haptics('Success') haptics('Success')
displayMessage({ displayMessage({
ref: messageRef,
theme, theme,
type: 'success', type: 'success',
message: i18next.t('screenImageViewer:content.save.succeed') message: i18next.t('screenImageViewer:content.save.succeed')
@ -41,7 +36,6 @@ const saveIos = async ({ messageRef, theme, image }: CommonProps) => {
.catch(() => { .catch(() => {
haptics('Error') haptics('Error')
displayMessage({ displayMessage({
ref: messageRef,
theme, theme,
type: 'error', type: 'error',
message: i18next.t('screenImageViewer:content.save.failed') message: i18next.t('screenImageViewer:content.save.failed')
@ -50,7 +44,6 @@ const saveIos = async ({ messageRef, theme, image }: CommonProps) => {
} else { } else {
haptics('Error') haptics('Error')
displayMessage({ displayMessage({
ref: messageRef,
theme, theme,
type: 'error', type: 'error',
message: i18next.t('screenImageViewer:content.save.failed') message: i18next.t('screenImageViewer:content.save.failed')
@ -59,7 +52,7 @@ const saveIos = async ({ messageRef, theme, image }: CommonProps) => {
}) })
} }
const saveAndroid = async ({ messageRef, theme, image }: CommonProps) => { const saveAndroid = async ({ theme, image }: CommonProps) => {
const fileUri: string = `${FileSystem.documentDirectory}${image.id}.jpg` const fileUri: string = `${FileSystem.documentDirectory}${image.id}.jpg`
const downloadedFile: FileSystem.FileSystemDownloadResult = const downloadedFile: FileSystem.FileSystemDownloadResult =
await FileSystem.downloadAsync(image.url, fileUri) await FileSystem.downloadAsync(image.url, fileUri)
@ -67,7 +60,6 @@ const saveAndroid = async ({ messageRef, theme, image }: CommonProps) => {
if (downloadedFile.status != 200) { if (downloadedFile.status != 200) {
haptics('Error') haptics('Error')
displayMessage({ displayMessage({
ref: messageRef,
theme, theme,
type: 'error', type: 'error',
message: i18next.t('screenImageViewer:content.save.failed') message: i18next.t('screenImageViewer:content.save.failed')
@ -83,7 +75,6 @@ const saveAndroid = async ({ messageRef, theme, image }: CommonProps) => {
if (status !== 'granted') { if (status !== 'granted') {
haptics('Error') haptics('Error')
displayMessage({ displayMessage({
ref: messageRef,
theme, theme,
type: 'error', type: 'error',
message: i18next.t('screenImageViewer:content.save.failed') message: i18next.t('screenImageViewer:content.save.failed')
@ -96,7 +87,6 @@ const saveAndroid = async ({ messageRef, theme, image }: CommonProps) => {
.then(() => { .then(() => {
haptics('Success') haptics('Success')
displayMessage({ displayMessage({
ref: messageRef,
theme, theme,
type: 'success', type: 'success',
message: i18next.t('screenImageViewer:content.save.succeed') message: i18next.t('screenImageViewer:content.save.succeed')
@ -105,7 +95,6 @@ const saveAndroid = async ({ messageRef, theme, image }: CommonProps) => {
.catch(() => { .catch(() => {
haptics('Error') haptics('Error')
displayMessage({ displayMessage({
ref: messageRef,
theme, theme,
type: 'error', type: 'error',
message: i18next.t('screenImageViewer:content.save.failed') message: i18next.t('screenImageViewer:content.save.failed')

View File

@ -1,7 +1,6 @@
import analytics from '@components/analytics' import analytics from '@components/analytics'
import GracefullyImage from '@components/GracefullyImage' import GracefullyImage from '@components/GracefullyImage'
import { HeaderCenter, HeaderLeft, HeaderRight } from '@components/Header' import { HeaderCenter, HeaderLeft, HeaderRight } from '@components/Header'
import { Message } from '@components/Message'
import { useActionSheet } from '@expo/react-native-action-sheet' import { useActionSheet } from '@expo/react-native-action-sheet'
import { RootStackScreenProps } from '@utils/navigation/navigators' import { RootStackScreenProps } from '@utils/navigation/navigators'
import { useTheme } from '@utils/styles/ThemeManager' import { useTheme } from '@utils/styles/ThemeManager'
@ -51,7 +50,6 @@ const ScreenImagesViewer = ({
const initialIndex = imageUrls.findIndex(image => image.id === id) const initialIndex = imageUrls.findIndex(image => image.id === id)
const [currentIndex, setCurrentIndex] = useState(initialIndex) const [currentIndex, setCurrentIndex] = useState(initialIndex)
const listRef = useRef<FlatList>(null)
const messageRef = useRef<FlashMessage>(null) const messageRef = useRef<FlashMessage>(null)
const { showActionSheetWithOptions } = useActionSheet() const { showActionSheetWithOptions } = useActionSheet()
@ -71,7 +69,7 @@ const ScreenImagesViewer = ({
switch (buttonIndex) { switch (buttonIndex) {
case 0: case 0:
analytics('imageviewer_more_save_press') analytics('imageviewer_more_save_press')
saveImage({ messageRef, theme, image: imageUrls[currentIndex] }) saveImage({ theme, image: imageUrls[currentIndex] })
break break
case 1: case 1:
analytics('imageviewer_more_share_press') analytics('imageviewer_more_share_press')
@ -193,11 +191,7 @@ const ScreenImagesViewer = ({
switch (buttonIndex) { switch (buttonIndex) {
case 0: case 0:
analytics('imageviewer_more_save_press') analytics('imageviewer_more_save_press')
saveImage({ saveImage({ theme, image: imageUrls[currentIndex] })
messageRef,
theme,
image: imageUrls[currentIndex]
})
break break
case 1: case 1:
analytics('imageviewer_more_share_press') analytics('imageviewer_more_share_press')
@ -236,7 +230,6 @@ const ScreenImagesViewer = ({
/> />
</LongPressGestureHandler> </LongPressGestureHandler>
</FlingGestureHandler> </FlingGestureHandler>
<Message ref={messageRef} />
</SafeAreaProvider> </SafeAreaProvider>
) )
} }