-
Notifications
You must be signed in to change notification settings - Fork 30
/
App.js
60 lines (57 loc) · 1.39 KB
/
App.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
import React from 'react';
import { StyleSheet, Text, View, Button, ScrollView,Image} from 'react-native';
import ImageBrowser from './ImageBrowser';
export default class App extends React.Component {
constructor(props) {
super(props);
this.state = {
imageBrowserOpen: false,
photos: []
}
}
imageBrowserCallback = (callback) => {
callback.then((photos) => {
console.log(photos)
this.setState({
imageBrowserOpen: false,
photos
})
}).catch((e) => console.log(e))
}
renderImage(item, i) {
return(
<Image
style={{height: 100, width: 100}}
source={{uri: item.file}}
key={i}
/>
)
}
render() {
if (this.state.imageBrowserOpen) {
return(<ImageBrowser max={4} callback={this.imageBrowserCallback}/>);
}
return (
<View style={styles.container}>
<Button
title="Choose Images"
onPress={() => this.setState({imageBrowserOpen: true})}
/>
<Text>This is an example of a</Text>
<Text>multi image selector using expo</Text>
<ScrollView>
{this.state.photos.map((item,i) => this.renderImage(item,i))}
</ScrollView>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
marginTop: 30,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
},
});