I am using JSQMessage for a chat application. On long press i am able to display default menu options (Copy & Delete)
Now the challenge is to add another option in menu. Any help will be appreciated.
Code for the default menu option is
override func collectionView(_ collectionView: UICollectionView, shouldShowMenuForItemAt indexPath: IndexPath) -> Bool {
super.collectionView(collectionView, shouldShowMenuForItemAt: indexPath)
return true;
}
override func collectionView(_ collectionView: UICollectionView, canPerformAction action: Selector, forItemAt indexPath: IndexPath, withSender sender: Any?) -> Bool {
let message = messageList[indexPath.item]
switch action.description {
case quickChatOptionDelete:
// you can only delete your sent messages
if message.senderId == strMemberID {
return true
} else {
return false
}
case quickChatOptionCopy:
return true
case quickChatOptionUserList:
return true
default:
return false
}
}
override func collectionView(_ collectionView: UICollectionView, performAction action: Selector, forItemAt indexPath: IndexPath, withSender sender: Any?) {
let message = messageList[indexPath.item]
switch action.description {
case quickChatOptionDelete:
if message.senderId == strMemberID {
deleteMessage(messageId:message.messageId!)
}
break
case quickChatOptionCopy: break
case quickChatOptionUserList:
print("list")
break
default: break
// do nothing
}
}