TrendText.js 2.3 KB
'use strict';

import React from 'react';
import ReactNative from 'react-native';


const {
    Component,
} = React;


const {
    View,
    Text,
    Image,
    Platform,
    StyleSheet,
} = ReactNative;


export default class TrendText extends Component {

    static propTypes = {
        topText: React.PropTypes.string,
        bottomText: React.PropTypes.string,
        smallText: React.PropTypes.string,
        arrowUp: React.PropTypes.bool,
        containerStyle: View.propTypes.style,
        topTextStyle: View.propTypes.style,
        bottomTextStyle: View.propTypes.style,
        imageStyle: View.propTypes.style,
        smallTextStyle: View.propTypes.style,
    };

	render() {

        let arrow = this.props.arrowUp ? require('../images/arrow_up.png') : require('../images/arrow_down.png');
        let bottomTextColor = this.props.arrowUp ? styles.bottomTextUp : styles.bottomTextDown;

        return (
            <View style={[styles.container, this.props.containerStyle]}>
                <Text style={[styles.topText, this.props.topTextStyle]}>{this.props.topText}</Text>
                <View style={styles.richContainer}>
                    <Image source={arrow} style={[styles.image, this.props.imageStyle]} />
                    <Text style={[styles.bottomText, bottomTextColor, this.props.bottomTextStyle]}>{this.props.bottomText}</Text>
                    <Text style={[styles.smallText, this.props.smallTextStyle]}>{this.props.smallText}</Text>
                </View>

            </View>
        );
    }
}

let styles = StyleSheet.create({
    container: {

    },
    topText: {
        fontSize: 14,
        color: '#444444',
        textAlign: 'center',
        lineHeight: 20,
        marginTop: 15,
        marginBottom: 10,
    },
    richContainer: {
        flex: 1,
        flexDirection: 'row',
        justifyContent: 'center',
        alignSelf: 'center',
        alignItems: 'center',
        marginBottom: 15,
    },
    image: {
        // width: 9,
        // height: 12,
    },
    bottomText: {
        fontSize: 17,
        fontWeight: 'bold',
        textAlign: 'center',
    },
    bottomTextUp: {
        color: '#D0021B',
    },
    bottomTextDown: {
        color: '#86BF4A',
    },
    smallText: {
        fontSize: 12,
        textAlign: 'center',
        color: '#444444',
    },

});