-
Notifications
You must be signed in to change notification settings - Fork 46
/
App.js
105 lines (101 loc) · 3.29 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
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
104
105
import React, {Component} from 'react';
import {
SafeAreaView,
Dimensions,
StyleSheet,
ScrollView,
View,
} from 'react-native';
import Preview from './src/Preview';
import FlatListSlider from './src/FlatListSlider';
// import {FlatListSlider} from 'react-native-flatlist-slider';
export default class extends Component {
constructor(props) {
super(props);
this.state = {
data: [
{
image:
'https://images.unsplash.com/photo-1567226475328-9d6baaf565cf?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=400&q=60',
desc: 'Silent Waters in the mountains in midst of Himilayas',
},
{
image:
'https://images.unsplash.com/photo-1455620611406-966ca6889d80?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1130&q=80',
desc:
'Red fort in India New Delhi is a magnificient masterpeiece of humans',
},
{
image:
'https://images.unsplash.com/photo-1477587458883-47145ed94245?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1050&q=80',
desc:
'Sample Description below the image for representation purpose only',
},
{
image:
'https://images.unsplash.com/photo-1568700942090-19dc36fab0c4?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1050&q=80',
desc:
'Sample Description below the image for representation purpose only',
},
{
image:
'https://images.unsplash.com/photo-1584271854089-9bb3e5168e32?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1051&q=80',
desc:
'Sample Description below the image for representation purpose only',
},
],
};
}
render() {
const screenWidth = Math.round(Dimensions.get('window').width);
return (
<SafeAreaView>
<ScrollView>
<FlatListSlider
data={this.state.data}
timer={2000}
imageKey={'image'}
local={false}
width={screenWidth}
separator={0}
loop={true}
autoscroll={true}
currentIndexCallback={index => console.log('Index', index)}
onPress={item => alert(JSON.stringify(item))}
indicator
animation
/>
<View style={styles.separator} />
<FlatListSlider
data={this.state.data}
width={275}
timer={4000}
component={<Preview />}
onPress={item => alert(JSON.stringify(item))}
indicatorActiveWidth={40}
contentContainerStyle={styles.contentStyle}
/>
<View style={styles.separator} />
<FlatListSlider
data={this.state.data}
timer={5000}
onPress={item => alert(JSON.stringify(item))}
indicatorContainerStyle={{position:'absolute', bottom: 20}}
indicatorActiveColor={'#8e44ad'}
indicatorInActiveColor={'#ffffff'}
indicatorActiveWidth={30}
animation
/>
</ScrollView>
</SafeAreaView>
);
}
}
const styles = StyleSheet.create({
separator: {
height: 20,
},
contentStyle: {
paddingHorizontal: 16,
},
});