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 4.7KB

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