// @flow import * as React from 'react'; import {View} from "react-native"; import {Avatar, Chip, List, withTheme} from 'react-native-paper'; import AuthenticatedScreen from "../../components/Amicale/AuthenticatedScreen"; import PureFlatList from "../../components/Lists/PureFlatList"; type Props = { navigation: Object, theme: Object, } type State = {} class ClubListScreen extends React.Component { state = {}; colors: Object; getRenderItem: Function; categories: Array; constructor(props) { super(props); this.colors = props.theme.colors; } keyExtractor = (item: Object) => { return item.name + item.logo; }; getScreen = (data: Object) => { this.categories = data.categories; return ( ) }; 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}; } getRenderItem = ({item}: Object) => { const onPress = this.onListItemPress.bind(this, item); const categoriesRender = this.getCategoriesRender.bind(this, item.category); const hasManagers = item.responsibles.length > 0; return ( } right={(props) => } /> ); }; /** * Callback used when clicking an article in the list. * It opens the modal to show detailed information about the article * * @param item The article pressed */ onListItemPress(item: Object) { this.props.navigation.navigate("ClubDisplayScreen", {data: item, categories: this.categories}); } render() { return ( ); } } export default withTheme(ClubListScreen);