YH_Swiper.js 1.61 KB
import React from 'react';
import ReactNative from 'react-native';
import Swiper from 'react-native-swiper';
import RecyclerSwiper from '../recycler-swiper/recyclerswiper'


const {
    Component,
} = React;

const {
    View,
    Platform,
} = ReactNative;

/**
 *  轮播图片
 *
 **/
export default class YH_Swiper extends Component {

    constructor(props) {
        super (props);

        this.dot = <View
            style={{
                backgroundColor:'rgba(237, 237, 237, 0.5)',
                width: 6,
                height: 6,
                borderRadius: 3,
                marginLeft: 3,
                marginRight: 3,
                marginTop: 0,
            }}
        />;
        this.activeDot = <View
            style={{
                backgroundColor:'white',
                width: 6,
                height: 6,
                borderRadius: 3,
                marginLeft: 3,
                marginRight: 3,
                marginTop: 0,
            }}
        />;

	}

    render() {

        if (Platform.OS === 'ios') {
            return (
                <Swiper 
                    dot={this.dot}
                    activeDot={this.activeDot}
                    {...this.props} 
                >
                    {this.props.children}
                </Swiper>
            );
        }
        else{
            return (
                <RecyclerSwiper 
                    dot={this.dot}
                    activeDot={this.activeDot}
                    {...this.props} 
                >
                    {this.props.children}
                </RecyclerSwiper>
            );
        }
    }
}