YH_ToolTips.js 2.57 KB
'use strict';

import React, { Component } from 'react';
import {
    View,
    Text,
    Dimensions,
    StyleSheet,
} from 'react-native';


export default class YH_ToolTips extends Component {
    constructor(props) {
        super(props);
    }

    render (){
        if (this.props.isShow) {
            return (
                <View style={[styles.container,this.props.style]}>
                    <View style={styles.content}>
                        {
                            this.props.actions.map((item,index)=>{
                                return (
                                    <View
                                        style={index==this.props.actions.length-1 ? styles.textContainer : [styles.textContainer, styles.midLine]}
                                        key={`toolTip${index}`}
                                    >
                                        <Text
                                             style={styles.textStyle}
                                             key={`toolTip${index}`}
                                             onPress={item.onPress}
                                         >
                                             {item.text}
                                         </Text>
                                    </View>
                                );
                            })
                        }
                    </View>
                    <View style={styles.arrow}>
                    </View>
                </View>
            );
        }else {
            return <View />;
        }
    }
}

let {width, height}=Dimensions.get('window');

let styles = StyleSheet.create({
    container: {
        justifyContent: 'center',
        alignItems: 'center',
        alignSelf: 'center',
        width,
        height: 44,
        flexDirection: 'column',
    },

    content: {
        height: 34,
        backgroundColor: "#2a2a2a",
        borderRadius: 5,
        flexDirection: 'row',
        justifyContent: 'center',
        alignItems: 'center'
    },

    textContainer: {
        height: 20,
        justifyContent: 'center',
        alignItems: 'center'
    },

    textStyle: {
        paddingLeft: 10,
        paddingRight: 10,
        color: 'white',
        textAlign: 'center',
        fontSize: 12,
        backgroundColor: 'transparent'
    },

    midLine: {
        borderRightWidth: StyleSheet.hairlineWidth,
        borderRightColor: 'white',
    },

    arrow:{
        borderWidth: 9,
        borderColor: 'transparent',
        width: 0,
        height: 0,
        borderTopColor: '#2a2a2a',
    },
})