// @flow import * as React from 'react'; import {Platform, Dimensions, StyleSheet, Image, FlatList, Linking} from 'react-native'; import {Badge, Text, Container, Content, Left, ListItem, Right} from "native-base"; import i18n from "i18n-js"; import CustomMaterialIcon from '../components/CustomMaterialIcon'; const deviceHeight = Dimensions.get("window").height; const drawerCover = require("../assets/drawer-cover.png"); const WIKETUD_LINK = "https://www.etud.insa-toulouse.fr/wiketud/index.php/Accueil"; type Props = { navigation: Object, }; type State = { active: string, }; /** * Class used to define a navigation drawer */ export default class SideBar extends React.Component { dataSet: Array; state = { active: 'Home', }; /** * Generate the datasets * * @param props */ constructor(props: Props) { super(props); this.dataSet = [ { name: i18n.t('screens.home'), route: "Home", icon: "home", bg: "#C5F442" // types: "11" // Shows the badge }, { name: i18n.t('screens.planning'), route: "Planning", icon: "calendar-range", bg: "#477EEA", // types: "11" }, { name: "Proxiwash", route: "Proxiwash", icon: "washing-machine", bg: "#477EEA", // types: "11" }, { name: "Proximo", route: "Proximo", icon: "shopping", bg: "#477EEA", // types: "11" }, { name: "Wiketud", route: "", icon: "web", bg: "#477EEA", // types: "11" }, { name: i18n.t('screens.settings'), route: "Settings", icon: "settings", bg: "#477EEA", // types: "11" }, { name: i18n.t('screens.about'), route: "About", icon: "information", bg: "#477EEA", // types: "11" }, ]; } /** * Navigate to the selected route, close the drawer, and mark the correct item as selected * @param route {string} The route name to navigate to */ navigateToScreen(route: string) { this.props.navigation.navigate(route); this.props.navigation.closeDrawer(); this.setState({active: route}); }; render() { return ( item.route} renderItem={({item}) => { if (item.name !== 'Wiketud') this.navigateToScreen(item.route); else Linking.openURL(WIKETUD_LINK).catch((err) => console.error('Error opening link', err)); }} > {item.name} {item.types && {`${item.types} Types`} } } /> ); } } const styles = StyleSheet.create({ drawerCover: { alignSelf: "stretch", height: deviceHeight / 4, width: null, position: "relative", marginBottom: 10, marginTop: 20 }, text: { fontWeight: Platform.OS === "ios" ? "500" : "400", fontSize: 16, marginLeft: 20 }, badgeText: { fontSize: Platform.OS === "ios" ? 13 : 11, fontWeight: "400", textAlign: "center", marginTop: Platform.OS === "android" ? -3 : undefined } });