"use strict";

exports.__esModule = true;
exports.default = exports.HEADER_HEIGHT = void 0;
var _react = _interopRequireWildcard(require("react"));
var _reactNative = require("react-native");
var _novaIcons = require("@coorpacademy/nova-icons");
var _templateContext = require("../../template/app-review/template-context");
var _index = _interopRequireDefault(require("../../molecule/brand-logo/index.native"));
var _index2 = _interopRequireDefault(require("../../atom/gradient/index.native"));
var _index3 = _interopRequireDefault(require("../../hoc/touchable/index.native"));
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
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 HEADER_HEIGHT = exports.HEADER_HEIGHT = 67;
const ICON_WIDTH = 20;
const createStyleSheet = theme => _reactNative.StyleSheet.create({
  container: {
    position: 'absolute',
    backgroundColor: theme.colors.white,
    flexDirection: 'row',
    alignItems: 'center',
    justifyContent: 'space-between',
    height: HEADER_HEIGHT,
    top: 0,
    width: '100%'
  },
  icons: {
    flexDirection: 'row'
  },
  icon: {
    marginRight: 16
  },
  logo: {
    width: 80,
    marginLeft: 16
  },
  gradient: {
    position: 'absolute',
    left: 0,
    top: HEADER_HEIGHT,
    right: 0,
    opacity: 0.3
  }
});
const Header = props => {
  const templateContext = (0, _templateContext.useTemplateContext)();
  const [styleSheet, setStylesheet] = (0, _react.useState)(null);
  const {
    theme
  } = templateContext;
  const {
    onSearchPress,
    onSettingsPress,
    onLogoLongPress
  } = props;
  const logoHeight = HEADER_HEIGHT - theme.spacing.small * 2;
  (0, _react.useEffect)(() => {
    const _stylesheet = createStyleSheet(theme);
    setStylesheet(_stylesheet);
  }, [theme]);

  // ------------------------------------

  if (!styleSheet) {
    return null;
  }
  return /*#__PURE__*/_react.default.createElement(_reactNative.View, {
    style: [styleSheet.container],
    testID: "header"
  }, /*#__PURE__*/_react.default.createElement(_index2.default, {
    height: theme.spacing.tiny,
    colors: [theme.colors.gray.medium, theme.colors.gray.light],
    transparencyPosition: "bottom",
    style: styleSheet.gradient
  }), /*#__PURE__*/_react.default.createElement(_reactNative.View, {
    style: styleSheet.logo
  }, /*#__PURE__*/_react.default.createElement(_index3.default, {
    testID: "header-logo",
    onLongPress: onLogoLongPress,
    analyticsID: "sign-out",
    isWithoutFeedback: true
  }, /*#__PURE__*/_react.default.createElement(_index.default, {
    height: logoHeight
  }))), /*#__PURE__*/_react.default.createElement(_reactNative.View, {
    style: [styleSheet.icons]
  }, /*#__PURE__*/_react.default.createElement(_index3.default, {
    testID: "search-icon",
    onPress: onSearchPress,
    analyticsID: "search-icon"
  }, /*#__PURE__*/_react.default.createElement(_novaIcons.NovaCompositionCoorpacademySearch, {
    height: ICON_WIDTH,
    width: ICON_WIDTH,
    color: theme.colors.gray.dark,
    style: styleSheet.icon
  })), /*#__PURE__*/_react.default.createElement(_index3.default, {
    testID: "settings-icon",
    onPress: onSettingsPress,
    analyticsID: "settings-icon"
  }, /*#__PURE__*/_react.default.createElement(_novaIcons.NovaCompositionCoorpacademyCog, {
    height: ICON_WIDTH,
    width: ICON_WIDTH,
    color: theme.colors.gray.dark,
    style: styleSheet.icon
  }))));
};
var _default = exports.default = Header;
//# sourceMappingURL=index.native.js.map