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.

ClubListHeader.js 1.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. // @flow
  2. import * as React from 'react';
  3. import {Card, List, Text, withTheme} from 'react-native-paper';
  4. import {StyleSheet, View} from "react-native";
  5. import i18n from 'i18n-js';
  6. type Props = {
  7. categoryRender: Function,
  8. categories: Array<Object>,
  9. }
  10. type State = {
  11. expanded: boolean,
  12. }
  13. class ClubListHeader extends React.Component<Props, State> {
  14. state = {
  15. expanded: true
  16. };
  17. colors: Object;
  18. constructor(props) {
  19. super(props);
  20. this.colors = props.theme.colors;
  21. }
  22. getCategoriesRender() {
  23. let final = [];
  24. for (let i = 0; i < this.props.categories.length; i++) {
  25. final.push(this.props.categoryRender(this.props.categories[i], this.props.categories[i].id));
  26. }
  27. return final;
  28. }
  29. onPress = () => this.setState({expanded: !this.state.expanded});
  30. render() {
  31. return (
  32. <Card style={styles.card}>
  33. <List.Accordion
  34. title={i18n.t("clubs.categories")}
  35. left={props => <List.Icon {...props} icon="star"/>}
  36. expanded={this.state.expanded}
  37. onPress={this.onPress}
  38. >
  39. <Text style={styles.text}>{i18n.t("clubs.categoriesFilterMessage")}</Text>
  40. <View style={styles.chipContainer}>
  41. {this.getCategoriesRender()}
  42. </View>
  43. </List.Accordion>
  44. </Card>
  45. );
  46. }
  47. }
  48. const styles = StyleSheet.create({
  49. card: {
  50. margin: 5
  51. },
  52. text: {
  53. paddingLeft: 0,
  54. marginTop: 5,
  55. marginBottom: 10,
  56. marginLeft: 'auto',
  57. marginRight: 'auto',
  58. },
  59. chipContainer: {
  60. justifyContent: 'space-around',
  61. flexDirection: 'row',
  62. flexWrap: 'wrap',
  63. paddingLeft: 0,
  64. marginBottom: 5,
  65. },
  66. });
  67. export default withTheme(ClubListHeader);