import React from 'react'; import { ScrollView, View, StyleSheet, } from 'react-native'; import { RkText, RkButton, RkStyleSheet, } from 'react-native-ui-kitten'; import { MainRoutes } from '../../config/navigation/routes'; import NavigationType from '../../config/navigation/propTypes'; export class GridV2 extends React.Component { static propTypes = { navigation: NavigationType.isRequired, }; static navigationOptions = { title: 'Grid Menu'.toUpperCase(), }; state = { dimensions: undefined, }; onContainerLayout = (event) => { if (this.state.height) { return; } const dimensions = event.nativeEvent.layout; this.setState({ dimensions }); }; renderItems = () => MainRoutes.map(this.renderItem); renderItem = (item) => ( this.onItemPressed(item)}> {item.icon} {item.title} ); onItemPressed = (item) => { this.props.navigation.navigate(item.id); }; render() { const items = this.state.dimensions === undefined ? : this.renderItems(); return ( {items} ); } } const styles = RkStyleSheet.create(theme => ({ root: { backgroundColor: theme.colors.screen.base, }, rootContainer: { flexDirection: 'row', flexWrap: 'wrap', }, empty: { borderWidth: StyleSheet.hairlineWidth, borderColor: theme.colors.border.base, }, icon: { marginBottom: 16, }, }));