Make FastImageExample work without a local server.
This commit is contained in:
parent
26fbc2fd98
commit
ba3174ee48
|
@ -6,11 +6,24 @@ import FastImage from 'react-native-fast-image'
|
||||||
import timeout from 'react-timeout'
|
import timeout from 'react-timeout'
|
||||||
import uuid from 'uuid/v4'
|
import uuid from 'uuid/v4'
|
||||||
|
|
||||||
const baseUrl = '192.168.2.11'
|
const getImageUrl = (id, width, height) =>
|
||||||
const image1 = `http://${baseUrl}:8080/pictures/ahmed-saffu-235616.jpg`
|
`https://source.unsplash.com/${id}/${width}x${height}`
|
||||||
const image2 = `http://${baseUrl}:8080/pictures/alex-bertha-236361.jpg`
|
let IMAGE_1
|
||||||
const image3 = `http://${baseUrl}:8080/pictures/jaromir-kavan-233699.jpg`
|
let IMAGE_2
|
||||||
|
let IMAGE_3
|
||||||
|
const IMAGE_SIZE = 150
|
||||||
|
const USE_SERVER = false
|
||||||
const token = 'someToken'
|
const token = 'someToken'
|
||||||
|
if (USE_SERVER) {
|
||||||
|
const baseUrl = '192.168.2.11'
|
||||||
|
IMAGE_1 = `http://${baseUrl}:8080/pictures/ahmed-saffu-235616.jpg`
|
||||||
|
IMAGE_2 = `http://${baseUrl}:8080/pictures/alex-bertha-236361.jpg`
|
||||||
|
IMAGE_3 = `http://${baseUrl}:8080/pictures/jaromir-kavan-233699.jpg`
|
||||||
|
} else {
|
||||||
|
IMAGE_1 = getImageUrl('x58soEovG_M', IMAGE_SIZE, IMAGE_SIZE)
|
||||||
|
IMAGE_2 = getImageUrl('yPI7myL5eWY', IMAGE_SIZE, IMAGE_SIZE)
|
||||||
|
IMAGE_3 = getImageUrl('S7VCcp6KCKE', IMAGE_SIZE, IMAGE_SIZE)
|
||||||
|
}
|
||||||
|
|
||||||
class FastImageExample extends Component {
|
class FastImageExample extends Component {
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
|
@ -44,7 +57,7 @@ class FastImageExample extends Component {
|
||||||
<FastImage
|
<FastImage
|
||||||
style={styles.image}
|
style={styles.image}
|
||||||
source={{
|
source={{
|
||||||
uri: image1 + bust,
|
uri: IMAGE_1 + bust,
|
||||||
headers: {
|
headers: {
|
||||||
token,
|
token,
|
||||||
},
|
},
|
||||||
|
@ -54,7 +67,7 @@ class FastImageExample extends Component {
|
||||||
<FastImage
|
<FastImage
|
||||||
style={styles.image}
|
style={styles.image}
|
||||||
source={{
|
source={{
|
||||||
uri: image2 + bust,
|
uri: IMAGE_2 + bust,
|
||||||
headers: {
|
headers: {
|
||||||
token,
|
token,
|
||||||
},
|
},
|
||||||
|
@ -64,7 +77,7 @@ class FastImageExample extends Component {
|
||||||
<FastImage
|
<FastImage
|
||||||
style={styles.image}
|
style={styles.image}
|
||||||
source={{
|
source={{
|
||||||
uri: image3 + bust,
|
uri: IMAGE_3 + bust,
|
||||||
headers: {
|
headers: {
|
||||||
token,
|
token,
|
||||||
},
|
},
|
||||||
|
@ -90,8 +103,6 @@ FastImageExample.navigationOptions = {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
const IMAGE_SIZE = 150
|
|
||||||
|
|
||||||
const styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
bold: {
|
bold: {
|
||||||
fontWeight: '900',
|
fontWeight: '900',
|
||||||
|
|
Loading…
Reference in New Issue