From fef6c64bdc7113271e168349dd14a9be0d70d75b Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Fri, 13 Jul 2018 17:24:42 -0600 Subject: [PATCH 1/3] decrease header spacing from 32->28. Previous spacing was based on applying the "full width" gutter spacing twice. --- .../ConversationView/Cells/OWSMessageCell.m | 4 ++-- .../ConversationView/Cells/OWSMessageHeaderView.m | 4 ++-- SignalMessaging/utils/ConversationStyle.swift | 9 ++++++++- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageCell.m b/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageCell.m index 50d0b0830c..1b0953eb19 100644 --- a/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageCell.m +++ b/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageCell.m @@ -151,8 +151,8 @@ NS_ASSUME_NONNULL_BEGIN [self.contentView addSubview:self.headerView]; [self.viewConstraints addObjectsFromArray:@[ [self.headerView autoSetDimension:ALDimensionHeight toSize:headerHeight], - [self.headerView autoPinLeadingToSuperviewMarginWithInset:self.conversationStyle.fullWidthGutterLeading], - [self.headerView autoPinTrailingToSuperviewMarginWithInset:self.conversationStyle.fullWidthGutterTrailing], + [self.headerView autoPinLeadingToSuperviewMarginWithInset:self.conversationStyle.headerGutterLeading], + [self.headerView autoPinTrailingToSuperviewMarginWithInset:self.conversationStyle.headerGutterTrailing], [self.headerView autoPinEdgeToSuperviewEdge:ALEdgeTop], [self.messageBubbleView autoPinEdge:ALEdgeTop toEdge:ALEdgeBottom ofView:self.headerView], ]]; diff --git a/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageHeaderView.m b/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageHeaderView.m index cd1ab807d6..b9a213f54a 100644 --- a/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageHeaderView.m +++ b/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageHeaderView.m @@ -93,8 +93,8 @@ const CGFloat OWSMessageHeaderViewDateHeaderVMargin = 23; [self.strokeView autoSetDimension:ALDimensionHeight toSize:strokeThickness], [self.stackView autoPinEdgeToSuperviewEdge:ALEdgeTop], - [self.stackView autoPinEdgeToSuperviewEdge:ALEdgeLeading withInset:conversationStyle.fullWidthGutterLeading], - [self.stackView autoPinEdgeToSuperviewEdge:ALEdgeTrailing withInset:conversationStyle.fullWidthGutterTrailing], + [self.stackView autoPinEdgeToSuperviewEdge:ALEdgeLeading], + [self.stackView autoPinEdgeToSuperviewEdge:ALEdgeTrailing], ]; } diff --git a/SignalMessaging/utils/ConversationStyle.swift b/SignalMessaging/utils/ConversationStyle.swift index e13b6e8cbe..4e7a4d61d5 100644 --- a/SignalMessaging/utils/ConversationStyle.swift +++ b/SignalMessaging/utils/ConversationStyle.swift @@ -23,10 +23,15 @@ public class ConversationStyle: NSObject { @objc public var gutterLeading: CGFloat = 0 @objc public var gutterTrailing: CGFloat = 0 + + @objc public var headerGutterLeading: CGFloat = 28 + @objc public var headerGutterTrailing: CGFloat = 28 + // These are the gutters used by "full width" views - // like "date headers" and "unread indicator". + // like "contact offer" and "info message". @objc public var fullWidthGutterLeading: CGFloat = 0 @objc public var fullWidthGutterTrailing: CGFloat = 0 + @objc public var errorGutterTrailing: CGFloat = 0 // viewWidth - (gutterLeading + gutterTrailing) @@ -88,6 +93,8 @@ public class ConversationStyle: NSObject { } fullWidthGutterLeading = 16 fullWidthGutterTrailing = 16 + headerGutterLeading = 28 + headerGutterTrailing = 28 errorGutterTrailing = 16 contentWidth = viewWidth - (gutterLeading + gutterTrailing) From f33e5c019c78b2fc6f7e2c8d56e8e85688f9a881 Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Mon, 16 Jul 2018 10:14:08 -0600 Subject: [PATCH 2/3] CR: assign gutter trailing/leading in HeaderView // FREEBIE --- .../ViewControllers/ConversationView/Cells/OWSMessageCell.m | 4 ++-- .../ConversationView/Cells/OWSMessageHeaderView.m | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageCell.m b/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageCell.m index 1b0953eb19..389c95ae3f 100644 --- a/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageCell.m +++ b/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageCell.m @@ -151,8 +151,8 @@ NS_ASSUME_NONNULL_BEGIN [self.contentView addSubview:self.headerView]; [self.viewConstraints addObjectsFromArray:@[ [self.headerView autoSetDimension:ALDimensionHeight toSize:headerHeight], - [self.headerView autoPinLeadingToSuperviewMarginWithInset:self.conversationStyle.headerGutterLeading], - [self.headerView autoPinTrailingToSuperviewMarginWithInset:self.conversationStyle.headerGutterTrailing], + [self.headerView autoPinEdgeToSuperviewEdge:ALEdgeLeading], + [self.headerView autoPinEdgeToSuperviewEdge:ALEdgeTrailing], [self.headerView autoPinEdgeToSuperviewEdge:ALEdgeTop], [self.messageBubbleView autoPinEdge:ALEdgeTop toEdge:ALEdgeBottom ofView:self.headerView], ]]; diff --git a/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageHeaderView.m b/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageHeaderView.m index b9a213f54a..5ed447e2fc 100644 --- a/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageHeaderView.m +++ b/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageHeaderView.m @@ -93,8 +93,8 @@ const CGFloat OWSMessageHeaderViewDateHeaderVMargin = 23; [self.strokeView autoSetDimension:ALDimensionHeight toSize:strokeThickness], [self.stackView autoPinEdgeToSuperviewEdge:ALEdgeTop], - [self.stackView autoPinEdgeToSuperviewEdge:ALEdgeLeading], - [self.stackView autoPinEdgeToSuperviewEdge:ALEdgeTrailing], + [self.stackView autoPinEdgeToSuperviewEdge:ALEdgeLeading withInset:conversationStyle.headerGutterLeading], + [self.stackView autoPinEdgeToSuperviewEdge:ALEdgeTrailing withInset:conversationStyle.headerGutterTrailing] ]; } From 24060c17d03aca64431d32f866ae5afcdd91bd85 Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Mon, 16 Jul 2018 10:17:50 -0600 Subject: [PATCH 3/3] CR: proper width calculation for header view --- .../Cells/OWSMessageHeaderView.m | 2 +- SignalMessaging/utils/ConversationStyle.swift | 18 ++++++++++-------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageHeaderView.m b/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageHeaderView.m index 5ed447e2fc..ee637bf3b1 100644 --- a/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageHeaderView.m +++ b/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageHeaderView.m @@ -170,7 +170,7 @@ const CGFloat OWSMessageHeaderViewDateHeaderVMargin = 23; CGFloat strokeThickness = [self strokeThicknessWithViewItem:viewItem]; result.height += strokeThickness; - CGFloat maxTextWidth = conversationStyle.fullWidthContentWidth; + CGFloat maxTextWidth = conversationStyle.headerViewContentWidth; CGSize titleSize = [self.titleLabel sizeThatFits:CGSizeMake(maxTextWidth, CGFLOAT_MAX)]; result.height += titleSize.height + self.stackView.spacing; diff --git a/SignalMessaging/utils/ConversationStyle.swift b/SignalMessaging/utils/ConversationStyle.swift index 4e7a4d61d5..7cbbdf3117 100644 --- a/SignalMessaging/utils/ConversationStyle.swift +++ b/SignalMessaging/utils/ConversationStyle.swift @@ -34,11 +34,17 @@ public class ConversationStyle: NSObject { @objc public var errorGutterTrailing: CGFloat = 0 - // viewWidth - (gutterLeading + gutterTrailing) - @objc public var contentWidth: CGFloat = 0 + @objc public var contentWidth: CGFloat { + return viewWidth - (gutterLeading + gutterTrailing) + } - // viewWidth - (gutterfullWidthGutterLeadingLeading + fullWidthGutterTrailing) - @objc public var fullWidthContentWidth: CGFloat = 0 + @objc public var fullWidthContentWidth: CGFloat { + return viewWidth - (fullWidthGutterLeading + fullWidthGutterTrailing) + } + + @objc public var headerViewContentWidth: CGFloat { + return viewWidth - (headerGutterLeading + headerGutterTrailing) + } @objc public var maxMessageWidth: CGFloat = 0 @@ -97,10 +103,6 @@ public class ConversationStyle: NSObject { headerGutterTrailing = 28 errorGutterTrailing = 16 - contentWidth = viewWidth - (gutterLeading + gutterTrailing) - - fullWidthContentWidth = viewWidth - (fullWidthGutterLeading + fullWidthGutterTrailing) - maxMessageWidth = floor(contentWidth - 32) let messageTextFont = UIFont.ows_dynamicTypeBody