我使用有天赋的聊天库在 React Native 中开发了聊天视图。但我想在点击聊天气泡时执行删除操作。
我尝试了自定义 renderCustomView 、lightboxProps 和 onLongPress 道具,但都没有工作。
我使用有天赋的聊天库在 React Native 中开发了聊天视图。但我想在点击聊天气泡时执行删除操作。
我尝试了自定义 renderCustomView 、lightboxProps 和 onLongPress 道具,但都没有工作。
像这样将 onLongPress 添加到 GiftedChat 组件
<GiftedChat
onLongPress={this.onLongPress}
....
....
/>
onLongPress 返回context, message
。然后您可以显示一个 ActionSheet 并添加要删除的逻辑。
onLongPress(context, message) {
console.log(context, message);
const options = ['Delete Message', 'Cancel'];
const cancelButtonIndex = options.length - 1;
context.actionSheet().showActionSheetWithOptions({
options,
cancelButtonIndex
}, (buttonIndex) => {
switch (buttonIndex) {
case 0:
// Your delete logic
break;
case 1:
break;
}
});
}