Skip to content

Commit

Permalink
Fixing Review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
SameeraMadushan committed Mar 22, 2021
1 parent c264880 commit 3ad5627
Show file tree
Hide file tree
Showing 2 changed files with 91 additions and 98 deletions.
91 changes: 91 additions & 0 deletions src/components/ConfirmModal.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
import React from 'react';
import {
TouchableOpacity, Text, View,
} from 'react-native';
import PropTypes from 'prop-types';
import Header from './Header';
import Modal from './Modal';
import styles from '../styles/styles';
import CONST from '../CONST';
import withWindowDimensions, {windowDimensionsPropTypes} from './withWindowDimensions';

const propTypes = {
/** Title of the modal */
title: PropTypes.string.isRequired,

/** A callback to call when the form has been submitted */
onConfirm: PropTypes.func.isRequired,

/** A callback to call when the form has been closed */
onCancel: PropTypes.func.isRequired,

/** Modal visibility */
isVisible: PropTypes.bool.isRequired,

/** Confirm button text */
confirmText: PropTypes.string,

/** Cancel button text */
cancelText: PropTypes.string,

/** Modal content text */
prompt: PropTypes.string,

...windowDimensionsPropTypes,
};

const defaultProps = {
confirmText: 'Yes',
cancelText: 'No',
prompt: '',
};

const ConfirmModal = props => (
<Modal
onSubmit={props.onConfirm}
onClose={props.onCancel}
isVisible={props.isVisible}
type={props.isSmallScreenWidth
? CONST.MODAL.MODAL_TYPE.BOTTOM_DOCKED
: CONST.MODAL.MODAL_TYPE.CONFIRM}
>
<View style={styles.m5}>
<View style={styles.flexRow}>
<Header title={props.title} />
</View>

<Text style={[styles.textLabel, styles.mt4]}>
{props.prompt}
</Text>

<TouchableOpacity
style={[styles.button, styles.buttonSuccess, styles.mt4]}
onPress={props.onConfirm}
>
<Text
style={[
styles.buttonText,
styles.buttonSuccessText,
styles.buttonConfirmText,
]}
>
{props.confirmText}
</Text>
</TouchableOpacity>

<TouchableOpacity
style={[styles.button, styles.mt3]}
onPress={props.onCancel}
>
<Text style={styles.buttonText}>
{props.cancelText}
</Text>
</TouchableOpacity>
</View>
</Modal>
);

ConfirmModal.propTypes = propTypes;
ConfirmModal.defaultProps = defaultProps;
ConfirmModal.displayName = 'ConfirmModal';
export default withWindowDimensions(ConfirmModal);
98 changes: 0 additions & 98 deletions src/components/ConfirmModal/index.js

This file was deleted.

0 comments on commit 3ad5627

Please sign in to comment.