2019-08-07 14:39:20 +02:00
|
|
|
// @flow
|
|
|
|
|
|
|
|
import * as React from 'react';
|
|
|
|
import {LinearGradient} from "expo-linear-gradient";
|
|
|
|
import {Image, StyleSheet, View} from "react-native";
|
2020-03-05 21:48:37 +01:00
|
|
|
import {MaterialCommunityIcons} from "@expo/vector-icons";
|
2020-03-06 23:15:01 +01:00
|
|
|
import {Text} from "react-native-paper";
|
2019-08-07 14:39:20 +02:00
|
|
|
import i18n from 'i18n-js';
|
|
|
|
import AppIntroSlider from "react-native-app-intro-slider";
|
2020-03-11 21:04:17 +01:00
|
|
|
import Update from "../constants/Update";
|
2019-08-07 14:39:20 +02:00
|
|
|
|
|
|
|
type Props = {
|
|
|
|
onDone: Function,
|
2020-03-08 13:21:14 +01:00
|
|
|
isUpdate: boolean,
|
2020-03-11 19:55:48 +01:00
|
|
|
isAprilFools: boolean,
|
2019-08-07 14:39:20 +02:00
|
|
|
};
|
|
|
|
|
2020-03-29 14:46:44 +02:00
|
|
|
/**
|
|
|
|
* Class used to create intro slides
|
|
|
|
*/
|
2019-08-07 14:39:20 +02:00
|
|
|
export default class CustomIntroSlider extends React.Component<Props> {
|
|
|
|
|
2019-09-16 00:10:14 +02:00
|
|
|
introSlides: Array<Object>;
|
|
|
|
updateSlides: Array<Object>;
|
2020-03-11 19:55:48 +01:00
|
|
|
aprilFoolsSlides: Array<Object>;
|
2019-08-07 14:39:20 +02:00
|
|
|
|
2020-03-29 14:46:44 +02:00
|
|
|
/**
|
|
|
|
* Generates intro slides
|
|
|
|
*/
|
2019-08-07 14:39:20 +02:00
|
|
|
constructor() {
|
|
|
|
super();
|
2019-09-16 00:10:14 +02:00
|
|
|
this.introSlides = [
|
2019-08-07 14:39:20 +02:00
|
|
|
{
|
|
|
|
key: '1',
|
|
|
|
title: i18n.t('intro.slide1.title'),
|
|
|
|
text: i18n.t('intro.slide1.text'),
|
2019-08-20 19:15:24 +02:00
|
|
|
image: require('../assets/splash.png'),
|
2019-08-07 14:39:20 +02:00
|
|
|
colors: ['#e01928', '#be1522'],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
key: '2',
|
|
|
|
title: i18n.t('intro.slide2.title'),
|
|
|
|
text: i18n.t('intro.slide2.text'),
|
|
|
|
icon: 'calendar-range',
|
|
|
|
colors: ['#d99e09', '#c28d08'],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
key: '3',
|
|
|
|
title: i18n.t('intro.slide3.title'),
|
|
|
|
text: i18n.t('intro.slide3.text'),
|
|
|
|
icon: 'washing-machine',
|
|
|
|
colors: ['#1fa5ee', '#1c97da'],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
key: '4',
|
|
|
|
title: i18n.t('intro.slide4.title'),
|
|
|
|
text: i18n.t('intro.slide4.text'),
|
|
|
|
icon: 'shopping',
|
|
|
|
colors: ['#ec5904', '#da5204'],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
key: '5',
|
|
|
|
title: i18n.t('intro.slide5.title'),
|
|
|
|
text: i18n.t('intro.slide5.text'),
|
|
|
|
icon: 'timetable',
|
|
|
|
colors: ['#7c33ec', '#732fda'],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
key: '6',
|
|
|
|
title: i18n.t('intro.slide6.title'),
|
|
|
|
text: i18n.t('intro.slide6.text'),
|
2019-09-20 11:05:34 +02:00
|
|
|
icon: 'silverware-fork-knife',
|
|
|
|
colors: ['#ec1213', '#ff372f'],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
key: '7',
|
|
|
|
title: i18n.t('intro.slide7.title'),
|
|
|
|
text: i18n.t('intro.slide7.text'),
|
2019-08-07 14:39:20 +02:00
|
|
|
icon: 'cogs',
|
|
|
|
colors: ['#37c13e', '#26852b'],
|
|
|
|
},
|
|
|
|
];
|
2019-09-16 00:10:14 +02:00
|
|
|
this.updateSlides = [
|
|
|
|
{
|
|
|
|
key: '1',
|
2020-03-11 21:04:17 +01:00
|
|
|
title: Update.getInstance().title,
|
|
|
|
text: Update.getInstance().description,
|
|
|
|
icon: Update.icon,
|
2019-09-16 00:10:14 +02:00
|
|
|
colors: ['#e01928', '#be1522'],
|
|
|
|
},
|
2020-03-08 13:21:14 +01:00
|
|
|
];
|
2020-03-11 19:55:48 +01:00
|
|
|
this.aprilFoolsSlides = [
|
|
|
|
{
|
|
|
|
key: '1',
|
|
|
|
title: i18n.t('intro.aprilFoolsSlide.title'),
|
|
|
|
text: i18n.t('intro.aprilFoolsSlide.text'),
|
|
|
|
icon: 'fish',
|
|
|
|
colors: ['#e01928', '#be1522'],
|
|
|
|
},
|
|
|
|
];
|
2019-08-07 14:39:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2019-09-16 00:10:14 +02:00
|
|
|
* Render item to be used for the intro introSlides
|
2020-03-29 14:46:44 +02:00
|
|
|
*
|
|
|
|
* @param item The item to be displayed
|
|
|
|
* @param dimensions Dimensions of the item
|
2019-08-07 14:39:20 +02:00
|
|
|
*/
|
2020-02-23 21:47:36 +01:00
|
|
|
static getIntroRenderItem({item, dimensions}: Object) {
|
2019-08-07 14:39:20 +02:00
|
|
|
|
|
|
|
return (
|
|
|
|
<LinearGradient
|
|
|
|
style={[
|
|
|
|
styles.mainContent,
|
|
|
|
dimensions,
|
|
|
|
]}
|
|
|
|
colors={item.colors}
|
|
|
|
start={{x: 0, y: 0.1}}
|
|
|
|
end={{x: 0.1, y: 1}}
|
|
|
|
>
|
|
|
|
{item.image !== undefined ?
|
|
|
|
<Image source={item.image} style={styles.image}/>
|
2020-03-05 21:48:37 +01:00
|
|
|
: <MaterialCommunityIcons
|
|
|
|
name={item.icon}
|
|
|
|
color={'#fff'}
|
|
|
|
size={200}/>}
|
2019-08-07 14:39:20 +02:00
|
|
|
<View style={{marginTop: 20}}>
|
|
|
|
<Text style={styles.title}>{item.title}</Text>
|
|
|
|
<Text style={styles.text}>{item.text}</Text>
|
|
|
|
</View>
|
|
|
|
</LinearGradient>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
2020-03-08 13:21:14 +01:00
|
|
|
let slides = this.introSlides;
|
|
|
|
if (this.props.isUpdate)
|
|
|
|
slides = this.updateSlides;
|
2020-03-11 19:55:48 +01:00
|
|
|
else if (this.props.isAprilFools)
|
|
|
|
slides = this.aprilFoolsSlides;
|
2019-08-07 14:39:20 +02:00
|
|
|
return (
|
2019-09-20 11:05:34 +02:00
|
|
|
<AppIntroSlider
|
2020-02-23 21:47:36 +01:00
|
|
|
renderItem={CustomIntroSlider.getIntroRenderItem}
|
2020-03-08 13:21:14 +01:00
|
|
|
slides={slides}
|
2020-02-23 21:47:36 +01:00
|
|
|
onDone={this.props.onDone}
|
2019-09-20 11:05:34 +02:00
|
|
|
bottomButton
|
|
|
|
showSkipButton
|
|
|
|
skipLabel={i18n.t('intro.buttons.skip')}
|
|
|
|
doneLabel={i18n.t('intro.buttons.done')}
|
|
|
|
nextLabel={i18n.t('intro.buttons.next')}
|
|
|
|
/>
|
2019-08-07 14:39:20 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-03-29 14:46:44 +02:00
|
|
|
const styles = StyleSheet.create({
|
|
|
|
mainContent: {
|
|
|
|
flex: 1,
|
|
|
|
alignItems: 'center',
|
|
|
|
justifyContent: 'center',
|
|
|
|
paddingBottom: 100
|
|
|
|
},
|
|
|
|
image: {
|
|
|
|
width: 300,
|
|
|
|
height: 300,
|
|
|
|
marginBottom: -50,
|
|
|
|
},
|
|
|
|
text: {
|
|
|
|
color: 'rgba(255, 255, 255, 0.8)',
|
|
|
|
backgroundColor: 'transparent',
|
|
|
|
textAlign: 'center',
|
|
|
|
paddingHorizontal: 16,
|
|
|
|
},
|
|
|
|
title: {
|
|
|
|
fontSize: 22,
|
|
|
|
color: 'white',
|
|
|
|
backgroundColor: 'transparent',
|
|
|
|
textAlign: 'center',
|
|
|
|
marginBottom: 16,
|
|
|
|
},
|
|
|
|
});
|