Fix layout of timestamp for system messages

Incorporate topLabelSize into cell size for system messages.

We are using the term "bubble size" to describe the interaction specific
views of a collection cell. It's a crappy name, but coincides with other
usage.

// FREEBIE
pull/1/head
Michael Kirk 7 years ago
parent 1125e2ac99
commit 4f3278db1e

@ -372,8 +372,8 @@
340CB2231EAC155C0001CAA1 /* ContactsViewHelper.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ContactsViewHelper.m; sourceTree = "<group>"; };
340CB2251EAC25820001CAA1 /* UpdateGroupViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UpdateGroupViewController.h; sourceTree = "<group>"; };
340CB2261EAC25820001CAA1 /* UpdateGroupViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = UpdateGroupViewController.m; sourceTree = "<group>"; };
341207251EE19F6A00463194 /* OWSSystemMessageCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OWSSystemMessageCell.h; sourceTree = "<group>"; };
341207261EE19F6A00463194 /* OWSSystemMessageCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OWSSystemMessageCell.m; sourceTree = "<group>"; };
341207251EE19F6A00463194 /* OWSSystemMessageCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = OWSSystemMessageCell.h; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
341207261EE19F6A00463194 /* OWSSystemMessageCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = OWSSystemMessageCell.m; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objc; };
341BB7471DB727EE001E2975 /* JSQMediaItem+OWS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "JSQMediaItem+OWS.h"; sourceTree = "<group>"; };
341BB7481DB727EE001E2975 /* JSQMediaItem+OWS.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "JSQMediaItem+OWS.m"; sourceTree = "<group>"; };
34330A591E7875FB00DF2FB9 /* fontawesome-webfont.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "fontawesome-webfont.ttf"; sourceTree = "<group>"; };
@ -502,8 +502,8 @@
34E8BF3A1EEB208E00F5F4CA /* DebugUIVerification.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DebugUIVerification.m; sourceTree = "<group>"; };
34F3089A1ECA4CDB00BB7697 /* TSUnreadIndicatorInteraction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TSUnreadIndicatorInteraction.h; sourceTree = "<group>"; };
34F3089B1ECA4CDB00BB7697 /* TSUnreadIndicatorInteraction.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TSUnreadIndicatorInteraction.m; sourceTree = "<group>"; };
34F3089D1ECA580B00BB7697 /* OWSUnreadIndicatorCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OWSUnreadIndicatorCell.h; sourceTree = "<group>"; };
34F3089E1ECA580B00BB7697 /* OWSUnreadIndicatorCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OWSUnreadIndicatorCell.m; sourceTree = "<group>"; };
34F3089D1ECA580B00BB7697 /* OWSUnreadIndicatorCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = OWSUnreadIndicatorCell.h; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
34F3089E1ECA580B00BB7697 /* OWSUnreadIndicatorCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = OWSUnreadIndicatorCell.m; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objc; };
34F308A01ECB469700BB7697 /* OWSBezierPathView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OWSBezierPathView.h; sourceTree = "<group>"; };
34F308A11ECB469700BB7697 /* OWSBezierPathView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OWSBezierPathView.m; sourceTree = "<group>"; };
34FD936E1E3BD43A00109093 /* OWSAnyTouchGestureRecognizer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OWSAnyTouchGestureRecognizer.h; path = views/OWSAnyTouchGestureRecognizer.h; sourceTree = "<group>"; };
@ -542,7 +542,7 @@
45387B031E36D650005D00B3 /* OWS102MoveLoggingPreferenceToUserDefaults.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OWS102MoveLoggingPreferenceToUserDefaults.m; path = Migrations/OWS102MoveLoggingPreferenceToUserDefaults.m; sourceTree = "<group>"; };
453CC0361D08E1A60040EBA3 /* sn */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = sn; path = translations/sn.lproj/Localizable.strings; sourceTree = "<group>"; };
453D28B81D332DB100D523F0 /* OWSMessagesBubblesSizeCalculator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OWSMessagesBubblesSizeCalculator.h; sourceTree = "<group>"; };
453D28B91D332DB100D523F0 /* OWSMessagesBubblesSizeCalculator.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OWSMessagesBubblesSizeCalculator.m; sourceTree = "<group>"; };
453D28B91D332DB100D523F0 /* OWSMessagesBubblesSizeCalculator.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = OWSMessagesBubblesSizeCalculator.m; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objc; };
4542F0931EB9372700C7EE92 /* SystemContactsFetcher.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SystemContactsFetcher.swift; sourceTree = "<group>"; };
4542F0951EBB9E9A00C7EE92 /* Promise+retainUntilComplete.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Promise+retainUntilComplete.swift"; sourceTree = "<group>"; };
45464DBB1DFA041F001D3FD6 /* DataChannelMessage.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DataChannelMessage.swift; sourceTree = "<group>"; };

@ -128,8 +128,8 @@ NS_ASSUME_NONNULL_BEGIN
return [cachedSize CGSizeValue];
}
CGSize result = [self.referenceSystemMessageCell cellSizeForInteraction:interaction
collectionViewWidth:layout.collectionView.width];
CGSize result = [self.referenceSystemMessageCell bubbleSizeForInteraction:interaction
collectionViewWidth:layout.collectionView.width];
[self.cache setObject:[NSValue valueWithCGSize:result] forKey:cacheKey];
@ -148,8 +148,8 @@ NS_ASSUME_NONNULL_BEGIN
return [cachedSize CGSizeValue];
}
CGSize result = [self.referenceUnreadIndicatorCell cellSizeForInteraction:interaction
collectionViewWidth:layout.collectionView.width];
CGSize result = [self.referenceUnreadIndicatorCell bubbleSizeForInteraction:interaction
collectionViewWidth:layout.collectionView.width];
[self.cache setObject:[NSValue valueWithCGSize:result] forKey:cacheKey];

@ -111,8 +111,8 @@ typedef enum : NSUInteger {
@protocol OWSMessagesCollectionViewFlowLayoutDelegate <NSObject>
// Returns YES for incoming and outgoing text and attachment messages.
- (BOOL)isUserMessageAtIndexPath:(NSIndexPath *)indexPath;
// Returns YES for all but the unread indicator
- (BOOL)shouldShowCellDecorationsAtIndexPath:(NSIndexPath *)indexPath;
@end
@ -131,12 +131,12 @@ typedef enum : NSUInteger {
- (CGSize)sizeForItemAtIndexPath:(NSIndexPath *)indexPath
{
// The unread indicator should be sized according to its desired size.
if (![self.delegate isUserMessageAtIndexPath:indexPath]) {
if ([self.delegate shouldShowCellDecorationsAtIndexPath:indexPath]) {
return [super sizeForItemAtIndexPath:indexPath];
} else {
CGSize messageBubbleSize = [self messageBubbleSizeForItemAtIndexPath:indexPath];
CGFloat finalHeight = messageBubbleSize.height;
return CGSizeMake(CGRectGetWidth(self.collectionView.frame), ceilf((float)finalHeight));
} else {
return [super sizeForItemAtIndexPath:indexPath];
}
}
@ -4097,12 +4097,13 @@ typedef enum : NSUInteger {
#pragma mark - OWSMessagesCollectionViewFlowLayoutDelegate
- (BOOL)isUserMessageAtIndexPath:(NSIndexPath *)indexPath;
- (BOOL)shouldShowCellDecorationsAtIndexPath:(NSIndexPath *)indexPath
{
// TODO: Eventually it'd be nice to this in a more performant way.
TSInteraction *interaction = [self interactionAtIndexPath:indexPath];
return (
[interaction isKindOfClass:[TSIncomingMessage class]] || [interaction isKindOfClass:[TSOutgoingMessage class]]);
// Show any top/bottom labels for all but the unread indicator
return ![interaction isKindOfClass:[TSUnreadIndicatorInteraction class]];
}
#pragma mark - Class methods

@ -25,7 +25,7 @@ NS_ASSUME_NONNULL_BEGIN
- (void)configureWithInteraction:(TSInteraction *)interaction;
- (CGSize)cellSizeForInteraction:(TSInteraction *)interaction collectionViewWidth:(CGFloat)collectionViewWidth;
- (CGSize)bubbleSizeForInteraction:(TSInteraction *)interaction collectionViewWidth:(CGFloat)collectionViewWidth;
@end

@ -242,12 +242,6 @@ NS_ASSUME_NONNULL_BEGIN
return 20.f;
}
/// The default layout spacing for the top label (e.g. timestamp) feels a little too close for the system messages.
- (CGFloat)topLabelBottomMargin
{
return 4.f;
}
- (void)layoutSubviews
{
[super layoutSubviews];
@ -260,7 +254,7 @@ NS_ASSUME_NONNULL_BEGIN
CGSize topLabelSize = [self.cellTopLabel sizeThatFits:CGSizeMake(self.contentView.width, CGFLOAT_MAX)];
self.cellTopLabel.frame = CGRectMake(0, 0, self.contentView.frame.size.width, topLabelSize.height);
CGFloat topLabelSpacing = topLabelSize.height + [self topLabelBottomMargin];
CGFloat topLabelSpacing = topLabelSize.height;
self.imageView.frame = CGRectMake(round((self.contentView.width - contentWidth) * 0.5f),
round((self.contentView.height - [self iconSize] + topLabelSpacing) * 0.5f),
@ -273,7 +267,7 @@ NS_ASSUME_NONNULL_BEGIN
ceil(titleSize.height + 1.f));
}
- (CGSize)cellSizeForInteraction:(TSInteraction *)interaction collectionViewWidth:(CGFloat)collectionViewWidth
- (CGSize)bubbleSizeForInteraction:(TSInteraction *)interaction collectionViewWidth:(CGFloat)collectionViewWidth
{
CGSize result = CGSizeMake(collectionViewWidth, 0);
result.height += self.topVMargin;
@ -286,8 +280,6 @@ NS_ASSUME_NONNULL_BEGIN
CGFloat contentHeight = ceil(MAX([self iconSize], titleSize.height));
result.height += contentHeight;
result.height += [self topLabelBottomMargin];
return result;
}

@ -15,8 +15,8 @@ NS_ASSUME_NONNULL_BEGIN
- (void)configureWithInteraction:(TSUnreadIndicatorInteraction *)interaction;
- (CGSize)cellSizeForInteraction:(TSUnreadIndicatorInteraction *)interaction
collectionViewWidth:(CGFloat)collectionViewWidth;
- (CGSize)bubbleSizeForInteraction:(TSUnreadIndicatorInteraction *)interaction
collectionViewWidth:(CGFloat)collectionViewWidth;
@end

@ -200,8 +200,8 @@ NS_ASSUME_NONNULL_BEGIN
}
}
- (CGSize)cellSizeForInteraction:(TSUnreadIndicatorInteraction *)interaction
collectionViewWidth:(CGFloat)collectionViewWidth
- (CGSize)bubbleSizeForInteraction:(TSUnreadIndicatorInteraction *)interaction
collectionViewWidth:(CGFloat)collectionViewWidth
{
CGSize result = CGSizeMake(collectionViewWidth, 0);
result.height += self.titleVMargin * 2.f;

Loading…
Cancel
Save