SectionItem.js 1.07 KB
'use strict';

import React from 'react';
import ReactNative from 'react-native';
import PropTypes from 'prop-types';

const {
    View,
    Text,
    Image,
    TouchableOpacity,
    StyleSheet,
    Dimensions,
} = ReactNative;

export default class SectionItem extends React.Component {

    static propTypes = {
        name: PropTypes.string.isRequired,
        onPressSection: PropTypes.func,
    };

    constructor(props) {
        super (props);

    }

    render() {
        if (!this.props.name) {
            return null;
        }
        
        return (
            <TouchableOpacity style={styles.container} onPress={() => {
                this.props.onPressSection && this.props.onPressSection();
            }}>
                <Text style={styles.name}>{this.props.name}</Text>
            </TouchableOpacity>
        );
    }
}

let styles = StyleSheet.create({
    container: {
        flexDirection: 'row',
        // alignItems: 'center',
        alignSelf: 'center',
        backgroundColor: '#f2f2f2',
    },
    name: {
        fontSize: 14,
        margin: 4,
    },
});