-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.ios.js
103 lines (90 loc) · 2.07 KB
/
index.ios.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
/**
* InstaTest - just an API call experiment in React Native
* @flow
*/
import React, { Component } from 'react';
import {
AppRegistry,
StyleSheet,
Text,
View,
Image
} from 'react-native';
class ImageGrid extends Component {
constructor(props) {
super(props);
if (props.name) {
fetch(`https://www.instagram.com/${props.name}/media`)
.then( result => result.json() )
.then( result => {
console.log(result);
this.setState({
error: null,
images: result.items.map(item => item.images.low_resolution)
});
}, reject => {
console.log("Epic fail", reject);
this.setState({ images: [], error: reject });
});
}
}
render() {
if (this.state && this.state.images && this.state.images.length > 0) {
let imgs = this.state.images.map(img =>
<Image source={{ uri: img.url }} style={styles.image} key={img.url} />
);
return (
<View style={styles.imageGrid}>
{imgs}
</View>
);
} else {
return (
<Text style={styles.text}>No images or no username.</Text>
);
}
}
}
export default class InstaTest extends Component {
constructor() {
super();
}
editUser() {
console.log("Meemid");
}
render() {
return (
<View style={styles.container}>
<Text onclick={this.editUser} style={styles.text}>{this.state ? this.state.name : "punanekleeps"}</Text>
<ImageGrid name={this.state ? this.state.name : "punanekleeps"} />
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'flex-start',
alignItems: 'center',
backgroundColor: '#121212',
paddingTop: 18
},
imageGrid: {
flex: 1,
flexDirection: 'row',
flexWrap: 'wrap',
justifyContent: 'space-between',
alignItems: 'center'
},
text: {
color: '#FDFDFD',
height: 35,
lineHeight: 35
},
image: {
margin: 5,
width: 75,
height: 75
}
});
AppRegistry.registerComponent('InstaTest', () => InstaTest);