-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
144 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import React, { ReactElement, useState } from 'react' | ||
import { Platform, StyleProp } from 'react-native' | ||
import FastImage, { | ||
Source, | ||
ImageStyle as FastImageStyle, | ||
} from 'react-native-fast-image' | ||
|
||
type FastImagePlaceholderProps = { | ||
source: Source | number | ||
style?: StyleProp<FastImageStyle> | ||
placeholder: Source | number | ||
} | ||
|
||
function FastImagePlaceholder({ | ||
source, | ||
style, | ||
placeholder, | ||
}: FastImagePlaceholderProps): ReactElement { | ||
const isLocalSource = typeof source !== 'number' | ||
const [loading, setLoading] = useState(isLocalSource) | ||
|
||
return ( | ||
<> | ||
{loading && <FastImage source={placeholder} style={style} />} | ||
<FastImage | ||
source={source} | ||
style={loading ? { flex: 0 } : style} | ||
onLoad={(): void => setLoading(false)} | ||
fallback={Platform.OS === 'android' && isLocalSource} | ||
/> | ||
</> | ||
) | ||
} | ||
|
||
export default FastImagePlaceholder |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.