import * as React from 'react';
import * as PropTypes from 'prop-types';
import { requireNativeComponent, ViewPropTypes } from 'react-native';
import type { LatLng } from '../types';
import { LatLngPropType } from '../prop-types';

export interface TexturePolylineProps {
    /**
     * 节点坐标
     */
    coordinates: LatLng[];

    /**
     * 线段宽度
     */
    width?: number;
    /**
     * 纹理名称
     */
    texture?: string;
    /**
     * 点击事件
     */
    onPress?: () => void;
}

/**
 * @ignore
 */
export default class TexturePolyline extends React.PureComponent<TexturePolylineProps> {
    static propTypes = {
        ...ViewPropTypes,
        coordinates: PropTypes.arrayOf(LatLngPropType).isRequired,
        width: PropTypes.number,
        texture: PropTypes.string,
        onPress: PropTypes.func,
    };

    static defaultProps = {
        width: 15,
    };

    render() {
        return <AMapTexturePolyline {...this.props} />;
    }
}

// @ts-ignore
const AMapTexturePolyline = requireNativeComponent('AMapTexturePolyline', TexturePolyline);
