Refine cell sizing.

pull/1/head
Matthew Chen 7 years ago
parent 7be6fbc24f
commit c6f370810b

@ -1026,7 +1026,6 @@ NS_ASSUME_NONNULL_BEGIN
} }
CGFloat hMargins = self.conversationStyle.textInsetHorizontal * 2; CGFloat hMargins = self.conversationStyle.textInsetHorizontal * 2;
const int maxTextWidth = (int)floor(self.conversationStyle.maxMessageWidth - hMargins); const int maxTextWidth = (int)floor(self.conversationStyle.maxMessageWidth - hMargins);
[self configureBodyTextView]; [self configureBodyTextView];
@ -1042,6 +1041,10 @@ NS_ASSUME_NONNULL_BEGIN
OWSAssert(self.conversationStyle.maxMessageWidth > 0); OWSAssert(self.conversationStyle.maxMessageWidth > 0);
CGFloat maxMessageWidth = self.conversationStyle.maxMessageWidth; CGFloat maxMessageWidth = self.conversationStyle.maxMessageWidth;
if (!self.hasFullWidthMediaView) {
CGFloat hMargins = self.conversationStyle.textInsetHorizontal * 2;
maxMessageWidth -= hMargins;
}
CGSize result = CGSizeZero; CGSize result = CGSizeZero;
switch (self.cellType) { switch (self.cellType) {
@ -1150,7 +1153,7 @@ NS_ASSUME_NONNULL_BEGIN
const int maxTextWidth = (int)floor(self.conversationStyle.maxMessageWidth - hMargins); const int maxTextWidth = (int)floor(self.conversationStyle.maxMessageWidth - hMargins);
[self configureSenderNameLabel]; [self configureSenderNameLabel];
CGSize result = CGSizeCeil([self.senderNameLabel sizeThatFits:CGSizeMake(maxTextWidth, CGFLOAT_MAX)]); CGSize result = CGSizeCeil([self.senderNameLabel sizeThatFits:CGSizeMake(maxTextWidth, CGFLOAT_MAX)]);
result.width = MIN(result.width, maxTextWidth);
return [NSValue valueWithCGSize:result]; return [NSValue valueWithCGSize:result];
} }
@ -1230,6 +1233,9 @@ NS_ASSUME_NONNULL_BEGIN
cellSize = CGSizeCeil(cellSize); cellSize = CGSizeCeil(cellSize);
OWSAssert(cellSize.width <= self.conversationStyle.maxMessageWidth);
cellSize.width = MIN(cellSize.width, self.conversationStyle.maxMessageWidth);
return cellSize; return cellSize;
} }

Loading…
Cancel
Save