forked from ZeusLN/zeus
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIntro.tsx
More file actions
161 lines (151 loc) · 5.49 KB
/
Intro.tsx
File metadata and controls
161 lines (151 loc) · 5.49 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
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
import * as React from 'react';
import { Dimensions, Image, Text, View, SafeAreaView } from 'react-native';
import Carousel, { Pagination } from 'react-native-snap-carousel';
import Button from './../components/Button';
import { localeString } from './../utils/LocaleUtils';
import { themeColor } from './../utils/ThemeUtils';
const One = require('./../assets/images/intro/1.png');
const Two = require('./../assets/images/intro/2.png');
const Three = require('./../assets/images/intro/3.png');
const Four = require('./../assets/images/intro/4.png');
interface IntroProps {
navigation: any;
}
interface IntroState {
activeIndex: number;
carouselItems: any;
}
export default class Intro extends React.Component<IntroProps, IntroState> {
carousel: any;
screenWidth: number;
constructor(props: any) {
super(props);
this.screenWidth = Dimensions.get('window').width;
this.screenHeight = Dimensions.get('window').height;
this.state = {
activeIndex: 0,
carouselItems: [
{
title: localeString('views.Intro.carousel1.title'),
text: localeString('views.Intro.carousel1.text'),
illustration: One
},
{
title: localeString('views.Intro.carousel2.title'),
text: localeString('views.Intro.carousel2.text'),
illustration: Two
},
{
title: localeString('views.Intro.carousel3.title'),
text: localeString('views.Intro.carousel3.text'),
illustration: Three
},
{
title: localeString('views.Intro.carousel4.title'),
text: localeString('views.Intro.carousel4.text'),
illustration: Four
}
]
};
}
render() {
const { navigation } = this.props;
const { carouselItems, activeIndex } = this.state;
const renderItem = ({ item }: { item: any }) => (
<View
style={{
borderRadius: 5
}}
>
<Image
source={item.illustration}
style={{
width: this.screenWidth,
height: '65%'
}}
/>
<View
style={{
backgroundColor: themeColor('background'),
width: '100%',
flexGrow: 1,
justifyContent: 'flex-end'
}}
>
<Text
style={{
fontSize: 23,
color: themeColor('text'),
fontFamily: 'Lato-Regular',
alignSelf: 'center',
paddingTop: 10
}}
>
{item.title}
</Text>
<Text
style={{
fontSize: 20,
color: themeColor('secondaryText'),
fontFamily: 'Lato-Regular',
alignSelf: 'center',
padding: 10
}}
>
{item.text}
</Text>
{item.text ===
localeString('views.Intro.carousel4.text') && (
<Button
title={localeString('views.Intro.getStarted')}
onPress={() => navigation.navigate('Settings')}
/>
)}
</View>
</View>
);
return (
<SafeAreaView
style={{
flex: 1,
backgroundColor: themeColor('background')
}}
>
<View
style={{
flex: 1,
justifyContent: 'center'
}}
>
<Carousel
layout="default"
ref={(ref) => (this.carousel = ref)}
data={carouselItems}
sliderWidth={this.screenWidth}
itemWidth={this.screenWidth}
renderItem={renderItem}
onSnapToItem={(index) =>
this.setState({ activeIndex: index })
}
hasParallaxImages={false}
/>
</View>
<Pagination
dotsLength={carouselItems.length}
activeDotIndex={activeIndex}
dotColor={themeColor('highlight')}
inactiveDotColor={themeColor('text')}
inactiveDotOpacity={0.4}
inactiveDotScale={0.6}
carouselRef={this.carousel}
tappableDots={!!this.carousel}
containerStyle={{
backgroundColor: 'transparent',
marginTop: -30,
marginBottom: -25
}}
/>
</SafeAreaView>
);
}
}