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
name='Screen-ImagesViewer'
component={ScreenImagesViewer}
options={{
headerShown: false,
presentation: 'fullScreenModal',
animation: 'fade'
}}
options={{ headerShown: false, animation: 'fade' }}
/>
<Stack.Screen
name='Screen-AccountSelection'

View File

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

View File

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