Tweak intra-cell spacing.

This commit is contained in:
Matthew Chen 2018-06-26 11:02:30 -04:00
parent afa003926e
commit 89523f556b
3 changed files with 19 additions and 5 deletions

View File

@ -4910,13 +4910,15 @@ typedef enum : NSUInteger {
} }
lastInteractionType = interactionType; lastInteractionType = interactionType;
// If this is an existing view item and it has changed size, // When `shouldHideRecipientStatus` changes, reload the cell if necessary.
// note that so that we can reload this cell while doing
// incremental updates.
if (viewItem.shouldHideRecipientStatus != shouldHideRecipientStatus && viewItem.previousRow != NSNotFound) { if (viewItem.shouldHideRecipientStatus != shouldHideRecipientStatus && viewItem.previousRow != NSNotFound) {
[rowsThatChangedSize addObject:@(viewItem.previousRow)]; [rowsThatChangedSize addObject:@(viewItem.previousRow)];
} }
viewItem.shouldHideRecipientStatus = shouldHideRecipientStatus; viewItem.shouldHideRecipientStatus = shouldHideRecipientStatus;
// When `shouldHideAvatar` changes, reload the cell if necessary.
if (viewItem.shouldHideAvatar != shouldHideAvatar && viewItem.previousRow != NSNotFound) {
[rowsThatChangedSize addObject:@(viewItem.previousRow)];
}
viewItem.shouldHideAvatar = shouldHideAvatar; viewItem.shouldHideAvatar = shouldHideAvatar;
} }

View File

@ -271,8 +271,21 @@ NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType)
return 0.f; return 0.f;
} }
// "Bubble Collapse". Adjacent messages with the same author should be close together.
if (self.interaction.interactionType == OWSInteractionType_IncomingMessage
&& previousLayoutItem.interaction.interactionType == OWSInteractionType_IncomingMessage) {
TSIncomingMessage *incomingMessage = (TSIncomingMessage *)self.interaction;
TSIncomingMessage *previousIncomingMessage = (TSIncomingMessage *)previousLayoutItem.interaction;
if ([incomingMessage.authorId isEqualToString:previousIncomingMessage.authorId]) {
return 2.f;
}
} else if (self.interaction.interactionType == OWSInteractionType_OutgoingMessage
&& previousLayoutItem.interaction.interactionType == OWSInteractionType_OutgoingMessage) {
return 2.f;
}
// TODO: // TODO:
return 4.f; return 10.f;
} }
- (ConversationViewCell *)dequeueCellForCollectionView:(UICollectionView *)collectionView - (ConversationViewCell *)dequeueCellForCollectionView:(UICollectionView *)collectionView

View File

@ -233,7 +233,6 @@ NS_ASSUME_NONNULL_BEGIN
relation:NSLayoutRelationGreaterThanOrEqual], relation:NSLayoutRelationGreaterThanOrEqual],
[self.unreadBadge autoSetDimension:ALDimensionHeight toSize:unreadBadgeHeight], [self.unreadBadge autoSetDimension:ALDimensionHeight toSize:unreadBadgeHeight],
]]; ]];
}]; }];
const CGFloat kMinVMargin = 5; const CGFloat kMinVMargin = 5;