2018-09-23 18:40:18 -04:00
|
|
|
import React from 'react'
|
|
|
|
|
import { PixelRatio, StyleSheet, View } from 'react-native'
|
|
|
|
|
import withCacheBust from './withCacheBust'
|
2020-07-16 23:31:44 -04:00
|
|
|
import { FastImage } from 'react-native-fast-image'
|
2018-09-23 18:40:18 -04:00
|
|
|
import Section from './Section'
|
|
|
|
|
import SectionFlex from './SectionFlex'
|
|
|
|
|
import FeatureText from './FeatureText'
|
|
|
|
|
|
2020-03-12 02:27:37 -04:00
|
|
|
const getImageUrl = (id: string, width: number, height: number) =>
|
2018-09-23 18:40:18 -04:00
|
|
|
`https://source.unsplash.com/${id}/${width}x${height}`
|
|
|
|
|
const IMAGE_SIZE = 1024
|
|
|
|
|
const IMAGE_SIZE_PX = PixelRatio.getPixelSizeForLayoutSize(IMAGE_SIZE)
|
|
|
|
|
const IMAGE_URLS = [
|
|
|
|
|
getImageUrl('x58soEovG_M', IMAGE_SIZE_PX, IMAGE_SIZE_PX),
|
|
|
|
|
getImageUrl('yPI7myL5eWY', IMAGE_SIZE_PX, IMAGE_SIZE_PX),
|
|
|
|
|
getImageUrl('S7VCcp6KCKE', IMAGE_SIZE, IMAGE_SIZE),
|
|
|
|
|
]
|
|
|
|
|
|
2020-03-12 02:27:37 -04:00
|
|
|
interface PriorityExampleProps {
|
|
|
|
|
onPressReload: () => void
|
|
|
|
|
bust: string
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const PriorityExample = ({ onPressReload, bust }: PriorityExampleProps) => (
|
2018-09-23 18:40:18 -04:00
|
|
|
<View>
|
|
|
|
|
<Section>
|
|
|
|
|
<FeatureText text="• Prioritize images (low, normal, high)." />
|
|
|
|
|
</Section>
|
|
|
|
|
<SectionFlex onPress={onPressReload}>
|
|
|
|
|
<FastImage
|
|
|
|
|
style={styles.image}
|
|
|
|
|
source={{
|
|
|
|
|
uri: IMAGE_URLS[0] + bust,
|
2020-07-16 23:31:44 -04:00
|
|
|
priority: 'low'
|
2018-09-23 18:40:18 -04:00
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
<FastImage
|
|
|
|
|
style={styles.image}
|
|
|
|
|
source={{
|
|
|
|
|
uri: IMAGE_URLS[1] + bust,
|
2020-07-16 23:31:44 -04:00
|
|
|
priority: 'normal'
|
2018-09-23 18:40:18 -04:00
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
<FastImage
|
|
|
|
|
style={styles.image}
|
|
|
|
|
source={{
|
|
|
|
|
uri: IMAGE_URLS[2] + bust,
|
2020-07-16 23:31:44 -04:00
|
|
|
priority: 'high'
|
2018-09-23 18:40:18 -04:00
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
</SectionFlex>
|
|
|
|
|
</View>
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
const styles = StyleSheet.create({
|
|
|
|
|
image: {
|
|
|
|
|
flex: 1,
|
|
|
|
|
height: 100,
|
|
|
|
|
backgroundColor: '#ddd',
|
|
|
|
|
margin: 10,
|
|
|
|
|
marginVertical: 20,
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
export default withCacheBust(PriorityExample)
|