|
@@ -1,14 +1,17 @@
|
1
|
1
|
// @flow
|
2
|
2
|
|
3
|
3
|
import * as React from 'react';
|
4
|
|
-import {Image, Platform, StatusBar, StyleSheet, View} from "react-native";
|
|
4
|
+import {Platform, StatusBar, StyleSheet, View} from "react-native";
|
|
5
|
+import type {MaterialCommunityIconsGlyphs} from "react-native-vector-icons/MaterialCommunityIcons";
|
5
|
6
|
import MaterialCommunityIcons from "react-native-vector-icons/MaterialCommunityIcons";
|
6
|
|
-import {Text} from "react-native-paper";
|
7
|
7
|
import i18n from 'i18n-js';
|
8
|
8
|
import AppIntroSlider from "react-native-app-intro-slider";
|
9
|
9
|
import Update from "../../constants/Update";
|
10
|
10
|
import ThemeManager from "../../managers/ThemeManager";
|
11
|
11
|
import LinearGradient from 'react-native-linear-gradient';
|
|
12
|
+import Mascot, {MASCOT_STYLE} from "../Mascot/Mascot";
|
|
13
|
+import * as Animatable from "react-native-animatable";
|
|
14
|
+import {Card} from "react-native-paper";
|
12
|
15
|
|
13
|
16
|
type Props = {
|
14
|
17
|
onDone: Function,
|
|
@@ -16,17 +19,34 @@ type Props = {
|
16
|
19
|
isAprilFools: boolean,
|
17
|
20
|
};
|
18
|
21
|
|
|
22
|
+type State = {
|
|
23
|
+ currentSlide: number,
|
|
24
|
+}
|
|
25
|
+
|
|
26
|
+type Slide = {
|
|
27
|
+ key: string,
|
|
28
|
+ title: string,
|
|
29
|
+ text: string,
|
|
30
|
+ view: () => React.Node,
|
|
31
|
+ mascotStyle: number,
|
|
32
|
+ colors: [string, string]
|
|
33
|
+};
|
|
34
|
+
|
19
|
35
|
/**
|
20
|
36
|
* Class used to create intro slides
|
21
|
37
|
*/
|
22
|
|
-export default class CustomIntroSlider extends React.Component<Props> {
|
|
38
|
+export default class CustomIntroSlider extends React.Component<Props, State> {
|
23
|
39
|
|
24
|
|
- sliderRef: {current: null | AppIntroSlider};
|
|
40
|
+ state = {
|
|
41
|
+ currentSlide: 0,
|
|
42
|
+ }
|
25
|
43
|
|
26
|
|
- introSlides: Array<Object>;
|
27
|
|
- updateSlides: Array<Object>;
|
28
|
|
- aprilFoolsSlides: Array<Object>;
|
29
|
|
- currentSlides: Array<Object>;
|
|
44
|
+ sliderRef: { current: null | AppIntroSlider };
|
|
45
|
+
|
|
46
|
+ introSlides: Array<Slide>;
|
|
47
|
+ updateSlides: Array<Slide>;
|
|
48
|
+ aprilFoolsSlides: Array<Slide>;
|
|
49
|
+ currentSlides: Array<Slide>;
|
30
|
50
|
|
31
|
51
|
/**
|
32
|
52
|
* Generates intro slides
|
|
@@ -36,53 +56,44 @@ export default class CustomIntroSlider extends React.Component<Props> {
|
36
|
56
|
this.sliderRef = React.createRef();
|
37
|
57
|
this.introSlides = [
|
38
|
58
|
{
|
39
|
|
- key: 'main',
|
|
59
|
+ key: '0', // Mascot
|
40
|
60
|
title: i18n.t('intro.slideMain.title'),
|
41
|
61
|
text: i18n.t('intro.slideMain.text'),
|
42
|
|
- image: require('../../../assets/splash.png'),
|
43
|
|
- colors: ['#be1522', '#740d15'],
|
|
62
|
+ view: this.getWelcomeView,
|
|
63
|
+ mascotStyle: MASCOT_STYLE.NORMAL,
|
|
64
|
+ colors: ['#be1522', '#57080e'],
|
44
|
65
|
},
|
45
|
66
|
{
|
46
|
|
- key: 'Planex',
|
|
67
|
+ key: '1',
|
47
|
68
|
title: i18n.t('intro.slidePlanex.title'),
|
48
|
69
|
text: i18n.t('intro.slidePlanex.text'),
|
49
|
|
- icon: 'timetable',
|
50
|
|
- colors: ['#e77020', '#803e12'],
|
51
|
|
- },
|
52
|
|
- {
|
53
|
|
- key: 'RU',
|
54
|
|
- title: i18n.t('intro.slideRU.title'),
|
55
|
|
- text: i18n.t('intro.slideRU.text'),
|
56
|
|
- icon: 'silverware-fork-knife',
|
57
|
|
- colors: ['#dcac18', '#8b6a15'],
|
|
70
|
+ view: () => this.getIconView("calendar-clock"),
|
|
71
|
+ mascotStyle: MASCOT_STYLE.INTELLO,
|
|
72
|
+ colors: ['#be1522', '#57080e'],
|
58
|
73
|
},
|
59
|
74
|
{
|
60
|
|
- key: 'events',
|
|
75
|
+ key: '2',
|
61
|
76
|
title: i18n.t('intro.slideEvents.title'),
|
62
|
77
|
text: i18n.t('intro.slideEvents.text'),
|
63
|
|
- icon: 'calendar-range',
|
64
|
|
- colors: ['#41a006', '#095c03'],
|
|
78
|
+ view: () => this.getIconView("calendar-star",),
|
|
79
|
+ mascotStyle: MASCOT_STYLE.HAPPY,
|
|
80
|
+ colors: ['#be1522', '#57080e'],
|
65
|
81
|
},
|
66
|
82
|
{
|
67
|
|
- key: 'proxiwash',
|
68
|
|
- title: i18n.t('intro.slideProxiwash.title'),
|
69
|
|
- text: i18n.t('intro.slideProxiwash.text'),
|
70
|
|
- icon: 'washing-machine',
|
71
|
|
- colors: ['#1fa5ee', '#06537d'],
|
72
|
|
- },
|
73
|
|
- {
|
74
|
|
- key: 'services',
|
|
83
|
+ key: '3',
|
75
|
84
|
title: i18n.t('intro.slideServices.title'),
|
76
|
85
|
text: i18n.t('intro.slideServices.text'),
|
77
|
|
- icon: 'view-dashboard-variant',
|
78
|
|
- colors: ['#6737c1', '#281a5a'],
|
|
86
|
+ view: () => this.getIconView("view-dashboard-variant",),
|
|
87
|
+ mascotStyle: MASCOT_STYLE.CUTE,
|
|
88
|
+ colors: ['#be1522', '#57080e'],
|
79
|
89
|
},
|
80
|
90
|
{
|
81
|
|
- key: 'done',
|
|
91
|
+ key: '4',
|
82
|
92
|
title: i18n.t('intro.slideDone.title'),
|
83
|
93
|
text: i18n.t('intro.slideDone.text'),
|
84
|
|
- icon: 'account-heart',
|
85
|
|
- colors: ['#b837c1', '#501a5a'],
|
|
94
|
+ view: () => this.getIconView("account-heart",),
|
|
95
|
+ mascotStyle: MASCOT_STYLE.COOL,
|
|
96
|
+ colors: ['#9c165b', '#3e042b'],
|
86
|
97
|
},
|
87
|
98
|
];
|
88
|
99
|
this.updateSlides = [];
|
|
@@ -103,50 +114,127 @@ export default class CustomIntroSlider extends React.Component<Props> {
|
103
|
114
|
key: '1',
|
104
|
115
|
title: i18n.t('intro.aprilFoolsSlide.title'),
|
105
|
116
|
text: i18n.t('intro.aprilFoolsSlide.text'),
|
106
|
|
- icon: 'fish',
|
|
117
|
+ view: () => <View/>,
|
|
118
|
+ mascotStyle: MASCOT_STYLE.NORMAL,
|
107
|
119
|
colors: ['#e01928', '#be1522'],
|
108
|
120
|
},
|
109
|
121
|
];
|
110
|
122
|
}
|
111
|
123
|
|
112
|
|
-
|
113
|
124
|
/**
|
114
|
125
|
* Render item to be used for the intro introSlides
|
115
|
126
|
*
|
116
|
127
|
* @param item The item to be displayed
|
117
|
128
|
* @param dimensions Dimensions of the item
|
118
|
129
|
*/
|
119
|
|
- static getIntroRenderItem({item, dimensions}: Object) {
|
|
130
|
+ getIntroRenderItem = ({item, dimensions}: { item: Slide, dimensions: { width: number, height: number } }) => {
|
|
131
|
+ const index = parseInt(item.key);
|
120
|
132
|
return (
|
121
|
133
|
<LinearGradient
|
122
|
134
|
style={[
|
123
|
135
|
styles.mainContent,
|
124
|
|
- dimensions,
|
|
136
|
+ dimensions
|
125
|
137
|
]}
|
126
|
138
|
colors={item.colors}
|
127
|
139
|
start={{x: 0, y: 0.1}}
|
128
|
140
|
end={{x: 0.1, y: 1}}
|
129
|
141
|
>
|
130
|
|
- {item.image !== undefined ?
|
131
|
|
- <View style={styles.image}>
|
132
|
|
- <Image
|
133
|
|
- source={item.image}
|
134
|
|
- resizeMode={"contain"}
|
135
|
|
- style={{width: '100%', height: '100%'}}
|
136
|
|
- />
|
137
|
|
- </View>
|
138
|
|
- : <MaterialCommunityIcons
|
139
|
|
- name={item.icon}
|
140
|
|
- color={'#fff'}
|
141
|
|
- size={200}/>}
|
142
|
|
- <View style={{marginTop: 20}}>
|
143
|
|
- <Text style={styles.title}>{item.title}</Text>
|
144
|
|
- <Text style={styles.text}>{item.text}</Text>
|
145
|
|
- </View>
|
|
142
|
+ {this.state.currentSlide === index
|
|
143
|
+ ? <View style={{height: "100%", flex: 1}}>
|
|
144
|
+ <View style={{flex: 1}}>
|
|
145
|
+ {item.view()}
|
|
146
|
+ </View>
|
|
147
|
+ <Animatable.View
|
|
148
|
+ animation={"fadeIn"}>
|
|
149
|
+ {index !== 0
|
|
150
|
+ ? <Animatable.View
|
|
151
|
+ animation={"pulse"}
|
|
152
|
+ iterationCount={"infinite"}
|
|
153
|
+ duration={2000}
|
|
154
|
+ style={{
|
|
155
|
+ marginLeft: 30,
|
|
156
|
+ marginBottom: 0,
|
|
157
|
+ width: 80
|
|
158
|
+ }}>
|
|
159
|
+ <Mascot emotion={item.mascotStyle} size={80}/>
|
|
160
|
+ </Animatable.View> : null}
|
|
161
|
+
|
|
162
|
+ <View style={{
|
|
163
|
+ marginLeft: 50,
|
|
164
|
+ width: 0,
|
|
165
|
+ height: 0,
|
|
166
|
+ borderLeftWidth: 20,
|
|
167
|
+ borderRightWidth: 0,
|
|
168
|
+ borderBottomWidth: 20,
|
|
169
|
+ borderStyle: 'solid',
|
|
170
|
+ backgroundColor: 'transparent',
|
|
171
|
+ borderLeftColor: 'transparent',
|
|
172
|
+ borderRightColor: 'transparent',
|
|
173
|
+ borderBottomColor: "rgba(0,0,0,0.60)",
|
|
174
|
+ }}/>
|
|
175
|
+ <Card style={{
|
|
176
|
+ backgroundColor: "rgba(0,0,0,0.38)",
|
|
177
|
+ marginHorizontal: 20,
|
|
178
|
+ borderColor: "rgba(0,0,0,0.60)",
|
|
179
|
+ borderWidth: 4,
|
|
180
|
+ borderRadius: 10,
|
|
181
|
+ }}>
|
|
182
|
+ <Card.Content>
|
|
183
|
+ <Animatable.Text
|
|
184
|
+ animation={"fadeIn"}
|
|
185
|
+ delay={100}
|
|
186
|
+ style={styles.title}>
|
|
187
|
+ {item.title}
|
|
188
|
+ </Animatable.Text>
|
|
189
|
+ <Animatable.Text
|
|
190
|
+ animation={"fadeIn"}
|
|
191
|
+ delay={200}
|
|
192
|
+ style={styles.text}>
|
|
193
|
+ {item.text}
|
|
194
|
+ </Animatable.Text>
|
|
195
|
+ </Card.Content>
|
|
196
|
+ </Card>
|
|
197
|
+ </Animatable.View>
|
|
198
|
+ </View> : null}
|
146
|
199
|
</LinearGradient>
|
147
|
200
|
);
|
148
|
201
|
}
|
149
|
202
|
|
|
203
|
+ getWelcomeView = () => {
|
|
204
|
+ return (
|
|
205
|
+ <View style={{flex: 1}}>
|
|
206
|
+ <View
|
|
207
|
+ style={styles.center}>
|
|
208
|
+ <Mascot
|
|
209
|
+ size={250}
|
|
210
|
+ emotion={MASCOT_STYLE.NORMAL}
|
|
211
|
+ animated={true}
|
|
212
|
+ entryAnimation={{
|
|
213
|
+ animation: "bounceIn",
|
|
214
|
+ duration: 2000,
|
|
215
|
+ }}
|
|
216
|
+ />
|
|
217
|
+ </View>
|
|
218
|
+ </View>
|
|
219
|
+ )
|
|
220
|
+ }
|
|
221
|
+
|
|
222
|
+ getIconView(icon: MaterialCommunityIconsGlyphs) {
|
|
223
|
+ return (
|
|
224
|
+ <View style={{flex: 1}}>
|
|
225
|
+ <Animatable.View
|
|
226
|
+ style={styles.center}
|
|
227
|
+ animation={"fadeIn"}
|
|
228
|
+ >
|
|
229
|
+ <MaterialCommunityIcons
|
|
230
|
+ name={icon}
|
|
231
|
+ color={'#fff'}
|
|
232
|
+ size={200}/>
|
|
233
|
+ </Animatable.View>
|
|
234
|
+ </View>
|
|
235
|
+ )
|
|
236
|
+ }
|
|
237
|
+
|
150
|
238
|
setStatusBarColor(color: string) {
|
151
|
239
|
if (Platform.OS === 'android')
|
152
|
240
|
StatusBar.setBackgroundColor(color, true);
|
|
@@ -154,12 +242,13 @@ export default class CustomIntroSlider extends React.Component<Props> {
|
154
|
242
|
|
155
|
243
|
onSlideChange = (index: number, lastIndex: number) => {
|
156
|
244
|
this.setStatusBarColor(this.currentSlides[index].colors[0]);
|
|
245
|
+ this.setState({currentSlide: index});
|
157
|
246
|
};
|
158
|
247
|
|
159
|
248
|
onSkip = () => {
|
160
|
|
- this.setStatusBarColor(this.currentSlides[this.currentSlides.length-1].colors[0]);
|
|
249
|
+ this.setStatusBarColor(this.currentSlides[this.currentSlides.length - 1].colors[0]);
|
161
|
250
|
if (this.sliderRef.current != null)
|
162
|
|
- this.sliderRef.current.goToSlide(this.currentSlides.length-1);
|
|
251
|
+ this.sliderRef.current.goToSlide(this.currentSlides.length - 1);
|
163
|
252
|
}
|
164
|
253
|
|
165
|
254
|
onDone = () => {
|
|
@@ -167,6 +256,42 @@ export default class CustomIntroSlider extends React.Component<Props> {
|
167
|
256
|
this.props.onDone();
|
168
|
257
|
}
|
169
|
258
|
|
|
259
|
+ renderNextButton = () => {
|
|
260
|
+ return (
|
|
261
|
+ <Animatable.View
|
|
262
|
+ animation={"fadeIn"}
|
|
263
|
+
|
|
264
|
+ style={{
|
|
265
|
+ borderRadius: 25,
|
|
266
|
+ padding: 5,
|
|
267
|
+ backgroundColor: "rgba(0,0,0,0.2)"
|
|
268
|
+ }}>
|
|
269
|
+ <MaterialCommunityIcons
|
|
270
|
+ name={"arrow-right"}
|
|
271
|
+ color={'#fff'}
|
|
272
|
+ size={40}/>
|
|
273
|
+ </Animatable.View>
|
|
274
|
+ )
|
|
275
|
+ }
|
|
276
|
+
|
|
277
|
+ renderDoneButton = () => {
|
|
278
|
+ return (
|
|
279
|
+ <Animatable.View
|
|
280
|
+ animation={"bounceIn"}
|
|
281
|
+
|
|
282
|
+ style={{
|
|
283
|
+ borderRadius: 25,
|
|
284
|
+ padding: 5,
|
|
285
|
+ backgroundColor: "rgb(190,21,34)"
|
|
286
|
+ }}>
|
|
287
|
+ <MaterialCommunityIcons
|
|
288
|
+ name={"check"}
|
|
289
|
+ color={'#fff'}
|
|
290
|
+ size={40}/>
|
|
291
|
+ </Animatable.View>
|
|
292
|
+ )
|
|
293
|
+ }
|
|
294
|
+
|
170
|
295
|
render() {
|
171
|
296
|
this.currentSlides = this.introSlides;
|
172
|
297
|
if (this.props.isUpdate)
|
|
@@ -177,16 +302,16 @@ export default class CustomIntroSlider extends React.Component<Props> {
|
177
|
302
|
return (
|
178
|
303
|
<AppIntroSlider
|
179
|
304
|
ref={this.sliderRef}
|
180
|
|
- renderItem={CustomIntroSlider.getIntroRenderItem}
|
181
|
305
|
data={this.currentSlides}
|
|
306
|
+ extraData={this.state.currentSlide}
|
|
307
|
+
|
|
308
|
+ renderItem={this.getIntroRenderItem}
|
|
309
|
+ renderNextButton={this.renderNextButton}
|
|
310
|
+ renderDoneButton={this.renderDoneButton}
|
|
311
|
+
|
182
|
312
|
onDone={this.onDone}
|
183
|
|
- bottomButton
|
184
|
|
- showSkipButton
|
185
|
313
|
onSlideChange={this.onSlideChange}
|
186
|
314
|
onSkip={this.onSkip}
|
187
|
|
- skipLabel={i18n.t('intro.buttons.skip')}
|
188
|
|
- doneLabel={i18n.t('intro.buttons.done')}
|
189
|
|
- nextLabel={i18n.t('intro.buttons.next')}
|
190
|
315
|
/>
|
191
|
316
|
);
|
192
|
317
|
}
|
|
@@ -196,15 +321,7 @@ export default class CustomIntroSlider extends React.Component<Props> {
|
196
|
321
|
|
197
|
322
|
const styles = StyleSheet.create({
|
198
|
323
|
mainContent: {
|
199
|
|
- flex: 1,
|
200
|
|
- alignItems: 'center',
|
201
|
|
- justifyContent: 'center',
|
202
|
|
- paddingBottom: 100
|
203
|
|
- },
|
204
|
|
- image: {
|
205
|
|
- width: 300,
|
206
|
|
- height: 300,
|
207
|
|
- marginBottom: -50,
|
|
324
|
+ paddingBottom: 100,
|
208
|
325
|
},
|
209
|
326
|
text: {
|
210
|
327
|
color: 'rgba(255, 255, 255, 0.8)',
|
|
@@ -219,4 +336,10 @@ const styles = StyleSheet.create({
|
219
|
336
|
textAlign: 'center',
|
220
|
337
|
marginBottom: 16,
|
221
|
338
|
},
|
|
339
|
+ center: {
|
|
340
|
+ marginTop: 'auto',
|
|
341
|
+ marginBottom: 'auto',
|
|
342
|
+ marginRight: 'auto',
|
|
343
|
+ marginLeft: 'auto',
|
|
344
|
+ }
|
222
|
345
|
});
|