-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c264880
commit 3ad5627
Showing
2 changed files
with
91 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file was deleted.
Oops, something went wrong.