Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
WhidRubeld committed Feb 14, 2023
2 parents 75e4533 + 51d1b3c commit fa487ef
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
3 changes: 3 additions & 0 deletions example/src/ImageExamples.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ export default function ImageExamples() {
ref={imageRef}
uri='https://picsum.photos/3840/2160.jpg?random=first'
manager='images'
// headers={{
// 'Authorization': `${token_type} ${access_token}`
// }}
toggleButtons
autoLoad={false}
style={styles.image}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "expo-cache-manager",
"version": "0.2.1",
"version": "0.2.2",
"description": "Library for handling data caching for React Native with expo-cache-manager",
"main": "lib/commonjs/index",
"module": "lib/module/index",
Expand Down
22 changes: 15 additions & 7 deletions src/CachingImage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ import {
Pressable,
ImageStyle,
Image,
ColorValue
ColorValue,
ImageResizeMode
} from 'react-native'
import { CacheEntryStatus } from './CacheEntry.class'
import { CacheEntryDownloadOptions, CacheEntryStatus } from './CacheEntry.class'
import { useCacheFile } from './hooks'
import { ProgressIcon } from './ProgressIcon'
import ProgressIndicator, { ProgressIndicatorProps } from './ProgressIndicator'
Expand All @@ -17,6 +18,7 @@ export type CachingImageProps = {
manager: string
uri: string
style?: StyleProp<ImageStyle>
resizeMode?: ImageResizeMode
backgroundColor?: ColorValue
progressDelay?: number
autoLoad?: boolean
Expand All @@ -25,7 +27,7 @@ export type CachingImageProps = {
ProgressIndicatorProps,
'progress' | 'children' | 'delay'
>
}
} & CacheEntryDownloadOptions

export const defaultCacheImageProgressProps: Omit<
ProgressIndicatorProps,
Expand Down Expand Up @@ -54,11 +56,13 @@ export const CachingImage = forwardRef<
manager,
uri,
style,
resizeMode = 'cover',
backgroundColor = '#cccccc',
progressDelay = 2e2,
autoLoad = true,
toggleButtons = false,
progressProps
progressProps,
...options
},
ref
) => {
Expand Down Expand Up @@ -87,7 +91,7 @@ export const CachingImage = forwardRef<
const processingHandler = useCallback(() => {
switch (status) {
case CacheEntryStatus.Pending: {
downloadAsync()
downloadAsync(options)
break
}
case CacheEntryStatus.Progress: {
Expand All @@ -99,7 +103,7 @@ export const CachingImage = forwardRef<
break
}
}
}, [status, downloadAsync, pauseAsync, resumeAsync, toggleButtons])
}, [status, downloadAsync, pauseAsync, resumeAsync, toggleButtons, options])

useEffect(() => {
if (ready && autoLoad && status === CacheEntryStatus.Pending) {
Expand All @@ -110,7 +114,11 @@ export const CachingImage = forwardRef<
return (
<View style={[styles.inner, style, { backgroundColor }]}>
{path && progress === 100 ? (
<Image source={{ uri: path }} style={styles.container} />
<Image
source={{ uri: path }}
style={styles.container}
resizeMode={resizeMode}
/>
) : (
<View style={styles.container} />
)}
Expand Down

0 comments on commit fa487ef

Please sign in to comment.