Try with RN Image instead of fast-image

This commit is contained in:
Zhiyuan Zheng 2021-03-18 23:54:40 +01:00
parent f9f9b783e3
commit 5243f71c8c
No known key found for this signature in database
GPG Key ID: 078A93AB607D85E0
2 changed files with 14 additions and 8 deletions

View File

@ -1,9 +1,15 @@
import { StyleConstants } from '@utils/styles/constants' import { StyleConstants } from '@utils/styles/constants'
import { useTheme } from '@utils/styles/ThemeManager' import { useTheme } from '@utils/styles/ThemeManager'
import React, { useCallback, useMemo, useRef, useState } from 'react' import React, { useCallback, useMemo, useRef, useState } from 'react'
import { Pressable, StyleProp, StyleSheet, ViewStyle } from 'react-native' import {
Image,
ImageStyle,
Pressable,
StyleProp,
StyleSheet,
ViewStyle
} from 'react-native'
import { Blurhash } from 'react-native-blurhash' import { Blurhash } from 'react-native-blurhash'
import FastImage, { ImageStyle } from 'react-native-fast-image'
// blurhas -> if blurhash, show before any loading succeed // blurhas -> if blurhash, show before any loading succeed
// original -> load original // original -> load original
@ -70,7 +76,7 @@ const GracefullyImage = React.memo(
const previewView = useMemo( const previewView = useMemo(
() => () =>
uri.preview && !imageLoaded ? ( uri.preview && !imageLoaded ? (
<FastImage <Image
source={{ uri: uri.preview }} source={{ uri: uri.preview }}
style={[{ flex: 1 }, imageStyle]} style={[{ flex: 1 }, imageStyle]}
/> />
@ -79,14 +85,14 @@ const GracefullyImage = React.memo(
) )
const originalView = useMemo( const originalView = useMemo(
() => ( () => (
<FastImage <Image
source={source} source={source}
style={[{ flex: imageLoaded ? 1 : undefined }, imageStyle]} style={[{ flex: 1 }, imageStyle]}
onLoad={onLoad} onLoad={onLoad}
onError={onError} onError={onError}
/> />
), ),
[source, imageLoaded] [source]
) )
const blurhashView = useMemo(() => { const blurhashView = useMemo(() => {
return blurhash && (hidden || !imageLoaded) ? ( return blurhash && (hidden || !imageLoaded) ? (

View File

@ -86,9 +86,9 @@ const HeaderComponent = React.memo(
analytics('imageviewer_more_share_press') analytics('imageviewer_more_share_press')
switch (Platform.OS) { switch (Platform.OS) {
case 'ios': case 'ios':
return Share.share({ url: imageUrls[currentIndex].url }) Share.share({ url: imageUrls[currentIndex].url })
case 'android': case 'android':
return Share.share({ message: imageUrls[currentIndex].url }) Share.share({ message: imageUrls[currentIndex].url })
} }
break break
} }