-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExPhotoGallery.js
More file actions
76 lines (69 loc) · 1.6 KB
/
Copy pathExPhotoGallery.js
File metadata and controls
76 lines (69 loc) · 1.6 KB
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
'use strict';
let React = require('react-native');
let {
Image,
ScrollView,
StyleSheet,
View,
} = React;
let PHOTO_SPACING = 40;
let IMAGE_SOURCES = [
// hedgehog
{uri: 'https://i.imgur.com/8049SBB.jpg'},
// kittens
{uri: 'https://i.imgur.com/m7DZR1A.jpg'},
// flower hamsters
{uri: 'https://i.imgur.com/BeMfZu3.jpg'},
// puppy
{uri: 'https://i.imgur.com/ExQom0o.jpg'},
// duckling
{uri: 'https://i.imgur.com/cSb7OTE.jpg'},
// polar bear
{uri: 'https://i.imgur.com/xlhiPb9.jpg'},
];
class ExPhotoGallery extends React.Component {
render() {
return (
<ScrollView
horizontal
scrollsToTop={false}
automaticallyAdjustContentInsets={false}
showsHorizontalScrollIndicator={false}
pagingEnabled
style={[styles.container, this.props.style]}>
{IMAGE_SOURCES.map(source =>
this._renderPhoto(source, { width: 320, height: 240 })
)}
</ScrollView>
);
}
_renderPhoto(source, size) {
return (
<View key={source.uri} style={styles.photoContainer}>
<Image source={source} style={[styles.photo, size]} />
</View>
);
}
}
let styles = StyleSheet.create({
container: {
flex: 0,
width: 320 + PHOTO_SPACING,
alignSelf: 'center',
marginTop: 16,
marginBottom: 12,
overflow: 'visible',
},
photoContainer: {
marginHorizontal: PHOTO_SPACING / 2,
overflow: 'visible',
shadowRadius: 3,
shadowColor: '#000',
shadowOpacity: 0.3,
shadowOffset: { width: 0, height: 1 },
},
photo: {
overflow: 'visible',
},
});
module.exports = ExPhotoGallery;