mirror of
https://github.com/zhigang1992/react-native-gifted-chat.git
synced 2026-01-12 17:42:27 +08:00
Add bubble prop optionTitles (#1091)
* Add bubble prop optionTitles * Fix break of app when array with length 0
This commit is contained in:
committed by
Xavier Carpentier
parent
a4fd557ce2
commit
ab1fb12c60
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user