import { Alert, View } from 'react-native';
import { useStyles } from './styles';
import BackButton from '../../../../../elements/BackButton';
import { useNavigation } from '@react-navigation/native';
import { Title } from '../../../../../elements';
import { ElementID, PageID } from '../../../../../enums';
export function TopBar({
  isFormDirty
}) {
  const {
    styles
  } = useStyles();
  const navigation = useNavigation();
  const onBackPress = () => {
    if (isFormDirty) {
      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(View, {
    style: styles.container
  }, /*#__PURE__*/React.createElement(BackButton, {
    pageId: PageID.edit_user_profile_page,
    onPress: onBackPress
  }), /*#__PURE__*/React.createElement(Title, {
    pageId: PageID.edit_user_profile_page,
    elementId: ElementID.title
  }), /*#__PURE__*/React.createElement(View, {
    style: styles.dummy
  }));
}
//# sourceMappingURL=TopBar.js.map