Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
},
"dependencies": {
"crypto-js": "^3.1.9-1",
"expo-asset": "^6.0.0",
"lodash": "^4.17.4"
},
"peerDependencies": {
Expand Down
9 changes: 7 additions & 2 deletions src/Image.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
StyleProp
} from "react-native";
import { BlurView } from "expo-blur";
import { Asset } from "expo-asset";

import CacheManager, { DownloadOptions } from "./CacheManager";

Expand All @@ -24,6 +25,7 @@ interface ImageProps {
uri: string;
transitionDuration?: number;
tint?: "dark" | "light";
fallback?: number;
}

interface ImageState {
Expand Down Expand Up @@ -66,10 +68,13 @@ export default class Image extends React.Component<ImageProps, ImageState> {
this.mounted = false;
}

async load({ uri, options = {} }: ImageProps): Promise<void> {
async load({ uri, options = {}, fallback }: ImageProps): Promise<void> {
if (uri) {
const path = await CacheManager.get(uri, options).getPath();
let path = await CacheManager.get(uri, options).getPath();
if (this.mounted) {
if (!path && fallback && Number.isInteger(fallback)) {
path = Asset.fromModule(fallback).uri;
}
this.setState({ uri: path });
}
}
Expand Down