session-ios/Signal/src/Models/OWSMessagesBubblesSizeCalculator.m
Michael Kirk 4d320d6015 Unfork JSQMessagesViewController
Geting back on upstream fixes a couple bugs (see ##Bugfixes), and also
will make future updates easier.

The unforking process was basically this:

* move custom message types (Calls and DisplayedMessages) classes from our
  custom JSQMVC fork into Signal-iOS.
* Move any method customization into our subclass. Including
  ColletionView stuff, bubble sizing, and gesture behavior

Bug Fixes
---------
* Fix mis-sized incoming media bubbles.

Bubble size was being cached by interaction id. Which broke when
receiving an attachment. The problem is that incoming media messages
were initially the height of a "Downloading Attachment" info message.
Instead we use the mediaHash for media messages to expire the bubble
size when the media changes.

* fix missized bubble when MVC did appear

The MessagesViewController isn't sized correctly until ViewWillAppear.
This caused the first round of bubbles to be rendered incorrectly (they
assumed a larger container than they had).  I think is reflected in the
current version of the app by a reflow occurring shortly after the view
appears.

Chores
------
* bump travis to build with xcode8
* specify RQV development team for device build. required by xcode 8 beta

Cleanup
------
* Refactor messageing XIB so that elements are hangning outside of
  the views frame
* Fix compiler warning with explicit cast
* delete deprecated lineBreakmode, it's the default value anyway.

// FREEBIE
2016-07-14 23:15:05 -07:00

46 lines
1.6 KiB
Objective-C

//
// OWSMessagesBubblesSizeCalculator.m
// Signal
//
// Created by Michael Kirk on 7/10/16.
// Copyright © 2016 Open Whisper Systems. All rights reserved.
//
#import "OWSMessagesBubblesSizeCalculator.h"
#import "TSMessageAdapter.h"
#import "JSQDisplayedMessageCollectionViewCell.h"
@implementation OWSMessagesBubblesSizeCalculator
/**
* Computes and returns the size of the `messageBubbleImageView` property
* of a `JSQMessagesCollectionViewCell` for the specified messageData at indexPath.
*
* @param messageData A message data object.
* @param indexPath The index path at which messageData is located.
* @param layout The layout object asking for this information.
*
* @return A sizes that specifies the required dimensions to display the entire message contents.
* Note, this is *not* the entire cell, but only its message bubble.
*/
- (CGSize)messageBubbleSizeForMessageData:(id<JSQMessageData>)messageData
atIndexPath:(NSIndexPath *)indexPath
withLayout:(JSQMessagesCollectionViewFlowLayout *)layout
{
CGSize superSize = [super messageBubbleSizeForMessageData:messageData
atIndexPath:indexPath
withLayout:layout];
TSMessageAdapter *message = (TSMessageAdapter *)messageData;
if (message.messageType == TSInfoMessageAdapter ||
message.messageType == TSErrorMessageAdapter) {
// Prevent cropping message text by accounting for message container/icon
superSize.height = OWSDisplayedMessageCellHeight;
}
return superSize;
}
@end