import React, { Component } from 'react';
import { View, Text, Image } from 'react-native';
import Gallery from 'react-native-image-gallery';
import { getImageofProducts } from '../NetworkAPI/index';
export default class DemoGallery extends Component {
constructor(props) {
super(props);
this.state = {
index: 0,
images: [
{source: { uri: 'http://i.imgur.com/Vv4bmwR.jpg' } }
],
listImagesLink: [],
};
this.onChangeImage = this.onChangeImage.bind(this);
}
componentDidMount=() => {
this.refreshDatafromServer();
}
refreshDatafromServer = async () => {
let { images } = this.state;
try {
const { navigation } = this.props;
const itemId = navigation.getParam('IdImage', 'NO-ID');
const response = await fetch('http://datapplication.tryfcomet.com/api/pro_images/'+itemId)
let json = await response.json();
json = json.map(x =>({...x, source: {uri: x.linkImage}}))
images = images.concat(json);
} catch (error) {
console.log(error)
}
this.setState({images})
}
static navigationOptions = {
title: 'Danh Mục',
headerStyle: {
backgroundColor: '#3ee2bf',
},
headerTintColor: '#fff',
headerTitleStyle: {
fontWeight: '400',
marginLeft: 95,
marginTop: 10,
fontSize: 28,
fontFamily: "Lobster-Regular",
},
headerRight: (
),
};
onChangeImage(index) {
this.setState({ index });
}
renderError() {
return (
This image cannot be displayed...
... but this is fine :)
);
}
get galleryCount() {
const { index, images } = this.state;
return (
{index + 1} / {images.length}
);
}
render() {
return (
{this.galleryCount}
);
}
}