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.

SideMenu.js 4.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. import React from 'react';
  2. import {Platform, Dimensions, ScrollView, StyleSheet, View, Image, FlatList} from 'react-native';
  3. import {Drawer} from 'react-native-paper';
  4. import {Badge, Text, Container, Content, Icon, Left, List, ListItem, Right} from "native-base";
  5. import i18n from "i18n-js";
  6. const deviceHeight = Dimensions.get("window").height;
  7. const drawerCover = require("../assets/drawer-cover.png");
  8. export default class SideBar extends React.Component {
  9. constructor(props) {
  10. super(props);
  11. this.state = {
  12. active: 'Home',
  13. };
  14. this.dataSet = [
  15. {
  16. name: i18n.t('screens.home'),
  17. route: "Home",
  18. icon: "home",
  19. bg: "#C5F442"
  20. // types: "11" // Shows the badge
  21. },
  22. {
  23. name: i18n.t('screens.planning'),
  24. route: "Planning",
  25. icon: "calendar-range",
  26. bg: "#477EEA",
  27. // types: "11"
  28. },
  29. {
  30. name: "Proxiwash",
  31. route: "Proxiwash",
  32. icon: "washing-machine",
  33. bg: "#477EEA",
  34. // types: "11"
  35. },
  36. {
  37. name: "Proximo",
  38. route: "Proximo",
  39. icon: "shopping",
  40. bg: "#477EEA",
  41. // types: "11"
  42. },
  43. {
  44. name: i18n.t('screens.settings'),
  45. route: "Settings",
  46. icon: "settings",
  47. bg: "#477EEA",
  48. // types: "11"
  49. },
  50. {
  51. name: i18n.t('screens.about'),
  52. route: "About",
  53. icon: "information",
  54. bg: "#477EEA",
  55. // types: "11"
  56. },
  57. ];
  58. }
  59. navigateToScreen = (route) => () => {
  60. this.props.navigation.navigate(route);
  61. this.props.navigation.closeDrawer();
  62. this.setState({active: route});
  63. };
  64. render() {
  65. return (
  66. <Container>
  67. <Content
  68. bounces={false}
  69. style={{ flex: 1, top: -1 }}
  70. >
  71. <Image source={drawerCover} style={styles.drawerCover} />
  72. <FlatList
  73. data={this.dataSet}
  74. extraData={this.state}
  75. keyExtractor={(item, index) => item.route}
  76. renderItem={({item}) =>
  77. <ListItem
  78. button
  79. noBorder={item.route !== 'Proximo'} // Display a separator before settings
  80. selected={this.state.active === item.route}
  81. onPress={
  82. this.navigateToScreen(item.route)
  83. }
  84. >
  85. <Left>
  86. <Icon
  87. active
  88. name={item.icon}
  89. type={'MaterialCommunityIcons'}
  90. style={{ color: "#777", fontSize: 26, width: 30 }}
  91. />
  92. <Text style={styles.text}>
  93. {item.name}
  94. </Text>
  95. </Left>
  96. {item.types &&
  97. <Right style={{ flex: 1 }}>
  98. <Badge
  99. style={{
  100. borderRadius: 3,
  101. height: 25,
  102. width: 72,
  103. backgroundColor: item.bg
  104. }}
  105. >
  106. <Text
  107. style={styles.badgeText}
  108. >{`${item.types} Types`}</Text>
  109. </Badge>
  110. </Right>}
  111. </ListItem>}
  112. />
  113. </Content>
  114. </Container>
  115. );
  116. }
  117. }
  118. const styles = StyleSheet.create({
  119. drawerCover: {
  120. alignSelf: "stretch",
  121. height: deviceHeight / 4,
  122. width: null,
  123. position: "relative",
  124. marginBottom: 10,
  125. marginTop: 20
  126. },
  127. text: {
  128. fontWeight: Platform.OS === "ios" ? "500" : "400",
  129. fontSize: 16,
  130. marginLeft: 20
  131. },
  132. badgeText: {
  133. fontSize: Platform.OS === "ios" ? 13 : 11,
  134. fontWeight: "400",
  135. textAlign: "center",
  136. marginTop: Platform.OS === "android" ? -3 : undefined
  137. }
  138. });