diff --git a/screens/Amicale/ProfileScreen.js b/screens/Amicale/ProfileScreen.js index b1df254..ad04225 100644 --- a/screens/Amicale/ProfileScreen.js +++ b/screens/Amicale/ProfileScreen.js @@ -1,8 +1,10 @@ import * as React from 'react'; -import {ScrollView, StyleSheet} from "react-native"; +import {FlatList, StyleSheet} from "react-native"; import {Avatar, Button, Card, Divider, List, withTheme} from 'react-native-paper'; import AuthenticatedScreen from "../../components/AuthenticatedScreen"; import {openBrowser} from "../../utils/WebBrowser"; +import ConnectionManager from "../../managers/ConnectionManager"; +import HeaderButton from "../../components/HeaderButton"; type Props = { navigation: Object, @@ -17,71 +19,176 @@ class ProfileScreen extends React.Component { colors: Object; + data: Object; + + flatListData: Array; + constructor(props) { super(props); this.colors = props.theme.colors; + this.onClickDisconnect = this.onClickDisconnect.bind(this); + this.flatListData = [ + {id: 0}, + {id: 1}, + {id: 2}, + ] + } + + componentDidMount() { + const rightButton = this.getHeaderButtons.bind(this); + this.props.navigation.setOptions({ + headerRight: rightButton, + }); + } + + getHeaderButtons() { + return ; + } + + onClickDisconnect() { + ConnectionManager.getInstance().disconnect() + .then(() => { + this.props.navigation.reset({ + index: 0, + routes: [{name: 'Main'}], + }); + }); } getScreen(data: Object) { - console.log(data); + this.data = data; return ( - - - } - /> - - - - INFORMATIONS PERSONNELLES - } - /> - } - /> - } - /> - } - /> - - - - - - - - - - - ETAT COTISATION - {this.getMembershipItem(data.validity)} - - - - + this.getRenderItem(item)} + keyExtractor={item => item.id} + data={this.flatListData} + /> ) } + getRenderItem({item}: Object) { + switch (item.id) { + case 0: + return this.getPersonalCard(); + case 1: + return this.getClubCard(); + case 2: + return this.getMembershipCar(); + } + } + + + getPersonalCard() { + return ( + + } + /> + + + + INFORMATIONS PERSONNELLES + } + /> + } + /> + } + /> + } + /> + + + + + + + + ); + } + + getClubCard() { + return ( + + } + /> + + + {this.getClubList(this.data.clubs)} + + + ); + } + + getMembershipCar() { + return ( + + } + /> + + + {this.getMembershipItem(this.data.validity)} + + + + ); + } + + getClubList(list: Array) { + let dataset = []; + for (let i = 0; i < list.length; i++) { + dataset.push({name: list[i]}); + } + return ( + + } + /> + } + keyExtractor={item => item.name} + data={dataset} + /> + ); + } + getMembershipItem(state: boolean) { return (