Browse Source

Added club categories on display screen

Arnaud Vergnet 1 year ago
parent
commit
44ff396ae3
2 changed files with 27 additions and 3 deletions
  1. 26
    2
      screens/Amicale/ClubDisplayScreen.js
  2. 1
    1
      screens/Amicale/ClubListScreen.js

+ 26
- 2
screens/Amicale/ClubDisplayScreen.js View File

@@ -4,7 +4,7 @@ import * as React from 'react';
4 4
 import {ScrollView, View} from 'react-native';
5 5
 import HTML from "react-native-render-html";
6 6
 import {Linking} from "expo";
7
-import {Avatar, Card, Paragraph, withTheme} from 'react-native-paper';
7
+import {Avatar, Card, Chip, Paragraph, withTheme} from 'react-native-paper';
8 8
 import ImageModal from 'react-native-image-modal';
9 9
 
10 10
 type Props = {
@@ -26,6 +26,7 @@ function openWebLink(event, link) {
26 26
 class ClubDisplayScreen extends React.Component<Props, State> {
27 27
 
28 28
     displayData = this.props.route.params['data'];
29
+    categories = this.props.route.params['categories'];
29 30
 
30 31
     colors: Object;
31 32
 
@@ -42,6 +43,23 @@ class ClubDisplayScreen extends React.Component<Props, State> {
42 43
         this.props.navigation.setOptions({title: this.displayData.name})
43 44
     }
44 45
 
46
+    getCategoryName(id: number) {
47
+        for (let i = 0; i < this.categories.length; i++) {
48
+            if (id === this.categories[i].id)
49
+                return this.categories[i].name;
50
+        }
51
+        return "";
52
+    }
53
+
54
+    getCategoriesRender(categories: Array<number|null>) {
55
+        let final = [];
56
+        for (let i = 0; i < categories.length; i++) {
57
+            if (categories[i] !== null)
58
+                final.push(<Chip style={{marginRight: 5}}>{this.getCategoryName(categories[i])}</Chip>);
59
+        }
60
+        return <View style={{flexDirection: 'row', marginTop: 5}}>{final}</View>;
61
+    }
62
+
45 63
     getResponsiblesRender(resp: Array<string>) {
46 64
         let final = [];
47 65
         for (let i = 0; i < resp.length; i++) {
@@ -67,8 +85,14 @@ class ClubDisplayScreen extends React.Component<Props, State> {
67 85
     render() {
68 86
         return (
69 87
             <ScrollView style={{paddingLeft: 5, paddingRight: 5}}>
88
+                {this.getCategoriesRender(this.displayData.category)}
70 89
                 {this.displayData.logo !== null ?
71
-                    <View style={{marginLeft: 'auto', marginRight: 'auto'}}>
90
+                    <View style={{
91
+                        marginLeft: 'auto',
92
+                        marginRight: 'auto',
93
+                        marginTop: 10,
94
+                        marginBottom: 10,
95
+                    }}>
72 96
                         <ImageModal
73 97
                             resizeMode="contain"
74 98
                             imageBackgroundColor={this.colors.background}

+ 1
- 1
screens/Amicale/ClubListScreen.js View File

@@ -85,7 +85,7 @@ class ClubListScreen extends React.Component<Props, State> {
85 85
      * @param item The article pressed
86 86
      */
87 87
     onListItemPress(item: Object) {
88
-        this.props.navigation.navigate("ClubDisplayScreen", {data: item});
88
+        this.props.navigation.navigate("ClubDisplayScreen", {data: item, categories: this.categories});
89 89
     }
90 90
 
91 91
     render() {

Loading…
Cancel
Save