HeaderList.js 2.52 KB
'use strict';

import React from 'react';
import Immutable, {Map} from 'immutable';
import YH_Image from '../../common/components/YH_Image';
import {getSlicedUrl} from '../../classify/utils/Utils';

import ReactNative, {
    View,
    Text,
    Image,
    StyleSheet,
    Dimensions,
    TouchableOpacity,
    Platform,
} from 'react-native';



export default class HeaderList extends React.Component {

    constructor(props) {
        super(props);
    }

    render() {
        let { resource ,lackNum} = this.props;
        if(!resource) return null;
        for (var i = 0; i < lackNum; i++) {
          resource.push({
            headUrl: '',
          })
        }

        return (
          <View style={styles.container}>
          {resource.map((item, i) => {
            let headUrl = item.headUrl && getSlicedUrl(item.headUrl, 40*DEVICE_WIDTH_RATIO, 40*DEVICE_WIDTH_RATIO, 2);
              if (i == 0) {
                return (
                  <View key={i} style={styles.icon1}>
                    <YH_Image style={{width: 40*DEVICE_WIDTH_RATIO,height: 40*DEVICE_WIDTH_RATIO}} url={headUrl} circle={true}></YH_Image>
                    <Image source={require('../images/PT_tx_tz.png')} style={styles.ovewicon} />
                  </View>
                );
              }else {
                if (!item.headUrl) {
                    return (
                      <Image key={i} source={require('../images/PT_head.png')} style={styles.icon} />
                    );
                }else {
                  return (
                      <YH_Image key={i} style={styles.icon} url={headUrl} circle={true}></YH_Image>
                  );
                }
              }

          })}
          </View>
        );
    }
}

let {width, height} = Dimensions.get('window');
const DEVICE_WIDTH_RATIO = width / 375;

let styles = StyleSheet.create({
    container: {
        flex: 1,
        width: width - 30*DEVICE_WIDTH_RATIO,
        height: 40*DEVICE_WIDTH_RATIO,
        justifyContent: 'center',
        flexDirection: 'row',
    },
    ovewicon: {
      width: 40*DEVICE_WIDTH_RATIO,
      height: 40*DEVICE_WIDTH_RATIO,
      position: 'absolute',
      top: 0,
      left: 0,
    },
    icon1: {
      width: 40*DEVICE_WIDTH_RATIO,
      height: 40*DEVICE_WIDTH_RATIO,
      borderRadius: 20*DEVICE_WIDTH_RATIO,
      overflow: 'hidden',
    },
    icon: {
      width: 40*DEVICE_WIDTH_RATIO,
      height: 40*DEVICE_WIDTH_RATIO,
      borderRadius: 20*DEVICE_WIDTH_RATIO,
      overflow: 'hidden',
      marginLeft: 20*DEVICE_WIDTH_RATIO,
    }
});