Application Android et IOS pour l'amicale des élèves https://play.google.com/store/apps/details?id=fr.amicaleinsat.application
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.3KB

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