jessesquires/JSQMessagesViewController — pull request #290 by adamcumiskey (2014-05-16 14:04:30+00:00)
Title: Issue 223 media messages

I've started work on adding media messages to the library. You can test it out in the demo by tapping the camera button on the toolbar and selecting an image.

I converted the JSQMessagesCollectionViewCell class to have a generic contentView instead of the older textView. I then subclassed that into a TextViewCell and ImageViewCell which had properties for a textView and imageView respectively. It would be ideal to go without these subclasses and just be able to add a subview to the contentView which would then size itself properly. This would make the cells extremely extensible, as you could display whatever you want without the need to subclass.

I think the best way to go about the media messages is to have separate bubbles for the text and the image. I think most messaging apps (Messenger, Google Hangouts, ect.) follow this because of how annoying it is to get a cell to layout with both a textView and imageView in it at the same time. I haven't yet figured out the best way to separate the messages, but I think it's definitely the smartest way forward.
I tried adding the image to an NSAttributedString, however the image cells never displayed anything and the other cells had text rendering issues.

I haven't made the JSQMessagesProtocol as described in the first message of this issue, and asynchronous loading is left up to the user. It can be done if you do a NSURLRequest to get the image, then call the setImage: method I added in the protocol, then invalidate the layout, however the layout will load a bit weird when loading several images. It would probably be better to handle it internally, however I don't think I know enough about the collection view layouts to implement it very well. Also, because the separation isn't fully implemented yet it will only show the image of the message without any text.

Please take a look and see what you think. If you have any ideas on how to improve it or if I'm doing anything that might affect the stability of the library let me know.