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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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 CustomMaterialIcon from "./CustomMaterialIcon";
  6. import {Text} from "native-base";
  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. };
  39. export default class CustomIntroSlider extends React.Component<Props> {
  40. slides: Array<Object>;
  41. constructor() {
  42. super();
  43. this.slides = [
  44. {
  45. key: '1',
  46. title: i18n.t('intro.slide1.title'),
  47. text: i18n.t('intro.slide1.text'),
  48. image: require('../assets/splash.png'),
  49. colors: ['#e01928', '#be1522'],
  50. },
  51. {
  52. key: '2',
  53. title: i18n.t('intro.slide2.title'),
  54. text: i18n.t('intro.slide2.text'),
  55. icon: 'calendar-range',
  56. colors: ['#d99e09', '#c28d08'],
  57. },
  58. {
  59. key: '3',
  60. title: i18n.t('intro.slide3.title'),
  61. text: i18n.t('intro.slide3.text'),
  62. icon: 'washing-machine',
  63. colors: ['#1fa5ee', '#1c97da'],
  64. },
  65. {
  66. key: '4',
  67. title: i18n.t('intro.slide4.title'),
  68. text: i18n.t('intro.slide4.text'),
  69. icon: 'shopping',
  70. colors: ['#ec5904', '#da5204'],
  71. },
  72. {
  73. key: '5',
  74. title: i18n.t('intro.slide5.title'),
  75. text: i18n.t('intro.slide5.text'),
  76. icon: 'timetable',
  77. colors: ['#7c33ec', '#732fda'],
  78. },
  79. {
  80. key: '6',
  81. title: i18n.t('intro.slide6.title'),
  82. text: i18n.t('intro.slide6.text'),
  83. icon: 'cogs',
  84. colors: ['#37c13e', '#26852b'],
  85. },
  86. ];
  87. }
  88. /**
  89. * Render item to be used for the intro slides
  90. * @param item
  91. * @param dimensions
  92. */
  93. static getIntroRenderItem(item: Object, dimensions: Object) {
  94. return (
  95. <LinearGradient
  96. style={[
  97. styles.mainContent,
  98. dimensions,
  99. ]}
  100. colors={item.colors}
  101. start={{x: 0, y: 0.1}}
  102. end={{x: 0.1, y: 1}}
  103. >
  104. {item.image !== undefined ?
  105. <Image source={item.image} style={styles.image}/>
  106. : <CustomMaterialIcon icon={item.icon} color={'#fff'} fontSize={200} width={200}/>}
  107. <View style={{marginTop: 20}}>
  108. <Text style={styles.title}>{item.title}</Text>
  109. <Text style={styles.text}>{item.text}</Text>
  110. </View>
  111. </LinearGradient>
  112. );
  113. }
  114. render() {
  115. return (
  116. <AppIntroSlider renderItem={({item, dimensions}) => CustomIntroSlider.getIntroRenderItem(item, dimensions)}
  117. slides={this.slides} onDone={() => this.props.onDone()} bottomButton showSkipButton/>
  118. );
  119. }
  120. }