-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathSlides.js
59 lines (54 loc) · 1.27 KB
/
Slides.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
import React from 'react';
import { View, Text, ScrollView, Dimensions } from 'react-native';
import { Button } from 'react-native-elements';
const SCREEN_WIDTH = Dimensions.get('window').width;
function Slides({ data, onComplete }) {
const renderSlides = (slides) => {
const renderLastSlide = (index) => {
if (index === slides.length - 1) {
return (
<Button
title='Finished!'
raised
buttonStyle={styles.buttonStyle}
onPress={onComplete}
/>
);
}
};
return slides.map((slide, index) => {
return (
<View key={slide.text} style={[styles.slideStyle, { backgroundColor: slide.color }]}>
<Text style={styles.textStyle}>{slide.text}</Text>
{ renderLastSlide(index) }
</View>
);
});
};
return (
<ScrollView
horizontal
pagingEnabled
style={{ flex: 1 }}
>
{renderSlides(data)}
</ScrollView>);
}
const styles = {
slideStyle: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
width: SCREEN_WIDTH
},
textStyle: {
textAlign: 'center',
fontSize: 27,
color: 'white',
marginBottom: 15
},
buttonStyle: {
backgroundColor: '#0288D1'
}
};
export default Slides;