Application Android et IOS pour l'amicale des élèves
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

CustomIntroSlider.js 5.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. // @flow
  2. import * as React from 'react';
  3. import {LinearGradient} from "expo-linear-gradient";
  4. import {Image, StyleSheet, View} from "react-native";
  5. import {MaterialCommunityIcons} from "@expo/vector-icons";
  6. import {Text} from "react-native-paper";
  7. import i18n from 'i18n-js';
  8. import AppIntroSlider from "react-native-app-intro-slider";
  9. import Update from "../constants/Update";
  10. // Content to be used int the intro slides
  11. const styles = StyleSheet.create({
  12. mainContent: {
  13. flex: 1,
  14. alignItems: 'center',
  15. justifyContent: 'center',
  16. paddingBottom: 100
  17. },
  18. image: {
  19. width: 300,
  20. height: 300,
  21. marginBottom: -50,
  22. },
  23. text: {
  24. color: 'rgba(255, 255, 255, 0.8)',
  25. backgroundColor: 'transparent',
  26. textAlign: 'center',
  27. paddingHorizontal: 16,
  28. },
  29. title: {
  30. fontSize: 22,
  31. color: 'white',
  32. backgroundColor: 'transparent',
  33. textAlign: 'center',
  34. marginBottom: 16,
  35. },
  36. });
  37. type Props = {
  38. onDone: Function,
  39. isUpdate: boolean,
  40. isAprilFools: boolean,
  41. };
  42. export default class CustomIntroSlider extends React.Component<Props> {
  43. introSlides: Array<Object>;
  44. updateSlides: Array<Object>;
  45. aprilFoolsSlides: Array<Object>;
  46. constructor() {
  47. super();
  48. this.introSlides = [
  49. {
  50. key: '1',
  51. title: i18n.t('intro.slide1.title'),
  52. text: i18n.t('intro.slide1.text'),
  53. image: require('../assets/splash.png'),
  54. colors: ['#e01928', '#be1522'],
  55. },
  56. {
  57. key: '2',
  58. title: i18n.t('intro.slide2.title'),
  59. text: i18n.t('intro.slide2.text'),
  60. icon: 'calendar-range',
  61. colors: ['#d99e09', '#c28d08'],
  62. },
  63. {
  64. key: '3',
  65. title: i18n.t('intro.slide3.title'),
  66. text: i18n.t('intro.slide3.text'),
  67. icon: 'washing-machine',
  68. colors: ['#1fa5ee', '#1c97da'],
  69. },
  70. {
  71. key: '4',
  72. title: i18n.t('intro.slide4.title'),
  73. text: i18n.t('intro.slide4.text'),
  74. icon: 'shopping',
  75. colors: ['#ec5904', '#da5204'],
  76. },
  77. {
  78. key: '5',
  79. title: i18n.t('intro.slide5.title'),
  80. text: i18n.t('intro.slide5.text'),
  81. icon: 'timetable',
  82. colors: ['#7c33ec', '#732fda'],
  83. },
  84. {
  85. key: '6',
  86. title: i18n.t('intro.slide6.title'),
  87. text: i18n.t('intro.slide6.text'),
  88. icon: 'silverware-fork-knife',
  89. colors: ['#ec1213', '#ff372f'],
  90. },
  91. {
  92. key: '7',
  93. title: i18n.t('intro.slide7.title'),
  94. text: i18n.t('intro.slide7.text'),
  95. icon: 'cogs',
  96. colors: ['#37c13e', '#26852b'],
  97. },
  98. ];
  99. this.updateSlides = [
  100. {
  101. key: '1',
  102. title: Update.getInstance().title,
  103. text: Update.getInstance().description,
  104. icon: Update.icon,
  105. colors: ['#e01928', '#be1522'],
  106. },
  107. ];
  108. this.aprilFoolsSlides = [
  109. {
  110. key: '1',
  111. title: i18n.t('intro.aprilFoolsSlide.title'),
  112. text: i18n.t('intro.aprilFoolsSlide.text'),
  113. icon: 'fish',
  114. colors: ['#e01928', '#be1522'],
  115. },
  116. ];
  117. }
  118. /**
  119. * Render item to be used for the intro introSlides
  120. * @param item
  121. * @param dimensions
  122. */
  123. static getIntroRenderItem({item, dimensions}: Object) {
  124. return (
  125. <LinearGradient
  126. style={[
  127. styles.mainContent,
  128. dimensions,
  129. ]}
  130. colors={item.colors}
  131. start={{x: 0, y: 0.1}}
  132. end={{x: 0.1, y: 1}}
  133. >
  134. {item.image !== undefined ?
  135. <Image source={item.image} style={styles.image}/>
  136. : <MaterialCommunityIcons
  137. name={item.icon}
  138. color={'#fff'}
  139. size={200}/>}
  140. <View style={{marginTop: 20}}>
  141. <Text style={styles.title}>{item.title}</Text>
  142. <Text style={styles.text}>{item.text}</Text>
  143. </View>
  144. </LinearGradient>
  145. );
  146. }
  147. render() {
  148. let slides = this.introSlides;
  149. if (this.props.isUpdate)
  150. slides = this.updateSlides;
  151. else if (this.props.isAprilFools)
  152. slides = this.aprilFoolsSlides;
  153. return (
  154. <AppIntroSlider
  155. renderItem={CustomIntroSlider.getIntroRenderItem}
  156. slides={slides}
  157. onDone={this.props.onDone}
  158. bottomButton
  159. showSkipButton
  160. skipLabel={i18n.t('intro.buttons.skip')}
  161. doneLabel={i18n.t('intro.buttons.done')}
  162. nextLabel={i18n.t('intro.buttons.next')}
  163. />
  164. );
  165. }
  166. }