"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _theme = require("../../contexts/theme");
var _react = _interopRequireWildcard(require("react"));
var _reactNative = require("react-native");
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
const ProgressBar = ({
  progressPercent
}) => {
  const {
    ColorPallet
  } = (0, _theme.useTheme)();
  const {
    width: windowWidth
  } = (0, _reactNative.useWindowDimensions)();
  const [progressBarScale] = (0, _react.useState)(new _reactNative.Animated.Value(0));
  (0, _react.useEffect)(() => {
    _reactNative.Animated.timing(progressBarScale, {
      toValue: progressPercent,
      duration: 300,
      useNativeDriver: true // allows for much smoother animation
    }).start();
  }, [progressBarScale, progressPercent]);
  const styles = _reactNative.StyleSheet.create({
    progressBarContainer: {
      width: '100%',
      height: 8,
      backgroundColor: ColorPallet.brand.primaryBackground
    },
    progressBar: {
      height: '100%',
      width: '100%',
      backgroundColor: ColorPallet.brand.highlight
    }
  });
  // scaleX rather than width is used for the progress bar as this allows useNativeDriver to be true
  const scaleX = progressBarScale.interpolate({
    inputRange: [0, 100],
    outputRange: [0, 1]
  });
  const animatedBarStyle = {
    // without these two translates, the progress would start from the center and expand outward, rather than start from the left
    transform: [{
      translateX: -(windowWidth / 2)
    }, {
      scaleX
    }, {
      translateX: windowWidth / 2
    }]
  };
  return /*#__PURE__*/_react.default.createElement(_reactNative.View, {
    style: styles.progressBarContainer
  }, /*#__PURE__*/_react.default.createElement(_reactNative.Animated.View, {
    style: [_reactNative.StyleSheet.absoluteFill, styles.progressBar, animatedBarStyle]
  }));
};
var _default = exports.default = ProgressBar;
//# sourceMappingURL=ProgressBar.js.map