/*
 * @Author: codingfly
 * @Description:
 * @Date: 2021-08-18 08:11:05
 * @LastEditTime: 2021-09-06 09:02:29
 * @FilePath: \young\components\images\index.tsx
 */
import * as React from 'react';
import { View, Image } from 'remax/one';
import { previewImage } from '../one';
import { getPrefixCls } from './../common';
var prefixCls = getPrefixCls('images');

var Images = function Images(props) {
  var _props$data = props.data,
      data = _props$data === void 0 ? [] : _props$data;

  var handleClickImage = function handleClickImage(index) {
    var urls = data;
    var current = index;

    if (typeof data[index] !== 'string') {
      urls = data.map(function (i) {
        return i.url;
      });
    }

    previewImage({
      urls: urls,
      current: current,
      // @ts-ignore
      enablesavephoto: true,
      enableShowPhotoDownload: true
    });
  };

  return /*#__PURE__*/React.createElement(View, {
    className: prefixCls
  }, data && data.map(function (item, index) {
    return /*#__PURE__*/React.createElement(View, {
      key: item.key || index,
      className: "".concat(prefixCls, "-item"),
      onTap: function onTap() {
        return handleClickImage(index);
      }
    }, /*#__PURE__*/React.createElement(Image, {
      mode: "widthFix",
      src: item.url || item
    }));
  }));
};

export default Images;