function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
import React, { Component, PropsWithChildren } from 'react';
import { Animated, StyleSheet, Text, View, I18nManager, Image } from 'react-native';
import { RectButton } from 'react-native-gesture-handler';
import Swipeable from 'react-native-gesture-handler/Swipeable';
import { Log } from "../utils";
export default class ChatSwipeableRow extends Component {
  constructor() {
    super(...arguments);
    _defineProperty(this, "renderLeftActions", (_progress, dragX) => {
      const trans = dragX.interpolate({
        inputRange: [0, 50, 100, 101],
        outputRange: [-20, 0, 0, 1],
        extrapolate: 'clamp'
      });
      return /*#__PURE__*/React.createElement(RectButton, {
        style: styles.leftAction,
        onPress: this.close
      }, /*#__PURE__*/React.createElement(Animated.Text, {
        style: [styles.actionText, {
          transform: [{
            translateX: trans
          }]
        }]
      }, "Archive"));
    });
    _defineProperty(this, "renderRightAction", (text, icon, color, x, progress, onPress) => {
      const trans = progress.interpolate({
        inputRange: [0, 1],
        outputRange: [x, 0]
      });
      const pressHandler = () => {
        if (onPress) onPress();
        this.close();
      };
      return /*#__PURE__*/React.createElement(Animated.View, {
        style: {
          flex: 1,
          transform: [{
            translateX: trans
          }]
        }
      }, /*#__PURE__*/React.createElement(RectButton, {
        style: [styles.rightAction, {
          backgroundColor: color
        }],
        onPress: pressHandler
      }, /*#__PURE__*/React.createElement(Image, {
        style: {
          width: 20,
          height: 20,
          resizeMode: 'contain'
        },
        source: icon
      }), /*#__PURE__*/React.createElement(Text, {
        style: styles.actionText
      }, text)));
    });
    _defineProperty(this, "renderRightActions", (progress, _dragAnimatedValue) => /*#__PURE__*/React.createElement(View, {
      style: {
        width: 192,
        flexDirection: I18nManager.isRTL ? 'row-reverse' : 'row'
      }
    }, this.renderRightAction('Bỏ ghim', require('../assets/ic_unpin.png'), '#3B7CEC', 198, progress, this.props.onPress1), this.renderRightAction('Xoá', require('../assets/ic_trash.png'), '#EE0033', 66, progress, this.props.onPress3)));
    _defineProperty(this, "swipeableRow", void 0);
    _defineProperty(this, "updateRef", ref => {
      this.swipeableRow = ref;
    });
    _defineProperty(this, "close", () => {
      var _this$swipeableRow;
      (_this$swipeableRow = this.swipeableRow) === null || _this$swipeableRow === void 0 ? void 0 : _this$swipeableRow.close();
    });
  }
  render() {
    const {
      children
    } = this.props;
    return /*#__PURE__*/React.createElement(Swipeable, {
      ref: this.updateRef,
      friction: 2,
      enableTrackpadTwoFingerGesture: true,
      leftThreshold: 30,
      rightThreshold: 40
      // renderLeftActions={this.renderLeftActions}
      ,
      renderRightActions: this.renderRightActions,
      onSwipeableOpen: direction => {
        Log(`Opening swipeable from the ${direction}`);
      },
      onSwipeableClose: direction => {
        Log(`Closing swipeable to the ${direction}`);
      }
    }, children);
  }
}
const styles = StyleSheet.create({
  leftAction: {
    flex: 1,
    backgroundColor: '#497AFC',
    justifyContent: 'center'
  },
  actionText: {
    color: 'white',
    fontSize: 13,
    backgroundColor: 'transparent',
    textAlign: 'center',
    paddingTop: 4
  },
  rightAction: {
    alignItems: 'center',
    flex: 1,
    justifyContent: 'center'
  }
});
//# sourceMappingURL=ChatSwipeableRow.js.map