"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.TypeSelect = exports.ScrollTab = void 0;
var React = _interopRequireWildcard(require("react"));
var _reactNative = require("react-native");
var _scrollInto = require("./scrollInto");
var _color = require("./color");
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
const $container = {
  minHeight: '100%',
  backgroundColor: _color.color.white,
  paddingBottom: 16,
  maxHeight: '100%'
};
const ScrollTab = function ScrollTab(props) {
  const [dataSourceCords, setDataSourceCords] = React.useState([]);
  const {
    style,
    onPressItem,
    dataMenu,
    styleTitle,
    styleViewTitle
  } = props;
  const styles = Object.assign({}, $container, style);
  const stylesTitle = Object.assign({}, $title, styleTitle);
  const stylesViewTitle = Object.assign({}, $viewTitle, styleViewTitle);
  return /*#__PURE__*/React.createElement(_reactNative.View, {
    style: styles
  }, /*#__PURE__*/React.createElement(_scrollInto.ScrollInto, {
    dataHeader: dataMenu,
    dataLengthView: dataSourceCords
  }, dataMenu.map((item, index) => {
    return /*#__PURE__*/React.createElement(_reactNative.View, {
      key: index,
      onLayout: event => {
        // lấy ra vị của view
        const layout = event.nativeEvent.layout;
        dataSourceCords[index] = layout.y;
        // set vào mảng
        setDataSourceCords(dataSourceCords);
      }
    }, /*#__PURE__*/React.createElement(_reactNative.View, {
      style: stylesViewTitle
    }, /*#__PURE__*/React.createElement(_reactNative.Text, {
      style: [stylesTitle]
    }, item.tile)), item.option.map((title, indexOption) => /*#__PURE__*/React.createElement(TypeSelect, {
      key: indexOption,
      title: title,
      onSelect: () => onPressItem(title)
    })));
  })));
};
exports.ScrollTab = ScrollTab;
const TypeSelect = props => {
  const {
    title,
    onSelect
  } = props;
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(_reactNative.TouchableOpacity, {
    onPress: onSelect
  }, /*#__PURE__*/React.isValidElement(title) ? title : /*#__PURE__*/React.createElement(_reactNative.Text, {
    style: $textSelect
  }, title)), /*#__PURE__*/React.createElement(_reactNative.View, {
    style: {
      height: 1,
      backgroundColor: _color.color.backgroundSoft
    }
  }));
};
exports.TypeSelect = TypeSelect;
const $textSelect = {
  fontSize: 14,
  color: _color.color.neutral700,
  flex: 1,
  margin: 16
};
const $viewTitle = {
  paddingHorizontal: 16,
  paddingTop: 16,
  paddingBottom: 8,
  backgroundColor: _color.color.backgroundSoft
};
const $title = {
  fontSize: 18,
  color: _color.color.neutral600
};
//# sourceMappingURL=ScrollTab.js.map