From 44ff396ae35305ab75b330c7245f6576450db080 Mon Sep 17 00:00:00 2001 From: Arnaud Vergnet Date: Thu, 2 Apr 2020 19:55:50 +0200 Subject: [PATCH] Added club categories on display screen --- screens/Amicale/ClubDisplayScreen.js | 28 ++++++++++++++++++++++++++-- screens/Amicale/ClubListScreen.js | 2 +- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/screens/Amicale/ClubDisplayScreen.js b/screens/Amicale/ClubDisplayScreen.js index 65328a6..e15a821 100644 --- a/screens/Amicale/ClubDisplayScreen.js +++ b/screens/Amicale/ClubDisplayScreen.js @@ -4,7 +4,7 @@ import * as React from 'react'; import {ScrollView, View} from 'react-native'; import HTML from "react-native-render-html"; import {Linking} from "expo"; -import {Avatar, Card, Paragraph, withTheme} from 'react-native-paper'; +import {Avatar, Card, Chip, Paragraph, withTheme} from 'react-native-paper'; import ImageModal from 'react-native-image-modal'; type Props = { @@ -26,6 +26,7 @@ function openWebLink(event, link) { class ClubDisplayScreen extends React.Component { displayData = this.props.route.params['data']; + categories = this.props.route.params['categories']; colors: Object; @@ -42,6 +43,23 @@ class ClubDisplayScreen extends React.Component { this.props.navigation.setOptions({title: this.displayData.name}) } + getCategoryName(id: number) { + for (let i = 0; i < this.categories.length; i++) { + if (id === this.categories[i].id) + return this.categories[i].name; + } + return ""; + } + + getCategoriesRender(categories: Array) { + let final = []; + for (let i = 0; i < categories.length; i++) { + if (categories[i] !== null) + final.push({this.getCategoryName(categories[i])}); + } + return {final}; + } + getResponsiblesRender(resp: Array) { let final = []; for (let i = 0; i < resp.length; i++) { @@ -67,8 +85,14 @@ class ClubDisplayScreen extends React.Component { render() { return ( + {this.getCategoriesRender(this.displayData.category)} {this.displayData.logo !== null ? - + { * @param item The article pressed */ onListItemPress(item: Object) { - this.props.navigation.navigate("ClubDisplayScreen", {data: item}); + this.props.navigation.navigate("ClubDisplayScreen", {data: item, categories: this.categories}); } render() {