Add bubble prop optionTitles (#1091)

* Add bubble prop optionTitles

* Fix break of app when array with length 0
This commit is contained in:
Leonardo Pereira
2019-01-28 11:33:18 -02:00
committed by Xavier Carpentier
parent a4fd557ce2
commit ab1fb12c60

View File

@@ -19,7 +19,10 @@ export default class Bubble extends React.Component {
if (this.props.onLongPress) {
this.props.onLongPress(this.context, this.props.currentMessage);
} else if (this.props.currentMessage.text) {
const options = ['Copy Text', 'Cancel'];
const options =
this.props.optionTitles.length > 0
? this.props.optionTitles.slice(0, 2)
: ['Copy Text', 'Cancel'];
const cancelButtonIndex = options.length - 1;
this.context.actionSheet().showActionSheetWithOptions(
{
@@ -270,6 +273,7 @@ Bubble.defaultProps = {
renderTicks: null,
renderTime: null,
position: 'left',
optionTitles: ['Copy Text', 'Cancel'],
currentMessage: {
text: null,
createdAt: null,
@@ -299,6 +303,7 @@ Bubble.propTypes = {
renderTime: PropTypes.func,
renderTicks: PropTypes.func,
position: PropTypes.oneOf(['left', 'right']),
optionTitles: PropTypes.arrayOf(PropTypes.string),
currentMessage: PropTypes.object,
nextMessage: PropTypes.object,
previousMessage: PropTypes.object,