"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.TopBar = TopBar;
var _reactNative = require("react-native");
var _styles = require("./styles");
var _BackButton = _interopRequireDefault(require("../../../../../elements/BackButton"));
var _native = require("@react-navigation/native");
var _elements = require("../../../../../elements");
var _enums = require("../../../../../enums");
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
function TopBar({
  isFormDirty
}) {
  const {
    styles
  } = (0, _styles.useStyles)();
  const navigation = (0, _native.useNavigation)();
  const onBackPress = () => {
    if (isFormDirty) {
      _reactNative.Alert.alert('Unsaved changes', 'Are you sure you want to discard the changes? They will be lost when you leave this page.', [{
        text: 'Cancel',
        style: 'cancel'
      }, {
        text: 'Discard',
        style: 'destructive',
        onPress: navigation.goBack
      }]);
    } else {
      navigation.goBack();
    }
  };
  return /*#__PURE__*/React.createElement(_reactNative.View, {
    style: styles.container
  }, /*#__PURE__*/React.createElement(_BackButton.default, {
    pageId: _enums.PageID.edit_user_profile_page,
    onPress: onBackPress
  }), /*#__PURE__*/React.createElement(_elements.Title, {
    pageId: _enums.PageID.edit_user_profile_page,
    elementId: _enums.ElementID.title
  }), /*#__PURE__*/React.createElement(_reactNative.View, {
    style: styles.dummy
  }));
}
//# sourceMappingURL=TopBar.js.map